KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > html > dom > HTMLTitleElementImpl


1 /*
2  * Copyright 1999,2000,2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.html.dom;
17
18 import org.w3c.dom.Node JavaDoc;
19 import org.w3c.dom.Text JavaDoc;
20 import org.w3c.dom.html.HTMLTitleElement;
21
22 /**
23  * @xerces.internal
24  * @version $Revision: 1.10 $ $Date: 2005/04/18 01:20:21 $
25  * @author <a HREF="mailto:arkin@exoffice.com">Assaf Arkin</a>
26  * @see org.w3c.dom.html.HTMLTitleElement
27  * @see org.apache.xerces.dom.ElementImpl
28  */

29 public class HTMLTitleElementImpl
30     extends HTMLElementImpl
31     implements HTMLTitleElement
32 {
33
34     private static final long serialVersionUID = 4050769294810034992L;
35
36     public String JavaDoc getText()
37     {
38         Node JavaDoc child;
39         StringBuffer JavaDoc text = new StringBuffer JavaDoc();
40         
41         // Find the Text nodes contained within this element and return their
42
// concatenated value. Required to go around comments, entities, etc.
43
child = getFirstChild();
44         while ( child != null )
45         {
46             if ( child instanceof Text JavaDoc ) {
47                 text.append(( (Text JavaDoc) child ).getData());
48             }
49             child = child.getNextSibling();
50         }
51         return text.toString();
52     }
53     
54     
55     public void setText( String JavaDoc text )
56     {
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         {
65             next = child.getNextSibling();
66             removeChild( child );
67             child = next;
68         }
69         insertBefore( getOwnerDocument().createTextNode( text ), getFirstChild() );
70     }
71
72         
73       /**
74      * Constructor requires owner document.
75      *
76      * @param owner The owner HTML document
77      */

78     public HTMLTitleElementImpl( HTMLDocumentImpl owner, String JavaDoc name )
79     {
80         super( owner, name );
81     }
82
83   
84 }
85
86
Popular Tags