org.purl.xnode
Interface XNodeFactory

All Known Subinterfaces:
XNodeCollectionFactory
All Known Implementing Classes:
XNodeCollectionFactoryImpl, XNodeFactoryImpl

public interface XNodeFactory

Provides an API of a factory for creating XNode objects.

The XNode API (the package org.purl.xnode.*, both its source code and documentation), are released under the Apache 2.0 License. For more details, check the LICENSE file contained with the distribution, or see The Ceryle Project for more information. It is distributed with no warranty.

Since:
XNode 1.0
Version:
$Id: XNodeFactory.java,v 3.7 2007-06-15 12:10:37 altheim Exp $
Author:
Murray Altheim

Method Summary
 XNode createXNode(String id)
          Return a new, empty XNode provided a String id.
 XNode createXNode(String id, Node node)
          Return an XNode provided a String id and a DOM Node node.
 Node getXNodeContent(XNode xnode, boolean includeEnvelope)
          Provided with an XNode xnode, returns a DOM Document representation.
 XNode recreateXNode(Node node)
          Return an XNode provided a DOM Node node, assuming the provided Node's content is a serialization of an XNode.
 String serializeXNode(XNode xnode, boolean includeEnvelope)
          Provided with an XNode xnode, returns an XML serialization as a String.
 boolean serializeXNode(XNode xnode, Writer writer, boolean includeEnvelope)
          Writes an XML serialization of the XNode xnode to the supplied Writer writer.
 

Method Detail

createXNode

XNode createXNode(String id)
                  throws XNodeException
Return a new, empty XNode provided a String id.

Parameters:
id - the XNode unique identifier.
Returns:
an XNode whose ID is 'id'.
Throws:
XNodeException - if an error occurs during creation.

createXNode

XNode createXNode(String id,
                  Node node)
                  throws XNodeException
Return an XNode provided a String id and a DOM Node node. If node is null, this method will act exactly as createXNode(String), i.e., provide an empty XNode.

Parameters:
id - the XNode ID.
node - the DOM Node to be enclosed in the XNode.
Returns:
the created XNode.
Throws:
XNodeException - if an error occurs during creation.

recreateXNode

XNode recreateXNode(Node node)
                    throws XNodeException
Return an XNode provided a DOM Node node, assuming the provided Node's content is a serialization of an XNode.

Parameters:
node - the DOM Node to be processed as XNode content.
Returns:
the re-created XNode.
Throws:
XNodeException - if an error occurs during re-creation.

getXNodeContent

Node getXNodeContent(XNode xnode,
                     boolean includeEnvelope)
                     throws XNodeException
Provided with an XNode xnode, returns a DOM Document representation. If includeEnvelope is true, the <xnode:Envelope> will be included.

Parameters:
xnode - the XNode to be processed.
includeEnvelope - if true, include the xnode:Envelope.
Returns:
a DOM Document representation of the XNode.
Throws:
XNodeException - if an error occurs during processing.

serializeXNode

boolean serializeXNode(XNode xnode,
                       Writer writer,
                       boolean includeEnvelope)
                       throws XNodeException
Writes an XML serialization of the XNode xnode to the supplied Writer writer. If includeEnvelope is true, the <xnode:Envelope> will be included.

Parameters:
xnode - the XNode to be serialized.
writer - the Writer receiving the output.
includeEnvelope - if true, include the xnode:Envelope.
Returns:
true if successful
Throws:
XNodeException - if an error occurs during serialization.

serializeXNode

String serializeXNode(XNode xnode,
                      boolean includeEnvelope)
                      throws XNodeException
Provided with an XNode xnode, returns an XML serialization as a String. If includeEnvelope is true, the <xnode:Envelope> will be included.

Parameters:
xnode - the XNode to be serialized.
includeEnvelope - if true, include the xnode:Envelope.
Returns:
the String representation of the XNode.
Throws:
XNodeException - if an error occurs during serialization.


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.