KickJava   Java API By Example, From Geeks To Geeks.

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


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.HTMLScriptElement;
21
22 /**
23  * @xerces.internal
24  * @version $Revision: 1.10 $ $Date: 2005/04/18 01:12:37 $
25  * @author <a HREF="mailto:arkin@exoffice.com">Assaf Arkin</a>
26  * @see org.w3c.dom.html.HTMLScriptElement
27  * @see org.apache.xerces.dom.ElementImpl
28  */

29 public class HTMLScriptElementImpl
30     extends HTMLElementImpl
31     implements HTMLScriptElement
32 {
33
34     private static final long serialVersionUID = 3832626162072498224L;
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        public String JavaDoc getHtmlFor()
74     {
75         return getAttribute( "for" );
76     }
77     
78     
79     public void setHtmlFor( String JavaDoc htmlFor )
80     {
81         setAttribute( "for", htmlFor );
82     }
83
84     
85        public String JavaDoc getEvent()
86     {
87         return getAttribute( "event" );
88     }
89     
90     
91     public void setEvent( String JavaDoc event )
92     {
93         setAttribute( "event", event );
94     }
95     
96        public String JavaDoc getCharset()
97     {
98         return getAttribute( "charset" );
99     }
100     
101     
102     public void setCharset( String JavaDoc charset )
103     {
104         setAttribute( "charset", charset );
105     }
106
107     
108     public boolean getDefer()
109     {
110         return getBinary( "defer" );
111     }
112     
113     
114     public void setDefer( boolean defer )
115     {
116         setAttribute( "defer", defer );
117     }
118
119   
120        public String JavaDoc getSrc()
121     {
122         return getAttribute( "src" );
123     }
124     
125     
126     public void setSrc( String JavaDoc src )
127     {
128         setAttribute( "src", src );
129     }
130
131   
132     public String JavaDoc getType()
133     {
134         return getAttribute( "type" );
135     }
136     
137     
138     public void setType( String JavaDoc type )
139     {
140         setAttribute( "type", type );
141     }
142     
143     
144       /**
145      * Constructor requires owner document.
146      *
147      * @param owner The owner HTML document
148      */

149     public HTMLScriptElementImpl( HTMLDocumentImpl owner, String JavaDoc name )
150     {
151         super( owner, name );
152     }
153
154   
155 }
156
157
Popular Tags