org.ozoneDB.xml
Class DOMFactory

java.lang.Object
  extended byorg.ozoneDB.xml.DOMFactory
Direct Known Subclasses:
OOXMLDOMFactory

public class DOMFactory
extends java.lang.Object

Factory for XML, HTML and DTD documents, parsers and printers. The factory has methods for creating new documents, parsers and printers. The exact type is determined by the document class, this might be Document (DOCUMENT_XML), HTMLDocument (DOCUMENT_HTML), DocumentType (DOCUMENT_DTD) or a user document derived from XMLDocument.

The default document type is controlled by the openxml.document.class propety in the OpenXML properties file ( openxml.prop). The parser and printer classes for XML, HTML and DTD documents are also controlled by the property file.

The method createDocument(java.lang.Class) does not guarantee that it will return Document, although this is the default behavior. To obtain a Document either pass its class as argument, or call createXMLDocument().

A newly created parser is only guaranteed to extend Parser, even if DOCUMENT_XML has been specified as the document type. To create a document from a user class, either use Source, or the following code:

 Parser    parser;

 parser = DOMFactory.createParser( reader, sourceURI, docClass );
 if ( parser instanceof XMLParser )
     doc = ( (XMLParser) parser ).parseDocument( null, docClass );
 else
     doc = parser.parseDocument();
 

Version:
$Revision: 1.2 $ $Date: 2003/11/17 23:37:10 $
Author:
Assaf Arkin
See Also:
Document, XMLElement, XMLCollection

Field Summary
static java.lang.Class DOCUMENT_DTD
          DTD document class.
static java.lang.Class DOCUMENT_HTML
          HTML document class.
static java.lang.Class DOCUMENT_XML
          XML document class.
 
Constructor Summary
DOMFactory()
           
 
Method Summary
static org.w3c.dom.Document createDocument(java.lang.Class docClass)
          Creates and returns a new XML/HTML/DTD document.
static DTDDocument createDTDDocument()
          Creates and returns a new DTD document.
static org.w3c.dom.html.HTMLDocument createHTMLDocument()
          Creates and returns a new HTML document.
static org.w3c.dom.Document createXMLDocument()
          Creates and returns a new XML document.
static java.lang.Class getDocClass(java.lang.Class docClass)
          Returns the specified document class, or the properties file specified class, or the default.
static java.util.Properties getProperties()
          Returns the properties list from the OpenXML properties file.
static java.lang.String getProperty(java.lang.String name)
          Returns the property from the OpenXML properties file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOCUMENT_XML

public static final java.lang.Class DOCUMENT_XML
XML document class. Can be used to request a new XML document, XML parser or XML printer. Will produce a document of type Document.


DOCUMENT_HTML

public static final java.lang.Class DOCUMENT_HTML
HTML document class. Can be used to request a new HTML document, HTML parser or HTML printer. Will produce a document of type HTMLDocument.


DOCUMENT_DTD

public static final java.lang.Class DOCUMENT_DTD
DTD document class. Can be used to request a new DTD document, DTD parser or DTD printer. Will produce a document of type DTDDocument.

Constructor Detail

DOMFactory

public DOMFactory()
Method Detail

createXMLDocument

public static org.w3c.dom.Document createXMLDocument()
Creates and returns a new XML document. The document type is Document.

Returns:
A new XML document
See Also:
Document

createHTMLDocument

public static org.w3c.dom.html.HTMLDocument createHTMLDocument()
Creates and returns a new HTML document. The document type is HTMLDocument.

Returns:
A new XML document
See Also:
HTMLDocument

createDTDDocument

public static DTDDocument createDTDDocument()
Creates and returns a new DTD document. The document type is DTDDocument.

Returns:
A new DTD document
See Also:
DTDDocument

createDocument

public static org.w3c.dom.Document createDocument(java.lang.Class docClass)
Creates and returns a new XML/HTML/DTD document. The document type is based on docClass, which dictates whether the document is XML, HTML or DTD. If docClass is null, the class type is read from the property openxml.document.class, and if that property is missing, the default Document is used.

Note that the returned document type may or may not be Document, but it must extend Document, and that is also true for non-XML documents.

Returns:
A new XML/HTML/DTD document
See Also:
Document

getProperty

public static java.lang.String getProperty(java.lang.String name)
Returns the property from the OpenXML properties file.

Parameters:
name - The property name
Returns:
Property value or null

getProperties

public static java.util.Properties getProperties()
Returns the properties list from the OpenXML properties file. If this property list is changed, changes will affect the behavior of the factory and other OpenXML elements.

Returns:
The properties list

getDocClass

public static java.lang.Class getDocClass(java.lang.Class docClass)
Returns the specified document class, or the properties file specified class, or the default. If the specified document class is not valid, a runtime exception is thrown. If the specified class is null, the name is read from the properties file and used as the based class. If that property is missing or not a valid class, the default document class (Document) is used.

Parameters:
docClass - The specified document class, or null
Returns:
A valid document class, extending Document


Copyright © 2004 The Ozone Database Project - www.ozone-db.org. All Rights Reserved.