org.gcube.data.trees.io
Class Bindings

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

public class Bindings
extends Object

Static facilities for binding trees to and from other data types.

Author:
Fabio Simeoni

Field Summary
static String COLLID_ATTR
           
static String DEFAULT_NODE_NAME
           
static String ID_ATTR
           
static QName NODE_QNAME
           
static String PREFIX
           
static String ROOT_NAME
           
static QName ROOT_QNAME
           
static String STATUS_ATTR
           
static String URI
           
 
Constructor Summary
Bindings()
           
 
Method Summary
static Tree fromElement(Element element)
          Binds an Element to a Tree.
static Tree fromReader(Reader reader)
          Binds a Reader to a Tree
static Tree fromStream(InputStream stream)
          Binds an InputStream to a Tree.
static Node nodeFromElement(Element element)
          Binds an Element to a Node.
static Node nodeFromReader(Reader r)
          Binds a Reader to a Node.
static Node nodeFromStream(InputStream in)
          Binds an InputStream to a Node.
static Element nodeToElement(Node node, QName... name)
          Binds a Node to an Element.
static void nodeToWriter(Node node, Writer stream, QName... name)
          Binds a Node to a Writer.
static Element toElement(Tree tree)
          Binds a Tree to an Element.
static String toText(Tree t)
          Binds a Tree to a String.
static void toWriter(Tree t, Writer stream, boolean... writeDeclaration)
          Binds a Tree to a Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_NAME

public static final String ROOT_NAME
See Also:
Constant Field Values

PREFIX

public static final String PREFIX
See Also:
Constant Field Values

URI

public static final String URI
See Also:
Constant Field Values

ROOT_QNAME

public static final QName ROOT_QNAME

DEFAULT_NODE_NAME

public static final String DEFAULT_NODE_NAME
See Also:
Constant Field Values

NODE_QNAME

public static final QName NODE_QNAME

ID_ATTR

public static final String ID_ATTR
See Also:
Constant Field Values

STATUS_ATTR

public static final String STATUS_ATTR
See Also:
Constant Field Values

COLLID_ATTR

public static final String COLLID_ATTR
See Also:
Constant Field Values
Constructor Detail

Bindings

public Bindings()
Method Detail

toText

public static String toText(Tree t)
                     throws Exception
Binds a Tree to a String.

Parameters:
t - the tree
Returns:
the string
Throws:
Exception - if the binding fails

toWriter

public static void toWriter(Tree t,
                            Writer stream,
                            boolean... writeDeclaration)
                     throws Exception
Binds a Tree to a Writer.

Parameters:
t - the tree
stream - the writer
writeDeclaration - (optional) true if the binding is to include the XML declaration (default), false otherwise
Throws:
Exception - if the binding fails

fromReader

public static Tree fromReader(Reader reader)
                       throws Exception
Binds a Reader to a Tree

Parameters:
reader - the reader
Returns:
the tree
Throws:
Exception - if the binding fails

fromStream

public static Tree fromStream(InputStream stream)
                       throws Exception
Binds an InputStream to a Tree.

Parameters:
stream - stream
Returns:
the tree
Throws:
Exception - if the binding fails

nodeFromReader

public static Node nodeFromReader(Reader r)
                           throws Exception
Binds a Reader to a Node.

Parameters:
r - the reader
Returns:
the node
Throws:
Exception - if the binding fails

nodeFromStream

public static Node nodeFromStream(InputStream in)
                           throws Exception
Binds an InputStream to a Node.

Parameters:
in - the InputStream
Returns:
the Node
Throws:
Exception - if the binding fails

toElement

public static Element toElement(Tree tree)
                         throws Exception
Binds a Tree to an Element.

Parameters:
tree - the tree
Returns:
the element
Throws:
Exception - if the binding fails

fromElement

public static Tree fromElement(Element element)
                        throws Exception
Binds an Element to a Tree.

Parameters:
element - the element
Returns:
the tree
Throws:
Exception - if the binding fails

nodeFromElement

public static Node nodeFromElement(Element element)
                            throws Exception
Binds an Element to a Node.

Parameters:
element - the element
Returns:
the node
Throws:
Exception - if the binding fails

nodeToElement

public static Element nodeToElement(Node node,
                                    QName... name)
                             throws Exception
Binds a Node to an Element.

Parameters:
node - the node
name - (optional) a name for the element.
Returns:
the element
Throws:
Exception - if the binding fails

nodeToWriter

public static void nodeToWriter(Node node,
                                Writer stream,
                                QName... name)
                         throws Exception
Binds a Node to a Writer.

Parameters:
node - the node
stream - the writer
name - (optional) an element name for the node
Throws:
Exception - if binding fails


Copyright © 2013. All Rights Reserved.