org.pf.six
Class ModelConverter

java.lang.Object
  extended by org.pf.six.ModelConverter

public class ModelConverter
extends java.lang.Object

Supports conversion of a XML representation in org.pf.six.Element to a DOM tree and vice versa as well as pretty printing of both kinds of XML representations to Strings.

Version:
2.0
Author:
Manfred Duchrow

Constructor Summary
ModelConverter()
          Initialize the new instance with default values.
 
Method Summary
 org.w3c.dom.Document toDOM(Element rootElement)
          Converts the given SIX element and its children to a DOM Document tree.
 java.lang.String toFormattedString(Element element)
          Returns the element and its attributes and children as string with new lines and indentation (2 chars).
 java.lang.String toFormattedString(org.w3c.dom.Element element)
          Returns the element and its attributes and children as string with new lines and indentation (2 chars).
 java.lang.String toFormattedString(Element element, int indent)
          Returns the element and its attributes and children as string with new lines and indentation.
 java.lang.String toFormattedString(org.w3c.dom.Element element, int indent)
          Returns the element and its attributes and children as string with new lines and indentation.
 java.lang.String toFormattedString(Element element, int indent, boolean useSingleQuotes)
          Returns the element and its attributes and children as string with new lines and indentation.
 java.lang.String toFormattedString(org.w3c.dom.Element element, int indent, boolean useSingleQuotes)
          Returns the element and its attributes and children as string with new lines and indentation.
 Element toSIXElement(org.w3c.dom.Document doc)
          Converts the given DOM Document tree to a SIX element tree.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelConverter

public ModelConverter()
Initialize the new instance with default values.

Method Detail

toDOM

public org.w3c.dom.Document toDOM(Element rootElement)
Converts the given SIX element and its children to a DOM Document tree. The element needs not necessarily be a root element (document type).

Parameters:
rootElement - The root element for the document to create
Returns:
The document or null in any case of exception

toSIXElement

public Element toSIXElement(org.w3c.dom.Document doc)
Converts the given DOM Document tree to a SIX element tree.

Parameters:
doc - The document to be converted to the SIX structure
Returns:
The root element or null in any case of exception

toFormattedString

public java.lang.String toFormattedString(Element element)
Returns the element and its attributes and children as string with new lines and indentation (2 chars).

Parameters:
element - An XML element, which is not necessarily the root of an XML document

toFormattedString

public java.lang.String toFormattedString(Element element,
                                          int indent)
Returns the element and its attributes and children as string with new lines and indentation.

Parameters:
element - An XML element, which is not necessarily the root of an XML document
indent - Specifies how much characters to indent after a new line

toFormattedString

public java.lang.String toFormattedString(Element element,
                                          int indent,
                                          boolean useSingleQuotes)
Returns the element and its attributes and children as string with new lines and indentation.

Parameters:
element - An XML element, which is not necessarily the root of an XML document
indent - Specifies how much characters to indent after a new line
useSingleQuotes - If true attribute values will be enclosed in quotes ('), otherwise in apostrophes (")

toFormattedString

public java.lang.String toFormattedString(org.w3c.dom.Element element)
Returns the element and its attributes and children as string with new lines and indentation (2 chars).

Parameters:
element - A DOM element, which is not necessarily the root of an XML document

toFormattedString

public java.lang.String toFormattedString(org.w3c.dom.Element element,
                                          int indent)
Returns the element and its attributes and children as string with new lines and indentation.

Parameters:
element - A DOM element, which is not necessarily the root of an XML document
indent - Specifies how much characters to indent after a new line

toFormattedString

public java.lang.String toFormattedString(org.w3c.dom.Element element,
                                          int indent,
                                          boolean useSingleQuotes)
Returns the element and its attributes and children as string with new lines and indentation.

Parameters:
element - A DOM element, which is not necessarily the root of an XML document
indent - Specifies how much characters to indent after a new line
useSingleQuotes - If true attribute values will be enclosed in quotes ('), otherwise in apostrophes (")