01: /**
02: * org/ozone-db/xml/dom/html/HTMLTitleElementImpl.java
03: *
04: * The contents of this file are subject to the OpenXML Public
05: * License Version 1.0; you may not use this file except in compliance
06: * with the License. You may obtain a copy of the License at
07: * http://www.openxml.org/license.html
08: *
09: * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
10: * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
11: * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
12: * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
13: * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
14: * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
15: *
16: * The Initial Developer of this code under the License is Assaf Arkin.
17: * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
18: * All Rights Reserved.
19: */package org.ozoneDB.xml.dom.html;
20:
21: import org.ozoneDB.xml.dom.*;
22: import org.w3c.dom.*;
23: import org.w3c.dom.html.*;
24:
25: /**
26: * @version $Revision: 1.1 $ $Date: 2001/12/18 11:03:24 $
27: * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
28: * @see org.w3c.dom.html.HTMLTitleElement
29: * @see ElementImpl
30: */
31: public final class HTMLTitleElementImpl extends HTMLElementImpl
32: implements HTMLTitleElement {
33:
34: public String getText() {
35: Node child;
36: String text;
37:
38: // Find the Text nodes contained within this element and return their
39: // concatenated value. Required to go around comments, entities, etc.
40: child = getFirstChild();
41: text = "";
42: while (child != null) {
43: if (child instanceof Text) {
44: text = text + ((Text) child).getData();
45: }
46: child = child.getNextSibling();
47: }
48: return text;
49: }
50:
51: public void setText(String text) {
52: Node child;
53: Node next;
54:
55: // Delete all the nodes and replace them with a single Text node.
56: // This is the only approach that can handle comments and other nodes.
57: child = getFirstChild();
58: while (child != null) {
59: next = child.getNextSibling();
60: removeChild(child);
61: child = next;
62: }
63: insertBefore(getOwnerDocument().createTextNode(text),
64: getFirstChild());
65: }
66:
67: /**
68: * Constructor requires owner document.
69: *
70: * @param owner The owner HTML document
71: */
72: public HTMLTitleElementImpl(HTMLDocumentImpl owner, String name) {
73: super (owner, "TITLE");
74: }
75:
76: }
|