org.sourceforge.ifx.utils
Class IFXDocumentHandler

java.lang.Object
  extended byorg.sourceforge.ifx.utils.IFXDocumentHandler

public class IFXDocumentHandler
extends java.lang.Object

The IFXDocumentHandler provides methods for formatting and validating IFX XML Documents.

Version:
$Revision: 1.2 $
Author:
Sujit Pal (spal@users.sourceforge.net)

Field Summary
static java.lang.String DEFAULT_LINE_SEPARATOR
          System default Line separator string.
 
Constructor Summary
IFXDocumentHandler()
           
 
Method Summary
static org.jdom.Document build(IFXObject obj, java.lang.String namespacePrefix, java.lang.String namespaceURI)
          Builds a JDOM Document object from an IFXObject.
static IFXObject parse(org.jdom.Document doc)
          Parses a Document object into an IFXObject.
static org.jdom.Document read(java.io.InputStream istream, boolean validate, java.util.Map validationProperties)
          Reads an XML stream from the specified InputStream and returns a JDOM Document object.
static void write(org.jdom.Document doc, int indentSize, java.lang.String lineSeparator, java.io.OutputStream ostream)
          Writes a Document object to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LINE_SEPARATOR

public static final java.lang.String DEFAULT_LINE_SEPARATOR
System default Line separator string.

Constructor Detail

IFXDocumentHandler

public IFXDocumentHandler()
Method Detail

build

public static org.jdom.Document build(IFXObject obj,
                                      java.lang.String namespacePrefix,
                                      java.lang.String namespaceURI)
                               throws IFXException
Builds a JDOM Document object from an IFXObject.

Parameters:
obj - the IFXObject object to format.
namespacePrefix - the namespace prefix to use in the output. A value of null implies no prefix. If the namespaceURI is specified it will be treated as the default namespace.
namespaceURI - the namespace URI to use in the output. If specified an xmlns declaration will be prepended to the output.
Returns:
a JDOM Document object.
Throws:
IFXException - if there was a problem building the document.

write

public static void write(org.jdom.Document doc,
                         int indentSize,
                         java.lang.String lineSeparator,
                         java.io.OutputStream ostream)
                  throws IFXException
Writes a Document object to the specified output stream.

Parameters:
doc - a JDOM Document object.
indentSize - the size of the indent in the output. A value of zero implies no indentation.
lineSeparator - the line separator for the output. A value of null implies no line separators and no newlines in the output. To use the system default, use DEFAULT_LINE_SEPARATOR.
ostream - the OutputStream to write the formatted output to.
Throws:
IFXException - if there was a problem writing the Document.

parse

public static IFXObject parse(org.jdom.Document doc)
                       throws IFXException
Parses a Document object into an IFXObject. This is a thin wrapper over the IFXDecoder.decode() method.

Parameters:
doc - the JDOM Document object to parse.
Throws:
IFXException - if any problems were encountered in parsing.

read

public static org.jdom.Document read(java.io.InputStream istream,
                                     boolean validate,
                                     java.util.Map validationProperties)
                              throws IFXException
Reads an XML stream from the specified InputStream and returns a JDOM Document object. If validation is requested, then the XML is validated while reading it into a Document.

Parameters:
istream - the InputStream to read from.
validate - XML is validated against schema if true.
validationProperties - a Map of name value pairs specifying the schema and the namespaces to validate against.
Throws:
IFXExveption - if there was a problem reading the document.
IFXException