KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > html > HTMLObjectImpl


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 Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: HTMLObjectImpl.java,v 1.3 2005/01/26 08:29:24 jkjome Exp $
22  */

23
24 package org.enhydra.xml.xmlc.html;
25
26 import org.enhydra.xml.io.DOMFormatter;
27 import org.enhydra.xml.xmlc.XMLObjectImpl;
28 import org.w3c.dom.Element JavaDoc;
29 import org.w3c.dom.Node JavaDoc;
30 import org.w3c.dom.NodeList JavaDoc;
31 import org.w3c.dom.html.HTMLCollection;
32 import org.w3c.dom.html.HTMLDocument;
33 import org.w3c.dom.html.HTMLElement;
34
35 // Note: Most methods in this object don't need to directly
36
// implement delegation, as they operate on the document,
37
// returned by getDocument(), which is delegate.
38

39 /**
40  * Abstract class that forms the base of all compiled HTML Objects.
41  */

42 public abstract class HTMLObjectImpl extends XMLObjectImpl
43     implements HTMLObject {
44     /**
45      * Default HTML formatting object for use by toDocument(). Initialized
46      * on first use and shared
47      */

48     private static DOMFormatter fFormatter = null;
49
50     /**
51      * Constructor. The setDocument() method must be called to
52      * associate a document with this object.
53      */

54     protected HTMLObjectImpl() {
55     }
56
57     /**
58      * Clone the entire document. Derived objects should override this
59      * to get the correct derived type. Cloning with deep being false
60      * is not allowed.
61      *
62      * @see org.w3c.dom.Node#cloneNode
63      */

64     abstract public Node JavaDoc cloneNode(boolean deep);
65
66     /**
67      * @see HTMLObject#toDocument
68      */

69     public String JavaDoc toDocument() {
70         // Create formatter if needed (no synchronization necessary)
71
if (fFormatter == null) {
72             fFormatter = new DOMFormatter(DOMFormatter.getDefaultOutputOptions(getDocument()));
73         }
74         return fFormatter.toString(this);
75     }
76
77     /**
78      * @see org.w3c.dom.html.HTMLDocument#getTitle
79      */

80     public String JavaDoc getTitle() {
81         return ((HTMLDocument)getDocument()).getTitle();
82     }
83
84     /**
85      * @see org.w3c.dom.html.HTMLDocument#setTitle
86      */

87     public void setTitle(String JavaDoc title) {
88         ((HTMLDocument)getDocument()).setTitle(title);
89     }
90
91     /**
92      * @see org.w3c.dom.html.HTMLDocument#getReferrer
93      */

94     public String JavaDoc getReferrer() {
95         return ((HTMLDocument)getDocument()).getReferrer();
96     }
97
98     /**
99      * @see org.w3c.dom.html.HTMLDocument#getDomain
100      */

101     public String JavaDoc getDomain() {
102         return ((HTMLDocument)getDocument()).getDomain();
103     }
104     
105     /**
106      * @see org.w3c.dom.html.HTMLDocument
107      */

108     public String JavaDoc getURL() {
109         return ((HTMLDocument)getDocument()).getURL();
110     }
111
112     /**
113      * @see org.w3c.dom.html.HTMLDocument
114      */

115     public HTMLElement getBody() {
116         return ((HTMLDocument)getDocument()).getBody();
117     }
118
119     /**
120      * @see org.w3c.dom.html.HTMLDocument#setBody
121      */

122     public void setBody(HTMLElement body) {
123         ((HTMLDocument)getDocument()).setBody(body);
124     }
125
126     /**
127      * @see org.w3c.dom.html.HTMLDocument#getImages
128      */

129     public HTMLCollection getImages() {
130         return ((HTMLDocument)getDocument()).getImages();
131     }
132
133     /**
134      * @see org.w3c.dom.html.HTMLDocument
135      */

136     public HTMLCollection getApplets() {
137         return ((HTMLDocument)getDocument()).getApplets();
138     }
139
140     /**
141      * @see org.w3c.dom.html.HTMLDocument
142      */

143     public HTMLCollection getLinks() {
144         return ((HTMLDocument)getDocument()).getLinks();
145     }
146
147     /**
148      * @see org.w3c.dom.html.HTMLDocument#getForms
149      */

150     public HTMLCollection getForms() {
151         return ((HTMLDocument)getDocument()).getForms();
152     }
153
154     /**
155      * @see org.w3c.dom.html.HTMLDocument#getAnchors
156      */

157     public HTMLCollection getAnchors() {
158         return ((HTMLDocument)getDocument()).getAnchors();
159     }
160
161     /**
162      * @see org.w3c.dom.html.HTMLDocument#getCookie
163      */

164     public String JavaDoc getCookie() {
165         return ((HTMLDocument)getDocument()).getCookie();
166     }
167
168     /**
169      * @see org.w3c.dom.html.HTMLDocument#setCookie
170      */

171     public void setCookie(String JavaDoc cookie) {
172         ((HTMLDocument)getDocument()).setCookie(cookie);
173     }
174
175     /**
176      * @see org.w3c.dom.html.HTMLDocument#open
177      */

178     public void open() {
179         ((HTMLDocument)getDocument()).open();
180     }
181
182     /**
183      * @see org.w3c.dom.html.HTMLDocument#close
184      */

185     public void close() {
186         ((HTMLDocument)getDocument()).close();
187     }
188
189     /**
190      * @see org.w3c.dom.html.HTMLDocument#write
191      */

192     public void write(String JavaDoc text) {
193         ((HTMLDocument)getDocument()).write(text);
194     }
195
196     /**
197      * @see org.w3c.dom.html.HTMLDocument#writeln
198      */

199     public void writeln(String JavaDoc text) {
200         ((HTMLDocument)getDocument()).writeln(text);
201     }
202
203     /**
204      * @see org.w3c.dom.html.HTMLDocument#getElementById
205      */

206     public Element JavaDoc getElementById(String JavaDoc elementId) {
207         return ((HTMLDocument)getDocument()).getElementById(elementId);
208     }
209
210     /**
211      * @see org.w3c.dom.html.HTMLDocument#getElementsByName
212      */

213     public NodeList JavaDoc getElementsByName(String JavaDoc elementName) {
214         return ((HTMLDocument)getDocument()).getElementsByName(elementName);
215     }
216 }
217
Popular Tags