KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xhtml > dom > xerces > XHTMLTitleElementImpl


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Original Code is DigitalSesame
15  * Portions created by DigitalSesame are Copyright (C) 1997-2000 DigitalSesame
16  * All Rights Reserved.
17  *
18  * Contributor(s):
19  * Rex Tsai <chihchun@digitalsesame.com>
20  * David Li <david@digitalsesam.com>
21  *
22  * $Id: XHTMLTitleElementImpl.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
23  */

24
25 package org.enhydra.xml.xhtml.dom.xerces;
26
27 import org.w3c.dom.Node JavaDoc;
28 import org.w3c.dom.Text JavaDoc;
29
30 public class XHTMLTitleElementImpl
31     extends XHTMLElementImpl
32     implements org.enhydra.xml.xhtml.dom.XHTMLTitleElement
33 {
34
35     public XHTMLTitleElementImpl (XHTMLDocumentBase owner, String JavaDoc namespaceURI, String JavaDoc tagName) {
36     super( owner, namespaceURI, tagName);
37     }
38
39         public void setId (String JavaDoc newValue) {
40     setAttribute("id", newValue);
41     }
42
43     public String JavaDoc getId () {
44     return getAttribute ("id");
45     }
46     public void setLang (String JavaDoc newValue) {
47     setAttribute("lang", newValue);
48     }
49
50     public String JavaDoc getLang () {
51     return getAttribute ("lang");
52     }
53     public void setDir (String JavaDoc newValue) {
54     setAttribute("dir", newValue);
55     }
56
57     public String JavaDoc getDir () {
58     return getAttribute ("dir");
59     }
60     public void setClassName (String JavaDoc newValue) {
61     setAttribute("class", newValue);
62     }
63
64     public String JavaDoc getClassName () {
65     return getAttribute ("class");
66     }
67     public void setTitle (String JavaDoc newValue) {
68     setAttribute("title", newValue);
69     }
70
71     public String JavaDoc getTitle () {
72     return getAttribute ("title");
73     }
74     public void setXmlLang (String JavaDoc newValue) {
75     setAttribute("xml:lang", newValue);
76     }
77
78     public String JavaDoc getXmlLang () {
79     return getAttribute ("xml:lang");
80     }
81 ;
82
83         public String JavaDoc getText() {
84         Node JavaDoc child;
85         String JavaDoc text;
86         
87         // Find the Text nodes contained within this element and return their
88
// concatenated value. Required to go around comments, entities, etc.
89
child = getFirstChild();
90         text = "";
91         while ( child != null ) {
92             if ( child instanceof Text JavaDoc )
93                 text = text + ( (Text JavaDoc) child ).getData();
94             child = child.getNextSibling();
95         }
96         return text;
97     }
98     
99     public void setText( String JavaDoc text ) {
100         Node JavaDoc child;
101         Node JavaDoc next;
102         
103         // Delete all the nodes and replace them with a single Text node.
104
// This is the only approach that can handle comments and other nodes.
105
child = getFirstChild();
106         while ( child != null ) {
107             next = child.getNextSibling();
108             removeChild( child );
109             child = next;
110         }
111         insertBefore( getOwnerDocument().createTextNode( text ), getFirstChild() );
112     }
113
114
115 ;
116 }
117
118
119
Popular Tags