KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom > html > HTMLTitleElementImpl


1 /**
2  * org/ozone-db/xml/dom/html/HTMLTitleElementImpl.java
3  *
4  * The contents of this file are subject to the OpenXML Public
5  * License Version 1.0; you may not use this file except in compliance
6  * with the License. You may obtain a copy of the License at
7  * http://www.openxml.org/license.html
8  *
9  * 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  */

20
21 package org.ozoneDB.xml.dom.html;
22
23 import org.ozoneDB.xml.dom.ElementImpl;
24 import org.w3c.dom.Node JavaDoc;
25 import org.w3c.dom.Text JavaDoc;
26 import org.w3c.dom.html.HTMLTitleElement;
27
28
29 /**
30  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
31  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
32  * @see org.w3c.dom.html.HTMLTitleElement
33  * @see ElementImpl
34  */

35 public final class HTMLTitleElementImpl extends HTMLElementImpl implements HTMLTitleElement {
36
37
38     public String JavaDoc getText() {
39         Node JavaDoc child;
40         String JavaDoc text;
41
42         // Find the Text nodes contained within this element and return their
43
// concatenated value. Required to go around comments, entities, etc.
44
child = getFirstChild();
45         text = "";
46         while (child != null) {
47             if (child instanceof Text JavaDoc) {
48                 text = text + ((Text JavaDoc)child).getData();
49             }
50             child = child.getNextSibling();
51         }
52         return text;
53     }
54
55
56     public void setText( String JavaDoc text ) {
57         Node JavaDoc child;
58         Node JavaDoc next;
59
60         // Delete all the nodes and replace them with a single Text node.
61
// This is the only approach that can handle comments and other nodes.
62
child = getFirstChild();
63         while (child != null) {
64             next = child.getNextSibling();
65             removeChild( child );
66             child = next;
67         }
68         insertBefore( getOwnerDocument().createTextNode( text ), getFirstChild() );
69     }
70
71
72     /**
73      * Constructor requires owner document.
74      *
75      * @param owner The owner HTML document
76      */

77     public HTMLTitleElementImpl( HTMLDocumentImpl owner, String JavaDoc name ) {
78         super( owner, "TITLE" );
79     }
80
81 }
82
Popular Tags