org.gcube.contentmanagement.contentmanager.stubs.model.trees
Class Bindings

java.lang.Object
  extended by org.gcube.contentmanagement.contentmanager.stubs.model.trees.Bindings

public class Bindings
extends java.lang.Object

A collection static methods for serialising and de-serialising gDoc trees.

Author:
Fabio Simeoni (University of Strathclyde)

Field Summary
static java.lang.String DEFAULT_NODE_NAME
           
static java.lang.String GDOC_COLLID_ATTR
           
static java.lang.String GDOC_ID_ATTR
           
static java.lang.String GDOC_NAME
           
static java.lang.String GDOC_NS
           
static java.lang.String GDOC_PREFIX
           
static java.lang.String GDOC_STATUS_ATTR
           
static java.lang.String GDOC_URI
           
 
Constructor Summary
Bindings()
           
 
Method Summary
static GDoc fromElement(org.w3c.dom.Element e)
          Transforms a DOM tree into a document tree.
static GDoc fromXML(java.io.InputStream in)
          Deserialiases a gDoc element from an XML stream.
static GDoc fromXML(java.io.Reader r)
          Deserialiases a gDoc element from an XML stream.
static Node nodeFromElement(org.w3c.dom.Element e)
          Transforms a DOM tree into a node.
static Node nodeFromXML(java.io.InputStream in)
          Deserialiases a node from an XML stream.
static Node nodeFromXML(java.io.Reader r)
          Deserialiases a node from an XML stream.
static org.w3c.dom.Element nodeToElement(Node node, javax.xml.namespace.QName... name)
          Transforms a document node to a DOM tree.
static void nodeToXML(Node node, java.io.Writer w, javax.xml.namespace.QName... name)
          Serialises a document node to an XML stream.
static org.w3c.dom.Element toElement(GDoc doc)
          Transforms a document tree to a DOM tree.
static void toXML(GDoc doc, java.io.Writer w, boolean... writeDeclaration)
          Serialises a document tree to an XML stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GDOC_NS

public static final java.lang.String GDOC_NS
See Also:
Constant Field Values

GDOC_NAME

public static final java.lang.String GDOC_NAME
See Also:
Constant Field Values

GDOC_PREFIX

public static final java.lang.String GDOC_PREFIX
See Also:
Constant Field Values

GDOC_URI

public static final java.lang.String GDOC_URI
See Also:
Constant Field Values

DEFAULT_NODE_NAME

public static final java.lang.String DEFAULT_NODE_NAME
See Also:
Constant Field Values

GDOC_ID_ATTR

public static final java.lang.String GDOC_ID_ATTR
See Also:
Constant Field Values

GDOC_STATUS_ATTR

public static final java.lang.String GDOC_STATUS_ATTR
See Also:
Constant Field Values

GDOC_COLLID_ATTR

public static final java.lang.String GDOC_COLLID_ATTR
See Also:
Constant Field Values
Constructor Detail

Bindings

public Bindings()
Method Detail

toElement

public static org.w3c.dom.Element toElement(GDoc doc)
                                     throws java.lang.Exception
Transforms a document tree to a DOM tree.

Parameters:
doc - the document.
Returns:
the root element of the DOM tree.
Throws:
java.lang.Exception - if the document could not be transformed.

nodeToElement

public static org.w3c.dom.Element nodeToElement(Node node,
                                                javax.xml.namespace.QName... name)
                                         throws java.lang.Exception
Transforms a document node to a DOM tree.

Parameters:
node - the node.
(optional) - the name for the root of the DOM tree.
Returns:
the root element of the DOM tree.
Throws:
java.lang.Exception - if the document could not be transformed.

fromElement

public static GDoc fromElement(org.w3c.dom.Element e)
                        throws java.lang.Exception
Transforms a DOM tree into a document tree.

Parameters:
e - the root of the DOM tree.
Returns:
the document tree.
Throws:
java.lang.Exception - if the DOM tree could not transformed.

nodeFromElement

public static Node nodeFromElement(org.w3c.dom.Element e)
                            throws java.lang.Exception
Transforms a DOM tree into a node.

Parameters:
e - the root of the DOM tree.
Returns:
the node.
Throws:
java.lang.Exception - if the DOM tree could not transformed.

toXML

public static void toXML(GDoc doc,
                         java.io.Writer w,
                         boolean... writeDeclaration)
                  throws java.lang.Exception
Serialises a document tree to an XML stream.

Parameters:
doc - the document.
w - the stream.
(optional) - writeDeclaration true if the serialisation is to have an XML declaration (default), false otherwise.
Throws:
java.lang.Exception - if the document could not be serialised.

nodeToXML

public static void nodeToXML(Node node,
                             java.io.Writer w,
                             javax.xml.namespace.QName... name)
                      throws java.lang.Exception
Serialises a document node to an XML stream.

Parameters:
node - the node.
w - the stream.
(optional) - name the element name for the node.
Throws:
java.lang.Exception - if the document could not be serialised.

fromXML

public static GDoc fromXML(java.io.Reader r)
                    throws java.lang.Exception
Deserialiases a gDoc element from an XML stream.

Parameters:
r - the stream.
Returns:
the document.
Throws:
java.lang.Exception - if the document could not be serialised.

fromXML

public static GDoc fromXML(java.io.InputStream in)
                    throws java.lang.Exception
Deserialiases a gDoc element from an XML stream.

Parameters:
in - the stream.
Returns:
the document.
Throws:
java.lang.Exception - if the document could not be serialised.

nodeFromXML

public static Node nodeFromXML(java.io.Reader r)
                        throws java.lang.Exception
Deserialiases a node from an XML stream.

Parameters:
r - the stream.
Returns:
the node.
Throws:
java.lang.Exception - if the document could not be serialised.

nodeFromXML

public static Node nodeFromXML(java.io.InputStream in)
                        throws java.lang.Exception
Deserialiases a node from an XML stream.

Parameters:
in - the stream.
Returns:
the node.
Throws:
java.lang.Exception - if the document could not be serialised.