org.apache.axiom.om.impl.dom.factory
Class OMDOMFactory

java.lang.Object
  extended by org.apache.axiom.om.impl.dom.factory.OMDOMFactory
All Implemented Interfaces:
OMFactory
Direct Known Subclasses:
DOMSOAPFactory

public class OMDOMFactory
extends Object
implements OMFactory

OM factory implementation for DOOM. It creates nodes that implement DOM as defined by the interfaces in org.w3c.dom.

Since DOM requires every node to have an owner document even if it has not yet been added to a tree, this factory internally maintains a reference to a DocumentImpl instance. The document can be set explicitly using the OMDOMFactory(DocumentImpl) constructor or the setDocument(DocumentImpl) method. If none is set, it will be implicitly created when the first node is created. All nodes created by this factory will have this DocumentImpl instance as owner document.

This has several important consequences:


Field Summary
protected  DocumentImpl document
           
 
Constructor Summary
OMDOMFactory()
           
OMDOMFactory(DocumentImpl doc)
           
OMDOMFactory(OMDOMMetaFactory metaFactory)
           
 
Method Summary
 OMAttribute createOMAttribute(String localName, OMNamespace ns, String value)
           
 OMComment createOMComment(OMContainer parent, String content)
          Creates a comment.
 OMDocType createOMDocType(OMContainer parent, String content)
          Creates DocType/DTD.
 OMDocument createOMDocument()
          Creates a new OMDocument.
 OMDocument createOMDocument(OMXMLParserWrapper builder)
           
 OMSourcedElement createOMElement(OMDataSource source, QName qname)
          Unsupported.
 OMSourcedElement createOMElement(OMDataSource source, String localName, OMNamespace ns)
          Construct element with arbitrary data source.
 OMElement createOMElement(OMDataSource source, String localName, OMNamespace ns, OMContainer parent)
           
 OMElement createOMElement(QName qname)
          Create an OMElement with the given QName

If the QName contains a prefix, we will ensure that an OMNamespace is created mapping the given namespace to the given prefix.

 OMElement createOMElement(QName qname, OMContainer parent)
          Creates a new OMDOM Element node and adds it to the given parent.
 OMElement createOMElement(String localName, OMNamespace ns)
          Create an element with the given name.
 OMElement createOMElement(String localName, OMNamespace ns, OMContainer parent)
           
 OMElement createOMElement(String localName, OMNamespace ns, OMContainer parent, OMXMLParserWrapper builder)
          Creates an OMElement with the builder.
 OMElement createOMElement(String localName, String namespaceURI, String prefix)
          Create an element with the given name.
 OMNamespace createOMNamespace(String uri, String prefix)
          Creates a new OMNamespace.
 OMProcessingInstruction createOMProcessingInstruction(OMContainer parent, String piTarget, String piData)
          Creates a PI.
 OMText createOMText(Object dataHandler, boolean optimize)
          Creates a new OMDOM Text node with the given datahandler and the given MTOM optimization configuration and returns it.
 OMText createOMText(OMContainer parent, char[] charArary, int type)
           
 OMText createOMText(OMContainer parent, OMText source)
          Create OMText node that is a copy of the source text node
 OMText createOMText(OMContainer parent, QName text)
           
 OMText createOMText(OMContainer parent, QName text, int type)
           
 OMText createOMText(OMContainer parent, String text)
          Creates a new OMText node with the given value and appends it to the given parent element.
 OMText createOMText(OMContainer parent, String text, int type)
           
 OMText createOMText(OMContainer parent, String s, String mimeType, boolean optimize)
          Creates an OMDOM Text node, adds it to the give parent element and returns it.
 OMText createOMText(String s)
          Creates a OMDOM Text node carrying the given value.
 OMText createOMText(String contentID, DataHandlerProvider dataHandlerProvider, boolean optimize)
          Create a binary OMText node supporting deferred loading of the content.
 OMText createOMText(String text, int type)
          Creates a Character node of the given type.
 OMText createOMText(String contentID, OMContainer parent, OMXMLParserWrapper builder)
           
 OMText createOMText(String text, String mimeType, boolean optimize)
          Creates a new OMDOM Text node with the value of the given text value along with the MTOM optimization parameters and returns it.
 DocumentImpl getDocument()
           
 OMMetaFactory getMetaFactory()
          Get the OMMetaFactory from which this factory was obtained.
 void setDocument(DocumentImpl document)
          Configure this factory to use the given document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

document

protected DocumentImpl document
Constructor Detail

OMDOMFactory

public OMDOMFactory(OMDOMMetaFactory metaFactory)

OMDOMFactory

public OMDOMFactory()

OMDOMFactory

public OMDOMFactory(DocumentImpl doc)
Method Detail

getMetaFactory

public OMMetaFactory getMetaFactory()
Description copied from interface: OMFactory
Get the OMMetaFactory from which this factory was obtained.

Specified by:
getMetaFactory in interface OMFactory
Returns:
the meta factory

createOMDocument

public OMDocument createOMDocument()
Description copied from interface: OMFactory
Creates a new OMDocument.

Specified by:
createOMDocument in interface OMFactory

setDocument

public void setDocument(DocumentImpl document)
Configure this factory to use the given document. Use with care.

Parameters:
document -

createOMElement

public OMElement createOMElement(String localName,
                                 OMNamespace ns)
Description copied from interface: OMFactory
Create an element with the given name. If a namespace is given, a namespace declaration will be added automatically to the newly created element.

Specified by:
createOMElement in interface OMFactory
Parameters:
localName - the local part of the name; must not be null
ns - the namespace, or null if the element has no namespace
Returns:
the newly created element

createOMElement

public OMElement createOMElement(String localName,
                                 OMNamespace ns,
                                 OMContainer parent)
                          throws OMDOMException
Specified by:
createOMElement in interface OMFactory
parent - the parent to which the newly created element will be added; this may be null, in which case the behavior of the method is the same as OMFactory.createOMElement(String, OMNamespace)
Returns:
the newly created element
Throws:
OMDOMException

createOMElement

public OMElement createOMElement(String localName,
                                 OMNamespace ns,
                                 OMContainer parent,
                                 OMXMLParserWrapper builder)
Creates an OMElement with the builder.

Specified by:
createOMElement in interface OMFactory
ns - - this can be null

createOMElement

public OMElement createOMElement(OMDataSource source,
                                 String localName,
                                 OMNamespace ns,
                                 OMContainer parent)

createOMElement

public OMSourcedElement createOMElement(OMDataSource source,
                                        String localName,
                                        OMNamespace ns)
Description copied from interface: OMFactory
Construct element with arbitrary data source. This is an optional operation which may not be supported by all factories.

Specified by:
createOMElement in interface OMFactory

createOMElement

public OMSourcedElement createOMElement(OMDataSource source,
                                        QName qname)
Unsupported.

Specified by:
createOMElement in interface OMFactory
Parameters:
source - the data source
qname - the name of the element produced by the data source

createOMElement

public OMElement createOMElement(String localName,
                                 String namespaceURI,
                                 String prefix)
Description copied from interface: OMFactory
Create an element with the given name. If a namespace is given, a namespace declaration will be added automatically to the newly created element.

Specified by:
createOMElement in interface OMFactory
Parameters:
localName - the local part of the name; must not be null
namespaceURI - the namespace URI, or the empty string if the element has no namespace; must not be null
prefix - the namespace prefix, or null if a prefix should be generated
Returns:
the newly created OMElement.

createOMElement

public OMElement createOMElement(QName qname,
                                 OMContainer parent)
                          throws OMException
Creates a new OMDOM Element node and adds it to the given parent.

Specified by:
createOMElement in interface OMFactory
Parameters:
qname - the QName of the element to create
parent - the parent to which the newly created element will be added; this may be null, in which case the behavior of the method is the same as OMFactory.createOMElement(QName)
Returns:
Returns the new OMElement
Throws:
OMException - if there's a namespace mapping problem
See Also:
createOMElement(String, OMNamespace, OMContainer), OMFactory.createOMElement( javax.xml.namespace.QName, org.apache.axiom.om.OMContainer)

createOMElement

public OMElement createOMElement(QName qname)
                          throws OMException
Create an OMElement with the given QName

If the QName contains a prefix, we will ensure that an OMNamespace is created mapping the given namespace to the given prefix. If no prefix is passed, we'll create a generated one.

Specified by:
createOMElement in interface OMFactory
Parameters:
qname -
Returns:
the new OMElement.
Throws:
OMException - TODO: when???

createOMNamespace

public OMNamespace createOMNamespace(String uri,
                                     String prefix)
Creates a new OMNamespace.

Specified by:
createOMNamespace in interface OMFactory
Parameters:
uri - the namespace URI; must not be null
prefix - the prefix
Returns:
the OMNamespace instance
See Also:
OMFactory.createOMNamespace(String, String)

createOMText

public OMText createOMText(OMContainer parent,
                           String text)
Description copied from interface: OMFactory
Creates a new OMText node with the given value and appends it to the given parent element.

Specified by:
createOMText in interface OMFactory
Returns:
Returns OMText.

createOMText

public OMText createOMText(OMContainer parent,
                           QName text)
Specified by:
createOMText in interface OMFactory
text - - This text itself can contain a namespace inside it.

createOMText

public OMText createOMText(OMContainer parent,
                           QName text,
                           int type)
Specified by:
createOMText in interface OMFactory
text - - This text itself can contain a namespace inside it.

createOMText

public OMText createOMText(OMContainer parent,
                           String text,
                           int type)
Specified by:
createOMText in interface OMFactory
type - - this should be either of XMLStreamConstants.CHARACTERS, XMLStreamConstants.CDATA, XMLStreamConstants.SPACE, XMLStreamConstants.ENTITY_REFERENCE
Returns:
Returns OMText.

createOMText

public OMText createOMText(OMContainer parent,
                           OMText source)
Description copied from interface: OMFactory
Create OMText node that is a copy of the source text node

Specified by:
createOMText in interface OMFactory
Returns:
TODO

createOMText

public OMText createOMText(OMContainer parent,
                           char[] charArary,
                           int type)
Specified by:
createOMText in interface OMFactory

createOMText

public OMText createOMText(String s)
Creates a OMDOM Text node carrying the given value.

Specified by:
createOMText in interface OMFactory
Returns:
Returns OMText.
See Also:
OMFactory.createOMText(String)

createOMText

public OMText createOMText(String text,
                           int type)
Creates a Character node of the given type.

Specified by:
createOMText in interface OMFactory
type - - OMText node can handle SPACE, CHARACTERS, CDATA and ENTITY REFERENCES. For Constants, use either XMLStreamConstants or constants found in OMNode.
Returns:
Returns OMText.
See Also:
OMFactory.createOMText(String, int)

createOMText

public OMText createOMText(String text,
                           String mimeType,
                           boolean optimize)
Creates a new OMDOM Text node with the value of the given text value along with the MTOM optimization parameters and returns it.

Specified by:
createOMText in interface OMFactory
See Also:
OMFactory.createOMText(String, String, boolean)

createOMText

public OMText createOMText(Object dataHandler,
                           boolean optimize)
Creates a new OMDOM Text node with the given datahandler and the given MTOM optimization configuration and returns it.

Specified by:
createOMText in interface OMFactory
See Also:
OMFactory.createOMText(Object, boolean)

createOMText

public OMText createOMText(String contentID,
                           DataHandlerProvider dataHandlerProvider,
                           boolean optimize)
Description copied from interface: OMFactory
Create a binary OMText node supporting deferred loading of the content.

Specified by:
createOMText in interface OMFactory
Parameters:
contentID - the content ID identifying the binary content; may be null
dataHandlerProvider - used to load the DataHandler when requested from the returned OMText node
optimize - determines whether the binary content should be optimized
Returns:
TODO

createOMText

public OMText createOMText(OMContainer parent,
                           String s,
                           String mimeType,
                           boolean optimize)
Creates an OMDOM Text node, adds it to the give parent element and returns it.

Specified by:
createOMText in interface OMFactory
See Also:
OMFactory.createOMText(OMContainer, String, String, boolean)

createOMText

public OMText createOMText(String contentID,
                           OMContainer parent,
                           OMXMLParserWrapper builder)
Specified by:
createOMText in interface OMFactory

createOMAttribute

public OMAttribute createOMAttribute(String localName,
                                     OMNamespace ns,
                                     String value)
Specified by:
createOMAttribute in interface OMFactory

createOMDocType

public OMDocType createOMDocType(OMContainer parent,
                                 String content)
Description copied from interface: OMFactory
Creates DocType/DTD.

Specified by:
createOMDocType in interface OMFactory
Returns:
Returns doctype.

createOMProcessingInstruction

public OMProcessingInstruction createOMProcessingInstruction(OMContainer parent,
                                                             String piTarget,
                                                             String piData)
Description copied from interface: OMFactory
Creates a PI.

Specified by:
createOMProcessingInstruction in interface OMFactory
Returns:
Returns OMProcessingInstruction.

createOMComment

public OMComment createOMComment(OMContainer parent,
                                 String content)
Description copied from interface: OMFactory
Creates a comment.

Specified by:
createOMComment in interface OMFactory
Returns:
Returns OMComment.

getDocument

public DocumentImpl getDocument()

createOMDocument

public OMDocument createOMDocument(OMXMLParserWrapper builder)
Specified by:
createOMDocument in interface OMFactory


Copyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.