KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * org/ozone-db/xml/dom/html/HTMLScriptElementImpl.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
22 package org.ozoneDB.xml.dom.html;
23
24
25 import org.ozoneDB.xml.dom.ElementImpl;
26 import org.w3c.dom.Node JavaDoc;
27 import org.w3c.dom.Text JavaDoc;
28 import org.w3c.dom.html.HTMLScriptElement;
29
30
31 /**
32  * @version $Revision: 1.2 $ $Date: 2003/11/20 23:18:42 $
33  * @author <a HREF="mailto:arkin@trendline.co.il">Assaf Arkin</a>
34  * @see org.w3c.dom.html.HTMLScriptElement
35  * @see ElementImpl
36  */

37 public final class HTMLScriptElementImpl extends HTMLElementImpl implements HTMLScriptElement {
38
39
40     public String JavaDoc getText() {
41         Node JavaDoc child;
42         String JavaDoc text;
43
44         // Find the Text nodes contained within this element and return their
45
// concatenated value. Required to go around comments, entities, etc.
46
child = getFirstChild();
47         text = "";
48         while (child != null) {
49             if (child instanceof Text JavaDoc) {
50                 text = text + ((Text JavaDoc)child).getData();
51             }
52             child = child.getNextSibling();
53         }
54         return text;
55     }
56
57
58     public void setText( String JavaDoc text ) {
59         Node JavaDoc child;
60         Node JavaDoc next;
61
62         // Delete all the nodes and replace them with a single Text node.
63
// This is the only approach that can handle comments and other nodes.
64
child = getFirstChild();
65         while (child != null) {
66             next = child.getNextSibling();
67             removeChild( child );
68             child = next;
69         }
70         insertBefore( getOwnerDocument().createTextNode( text ), getFirstChild() );
71     }
72
73
74     public String JavaDoc getHtmlFor() {
75         return getAttribute( "for" );
76     }
77
78
79     public void setHtmlFor( String JavaDoc htmlFor ) {
80         setAttribute( "for", htmlFor );
81     }
82
83
84     public String JavaDoc getEvent() {
85         return getAttribute( "event" );
86     }
87
88
89     public void setEvent( String JavaDoc event ) {
90         setAttribute( "event", event );
91     }
92
93
94     public String JavaDoc getCharset() {
95         return getAttribute( "charset" );
96     }
97
98
99     public void setCharset( String JavaDoc charset ) {
100         setAttribute( "charset", charset );
101     }
102
103
104     public boolean getDefer() {
105         return getAttribute( "defer" ) != null;
106     }
107
108
109     public void setDefer( boolean defer ) {
110         setAttribute( "defer", defer ? "" : null );
111     }
112
113
114     public String JavaDoc getSrc() {
115         return getAttribute( "src" );
116     }
117
118
119     public void setSrc( String JavaDoc src ) {
120         setAttribute( "src", src );
121     }
122
123
124     public String JavaDoc getType() {
125         return getAttribute( "type" );
126     }
127
128
129     public void setType( String JavaDoc type ) {
130         setAttribute( "type", type );
131     }
132
133
134     /**
135      * Constructor requires owner document.
136      *
137      * @param owner The owner HTML document
138      */

139     public HTMLScriptElementImpl( HTMLDocumentImpl owner, String JavaDoc name ) {
140         super( owner, "SCRIPT" );
141     }
142
143
144 }
145
Popular Tags