001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.html.dom;
018:
019: import org.w3c.dom.Node;
020: import org.w3c.dom.Text;
021: import org.w3c.dom.html.HTMLScriptElement;
022:
023: /**
024: * @xerces.internal
025: * @version $Revision: 447255 $ $Date: 2006-09-18 01:36:42 -0400 (Mon, 18 Sep 2006) $
026: * @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
027: * @see org.w3c.dom.html.HTMLScriptElement
028: * @see org.apache.xerces.dom.ElementImpl
029: */
030: public class HTMLScriptElementImpl extends HTMLElementImpl implements
031: HTMLScriptElement {
032:
033: private static final long serialVersionUID = 5090330049085326558L;
034:
035: public String getText() {
036: Node child;
037: StringBuffer text = new StringBuffer();
038:
039: // Find the Text nodes contained within this element and return their
040: // concatenated value. Required to go around comments, entities, etc.
041: child = getFirstChild();
042: while (child != null) {
043: if (child instanceof Text) {
044: text.append(((Text) child).getData());
045: }
046: child = child.getNextSibling();
047: }
048: return text.toString();
049: }
050:
051: public void setText(String text) {
052: Node child;
053: Node next;
054:
055: // Delete all the nodes and replace them with a single Text node.
056: // This is the only approach that can handle comments and other nodes.
057: child = getFirstChild();
058: while (child != null) {
059: next = child.getNextSibling();
060: removeChild(child);
061: child = next;
062: }
063: insertBefore(getOwnerDocument().createTextNode(text),
064: getFirstChild());
065: }
066:
067: public String getHtmlFor() {
068: return getAttribute("for");
069: }
070:
071: public void setHtmlFor(String htmlFor) {
072: setAttribute("for", htmlFor);
073: }
074:
075: public String getEvent() {
076: return getAttribute("event");
077: }
078:
079: public void setEvent(String event) {
080: setAttribute("event", event);
081: }
082:
083: public String getCharset() {
084: return getAttribute("charset");
085: }
086:
087: public void setCharset(String charset) {
088: setAttribute("charset", charset);
089: }
090:
091: public boolean getDefer() {
092: return getBinary("defer");
093: }
094:
095: public void setDefer(boolean defer) {
096: setAttribute("defer", defer);
097: }
098:
099: public String getSrc() {
100: return getAttribute("src");
101: }
102:
103: public void setSrc(String src) {
104: setAttribute("src", src);
105: }
106:
107: public String getType() {
108: return getAttribute("type");
109: }
110:
111: public void setType(String type) {
112: setAttribute("type", type);
113: }
114:
115: /**
116: * Constructor requires owner document.
117: *
118: * @param owner The owner HTML document
119: */
120: public HTMLScriptElementImpl(HTMLDocumentImpl owner, String name) {
121: super(owner, name);
122: }
123:
124: }
|