KickJava   Java API By Example, From Geeks To Geeks.

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


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: HTMLDocumentFactory.java,v 1.2 2005/01/26 08:29:24 jkjome Exp $
22  */

23
24 package org.enhydra.xml.xmlc.html;
25
26 import org.enhydra.xml.xmlc.dom.XMLCDomFactory;
27 import org.enhydra.xml.xmlc.dom.xerces.XercesHTMLDomFactory;
28 import org.w3c.dom.html.HTMLDocument;
29
30 /**
31  * Factory class for constructing new HTMLDocument objects without
32  * needing to know the implementing class.
33  */

34 public class HTMLDocumentFactory {
35     /**
36      * Factory for creating documents.
37      */

38     private static XMLCDomFactory domFactory = new XercesHTMLDomFactory();
39
40     /**
41      * Constructor that prevents instantiation.
42      */

43     private HTMLDocumentFactory() {
44     }
45
46     /**
47      * Create a new HTMLDocument object. The document will contain an
48      * empty HTML element.
49      */

50     static public HTMLDocument createDocument() {
51         return (HTMLDocument)domFactory.createDocument(null, null, null);
52     }
53
54     /**
55      * Create a new HTMLDocument object, initialized with
56      * empty HTML, HEAD, TITLE and BODY elements.
57      * @param title The title string to set in the header.
58      */

59     static public HTMLDocument createBasicDocument(String JavaDoc title) {
60         HTMLDocument doc = createDocument();
61
62         // This creates head and title
63
doc.setTitle(title);
64         // This creates body
65
doc.getBody();
66
67         return doc;
68     }
69
70     /**
71      * Create a new HTMLDocument object, initialized with
72      * empty HTML, HEAD, TITLE and BODY elements.
73      */

74     static public HTMLDocument createBasicDocument() {
75         return createBasicDocument("");
76     }
77 }
78
Popular Tags