KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xmlc > dom > XMLCDomFactory


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

23
24 package org.enhydra.xml.xmlc.dom;
25
26 import org.w3c.dom.Document JavaDoc;
27 import org.w3c.dom.DocumentType JavaDoc;
28 import org.w3c.dom.Element JavaDoc;
29 import org.w3c.dom.Node JavaDoc;
30
31
32 /**
33  * Interface for a factory class that can create DocumentType and Document
34  * objects. It also provides document-type specific functions. This is
35  * used in implementing subclassed DOMs.
36  * <P>
37  * Classes implementing this must:
38  * <UL>
39  * <LI> Provide a constructor that takes no arguments.
40  * <LI> Be thread-safe (reentrant is preferred).
41  * </UL>
42  * When a DTD-specific DOM is created, an class implementing this interface
43  * must be supplied to XMLC. This would normally be created by extending the
44  * XMLCDomDefaultFactory class.
45  * <P>
46  * This class is designed to be build using a DOMImplementation object.
47  * However, since the DOM doesn't specify how DOMImplementation objects
48  * are obtained, we hide that detail. The methods are somewhat different
49  * for historic reasons.
50  *
51  * @see org.w3c.dom.DOMImplementation
52  * @see org.w3c.dom.html.HTMLDOMImplementation
53  */

54 public interface XMLCDomFactory {
55
56     //FIXME: Way of returning URL attribute names would allow for
57
// more efficient code.
58

59     /**
60      * Creates an empty <code>DocumentType</code> node.
61      *
62      * @param qualifiedName The document type name (same as the root element).
63      * @param publicID The document type public identifier.
64      * @param systemID The document type system identifier.
65      * @param internalSubset The internal subset as a string.
66      * @return A new <code>DocumentType</code> node.
67      */

68     public DocumentType JavaDoc createDocumentType(String JavaDoc qualifiedName,
69                                            String JavaDoc publicID,
70                                            String JavaDoc systemID,
71                                            String JavaDoc internalSubset);
72
73     /**
74      * Creates an XML <code>Document</code> object of the specified type. The
75      * document element should be created. A HTML document should
76      * only have the document element, which differs from the
77      * <code>DOMImplementation</code> specification, however it makes
78      * code generation easier and its not expected that there will be
79      * many custom HTML DOM factories.
80      *
81      * @param namespaceURI The namespace URI of the document element to
82      * create, or null.
83      * @param qualifiedName The document type name (same as the root element).
84      * Maybe null for HTML documents or documents without DTDs.
85      * @param doctype The type of document to be created or <code>null</code>.
86      * When <code>doctype</code> is not <code>null</code>, its
87      * <code>Node.ownerDocument</code> attribute is set to the document being
88      * created. Maybe null for for documents without DTDs or HTML documents.
89      * @return A new <code>Document</code> object.
90      * @see org.w3c.dom.DOMImplementation
91      * @see org.w3c.dom.html.HTMLDOMImplementation
92      */

93     public Document JavaDoc createDocument(String JavaDoc namespaceURI,
94                                    String JavaDoc qualifiedName,
95                                    DocumentType JavaDoc doctype);
96
97     /**
98      * Get the MIME type to associated with the document, or null
99      * if none should be associated.
100      */

101     public String JavaDoc getMIMEType();
102
103     /**
104      * Get the base class name for generated classes. It must extend
105      * XMLObjectImpl. This class maybe overridden for individual documents
106      * that are compiled.
107      */

108     public String JavaDoc getBaseClassName();
109
110     /**
111      * Get the interface names that will automatically be added to all
112      * generated classes and interfaces. This class maybe overridden for
113      * individual documents that are compiled. It XMLObject is not
114      * part of the list, it will be added automatically.
115      *
116      * @return An array of fully-qualified interface names, or null
117      * if none, other than XMLObject, are to be added.
118      */

119     public String JavaDoc[] getInterfaceNames();
120
121     /**
122      * Convert an implementation-specific DOM node class name to the
123      * external interface or class name that should be used to
124      * reference it. This could be a <CODE>org.w3c.dom</CODE> interface or
125      * other interface or class.
126      *
127      * @see org.enhydra.xml.xmlc#XMLObject
128      */

129     public String JavaDoc nodeClassToInterface(Node JavaDoc node);
130
131     /**
132      * Extract the class names for an element. This is a class for grouping
133      * elements, not the Java class. In HTML, the class is specified with the
134      * <CODE>class</CODE> attribute and with a value of a white-space
135      * separated list of class names. Its not specified for XML, however this
136      * method can be implemented in DTD-specifc XMLDomFactories to enable this
137      * functionality.
138      *
139      * @return An array of class names or null if the node has no classes.
140      * XML returns null.
141      */

142     public String JavaDoc[] getElementClassNames(Element JavaDoc element);
143
144     /**
145      * Determine if an an attribute of an element may contain a URL and should
146      * be subject to URL editing at compile time(or rewriting at run
147      * time. This method is required, as there is not way to define this in a
148      * XML DTD. With HTML, the attributes returned should have values of type
149      * %URL, %URI or %Script.
150      *
151      * @param element The element object the attribute is associated with.
152      * @param attrName The name of the attribute.
153      * @return True if the attribute may contain a URL (although it could
154      * contain JavaScript, etc. False if it can't and shouldn't be edited.
155      */

156     public boolean isURLAttribute(Element JavaDoc element,
157                                   String JavaDoc attrName);
158
159     /**
160      * Create an AccessorGenerator object for this DOM.
161      * Normally, this method is inherited from the DOM that the base
162      * DOM implementation a.
163      */

164     public AccessorGenerator createAccessorGenerator(Document JavaDoc document);
165
166     /**
167      * Create an DocBuilderGenerator object for this DOM.
168      * Normally, this method is inherited from the DOM that the base
169      * DOM implementation a.
170      */

171     public DocBuilderGenerator createDocBuilderGenerator(Document JavaDoc document);
172 }
173
Popular Tags