org.gcube.data.trees.io
Class XMLBindings

java.lang.Object
  extended by org.gcube.data.trees.io.XMLBindings

public class XMLBindings
extends Object

Static facilities for converting Trees to and from XML representations.

Author:
Fabio Simeoni

Field Summary
static QName ID
           
static QName SOURCE
           
static QName STATE
           
 
Constructor Summary
XMLBindings()
           
 
Method Summary
static String _fromElement(Element element)
           
static Tree fromElement(Element element)
          Parses a Tree from its XML representation.
static Tree fromStream(InputStream stream)
          Parses a Tree from its XML representation.
static Tree fromStream(Reader stream)
          Parses a Tree from its XML representation.
static Tree fromString(String xml)
          Parses a Tree from its XML representation.
static Node nodeFromElement(Element element)
          Parses a Node from its XML representation.
static Node nodeFromStream(InputStream stream)
          Parses a Node from its XML representation.
static Node nodeFromStream(Reader stream)
          Parses a Node from its XML representation.
static Node nodeFromString(String xml)
          Parses a Node from its XML representation.
static Element nodeToElement(Node node)
          Converts a Node to its XML representation.
static Element nodeToElement(Node node, WriteOptions options)
          Converts a Node to its XML representation.
static void nodetoStream(Node node, OutputStream stream)
          Converts a Node to its XML representation.
static void nodeToStream(Node node, OutputStream stream, WriteOptions options)
          Converts a Node to its XML representation.
static void nodeToStream(Node node, Writer stream)
          Converts a Node to its XML representation.
static void nodeToStream(Node node, Writer stream, WriteOptions options)
          Converts a Node to its XML representation.
static String nodeToString(Node node)
          Converts a Node to its XML representation.
static String nodeToString(Node node, WriteOptions options)
          Converts a Node to its XML representation.
static Element toElement(Tree tree)
          Converts a Tree to its XML representation.
static Element toElement(Tree tree, WriteOptions options)
          Converts a Tree to its XML representation.
static void toStream(Tree tree, OutputStream stream)
          Converts a Tree to its XML representation.
static void toStream(Tree tree, OutputStream stream, WriteOptions options)
          Converts a Tree to its XML representation.
static void toStream(Tree tree, Writer stream)
          Converts a Tree to its XML representation.
static void toStream(Tree tree, Writer stream, WriteOptions options)
          Converts a Tree to its XML representation.
static String toString(Tree tree)
          Converts a Tree to its XML representation.
static String toString(Tree tree, WriteOptions options)
          Converts a Tree to its XML representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final QName ID

STATE

public static final QName STATE

SOURCE

public static final QName SOURCE
Constructor Detail

XMLBindings

public XMLBindings()
Method Detail

toString

public static String toString(Tree tree)
Converts a Tree to its XML representation.

Parameters:
tree - the tree
Returns:
the XML representation of the tree
Throws:
RuntimeException - if the conversion fails

nodeToString

public static String nodeToString(Node node)
Converts a Node to its XML representation.

Parameters:
node - the node
Returns:
the XML representation of the node
Throws:
RuntimeException - if the conversion fails

toString

public static String toString(Tree tree,
                              WriteOptions options)
Converts a Tree to its XML representation.

Parameters:
tree - the tree
custom - options for the conversion
Returns:
the XML representation of the tree
Throws:
RuntimeException - if the conversion fails

nodeToString

public static String nodeToString(Node node,
                                  WriteOptions options)
Converts a Node to its XML representation.

Parameters:
node - the node
custom - options for the conversion
Returns:
the XML representation of the node
Throws:
RuntimeException - if the conversion fails

fromString

public static Tree fromString(String xml)
Parses a Tree from its XML representation.

Parameters:
xml - the XML representation
Returns:
the tree parsed from the representation
Throws:
RuntimeException - if the representation cannot be parsed

nodeFromString

public static Node nodeFromString(String xml)
Parses a Node from its XML representation.

Parameters:
xml - the XML representation
Returns:
the node parsed from the representation
Throws:
RuntimeException - if the representation cannot be parsed

toStream

public static void toStream(Tree tree,
                            Writer stream)
Converts a Tree to its XML representation.

Parameters:
tree - the tree
stream - a stream where to write out the tree representation
Throws:
RuntimeException - if the conversion fails

nodeToStream

public static void nodeToStream(Node node,
                                Writer stream)
Converts a Node to its XML representation.

Parameters:
node - the node
stream - a stream where to write out the node representation
Throws:
RuntimeException - if the conversion fails

toStream

public static void toStream(Tree tree,
                            Writer stream,
                            WriteOptions options)
Converts a Tree to its XML representation.

Parameters:
tree - the tree
stream - a stream where to write out the tree representation
custom - options for the conversion
Throws:
RuntimeException - if the conversion fails

nodeToStream

public static void nodeToStream(Node node,
                                Writer stream,
                                WriteOptions options)
Converts a Node to its XML representation.

Parameters:
node - the node
stream - a stream where to write out the node representation
custom - options for the conversion
Throws:
RuntimeException - if the conversion fails

fromStream

public static Tree fromStream(Reader stream)
Parses a Tree from its XML representation.

Parameters:
stream - a stream with the XML representation of the tree
Returns:
the tree parsed from the representation
Throws:
RuntimeException - if the representation cannot be parsed

nodeFromStream

public static Node nodeFromStream(Reader stream)
Parses a Node from its XML representation.

Parameters:
stream - a stream with the XML representation of the node
Returns:
the node parsed from the representation
Throws:
RuntimeException - if the representation cannot be parsed

toStream

public static void toStream(Tree tree,
                            OutputStream stream)
Converts a Tree to its XML representation.

Parameters:
tree - the tree
stream - a stream where to write out the tree representation
Throws:
RuntimeException - if the conversion fails

nodetoStream

public static void nodetoStream(Node node,
                                OutputStream stream)
Converts a Node to its XML representation.

Parameters:
node - the node
stream - a stream where to write out the node representation
Throws:
RuntimeException - if the conversion fails

toStream

public static void toStream(Tree tree,
                            OutputStream stream,
                            WriteOptions options)
Converts a Tree to its XML representation.

Parameters:
tree - the tree
stream - a stream where to write out the tree representation
custom - options for the conversion
Throws:
RuntimeException - if the conversion fails

nodeToStream

public static void nodeToStream(Node node,
                                OutputStream stream,
                                WriteOptions options)
Converts a Node to its XML representation.

Parameters:
node - the node
stream - a stream where to write out the node representation
custom - options for the conversion
Throws:
RuntimeException - if the conversion fails

fromStream

public static Tree fromStream(InputStream stream)
Parses a Tree from its XML representation.

Parameters:
stream - a stream with the XML representation of the tree
Returns:
the tree parsed from the representation
Throws:
RuntimeException - if the representation cannot be parsed

nodeFromStream

public static Node nodeFromStream(InputStream stream)
Parses a Node from its XML representation.

Parameters:
stream - a stream with the XML representation of the node
Returns:
the node parsed from the representation
Throws:
RuntimeException - if the representation cannot be parsed

toElement

public static Element toElement(Tree tree)
Converts a Tree to its XML representation.

Note that this is a derived thus unoptimised conversion, the tree is first converted to an in-memory string-based

Parameters:
tree - the tree
Returns:
the root Element of a DOM model of the XML representation
Throws:
RuntimeException - if the conversion fails

toElement

public static Element toElement(Tree tree,
                                WriteOptions options)
Converts a Tree to its XML representation. *

Note that this is a derived thus unoptimised conversion, the tree is first converted to an in-memory string-based

Parameters:
tree - the tree
custom - options for the conversion
Returns:
the root Element of a DOM model of the XML representation
Throws:
RuntimeException - if the conversion fails

nodeToElement

public static Element nodeToElement(Node node,
                                    WriteOptions options)
Converts a Node to its XML representation.

Note that this is a derived thus unoptimised conversion, the node is first converted to an in-memory string-based

Parameters:
node - the node
custom - options for the conversion
Returns:
the root Element of a DOM model of the XML representation
Throws:
RuntimeException - if the conversion fails

nodeToElement

public static Element nodeToElement(Node node)
Converts a Node to its XML representation.

Note that this is a derived thus unoptimised conversion, the node is first converted to an in-memory string-based

Parameters:
node - the node
Returns:
the root Element of a DOM model of the XML representation
Throws:
RuntimeException - if the conversion fails

fromElement

public static Tree fromElement(Element element)
Parses a Tree from its XML representation.

Note that this is a derived thus unoptimised conversion, the representation is first converted to a string.

Parameters:
element - the root Element of a DOM model of the XML representation
Returns:
the tree parsed from the representation
Throws:
RuntimeException - if the representation cannot be parsed

nodeFromElement

public static Node nodeFromElement(Element element)
Parses a Node from its XML representation.

Note that this is a derived thus unoptimised conversion, the representation is first converted to a string.

Parameters:
element - the root Element of a DOM model of the XML representation
Returns:
the node parsed from the representation
Throws:
RuntimeException - if the representation cannot be parsed

_fromElement

public static String _fromElement(Element element)


Copyright © 2013. All Rights Reserved.