001: /**
002: * org/ozone-db/xml/dom/html/HTMLScriptElementImpl.java
003: *
004: * The contents of this file are subject to the OpenXML Public
005: * License Version 1.0; you may not use this file except in compliance
006: * with the License. You may obtain a copy of the License at
007: * http://www.openxml.org/license.html
008: *
009: * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY
010: * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER
011: * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A
012: * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
013: * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
014: * RIGHTS AND LIMITATIONS UNDER THE LICENSE.
015: *
016: * The Initial Developer of this code under the License is Assaf Arkin.
017: * Portions created by Assaf Arkin are Copyright (C) 1998, 1999.
018: * All Rights Reserved.
019: */package org.ozoneDB.xml.dom.html;
020:
021: import org.ozoneDB.xml.dom.*;
022: import org.w3c.dom.*;
023: import org.w3c.dom.html.*;
024:
025: /**
026: * @version $Revision: 1.1 $ $Date: 2001/12/18 11:03:24 $
027: * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a>
028: * @see org.w3c.dom.html.HTMLScriptElement
029: * @see ElementImpl
030: */
031: public final class HTMLScriptElementImpl extends HTMLElementImpl
032: implements HTMLScriptElement {
033:
034: public String getText() {
035: Node child;
036: String text;
037:
038: // Find the Text nodes contained within this element and return their
039: // concatenated value. Required to go around comments, entities, etc.
040: child = getFirstChild();
041: text = "";
042: while (child != null) {
043: if (child instanceof Text) {
044: text = text + ((Text) child).getData();
045: }
046: child = child.getNextSibling();
047: }
048: return text;
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 getAttribute("defer") != null;
093: }
094:
095: public void setDefer(boolean defer) {
096: setAttribute("defer", defer ? "" : null);
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, "SCRIPT");
122: }
123:
124: }
|