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

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

public class Nodes
extends java.lang.Object

A collection of static methods that compose into a pseudo-literal syntax for creating gDoc trees.

Author:
Fabio Simeoni (University of Strathclyde)

Field Summary
static java.lang.Class<Leaf> L
          Constant for the leaf node type.
static java.lang.Class<InnerNode> N
          Constant for the inner node type.
 
Constructor Summary
Nodes()
           
 
Method Summary
static org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute a(javax.xml.namespace.QName n, java.lang.Object v)
          Builds an attribute with a given name and a given value.
static org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute a(java.lang.String name, java.lang.Object v)
          Builds an attribute with a given name and a given value.
static org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute a(java.lang.String ns, java.lang.String local, java.lang.Object v)
          Builds an attribute with a given name and a given value.
static void addURIs(GDoc doc)
          Marks a document and all its descendants with their content URIs.
static void addURIs(Node n)
          Marks a node and all its descendants with their content URIs.
static
<N extends Node>
N
attr(N n, org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute attribute, org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute... as)
          Returns a given node annotated with one or more attributes
static Edge e(Edge e)
          Clones a given edge.
static Edge e(java.lang.String name, Node node)
          Creates an edge to a node in a document tree.
static Edge e(java.lang.String l, java.lang.Object v)
          Creates an edge to a leaf node in a document tree.
static Edge e(java.lang.String ns, java.lang.String name, Node node)
          Creates an edge to a node in a document tree.
static Edge e(java.lang.String ns, java.lang.String name, java.lang.Object v)
          Creates an edge to a leaf node in a document tree.
static Edge e(java.lang.String prefix, java.lang.String ns, java.lang.String name, Node node)
          Creates an edge to a node in a document tree.
static Edge e(java.lang.String prefix, java.lang.String ns, java.lang.String name, java.lang.Object v)
          Creates an edge to a leaf node in a document tree.
static GDoc gdoc(Edge... edges)
          Creates a document tree with given edges.
static GDoc gdoc(GDoc doc)
          Clones a given document.
static InnerNode gdoc(InnerNode n)
          Clones a given node.
static GDoc gdoc(java.lang.String id, Edge... edges)
          Creates a document tree with a given identifier and given edges.
static GDoc gdoc(java.lang.String collID, java.lang.String id, Edge... edges)
          Creates a document tree in a given collection with a given identifier and given edges.
static Leaf l(Leaf l)
          Clones a given leaf.
static Leaf l(java.lang.Object v)
          Returns a leaf with a given value.
static Leaf l(java.lang.String id, java.lang.Object v)
          Returns a leaf with a given identifier and a given value.
static boolean matches(javax.xml.namespace.QName lbl, javax.xml.namespace.QName regexp)
          Indicates whether a label matches a regular expession.
static InnerNode n(Edge... edges)
          Creates a node in a document tree with given edges.
static InnerNode n(java.lang.String id, Edge... edges)
          Creates a node in a document tree with a given identifier and given edges.
static void removeURIs(InnerNode n)
          Removes content URIs from a node and all its descendants.
static java.util.Date toDate(java.lang.String date)
          Transforms a string in the format of the dateTime type of XML Schema into a Date object.
static java.lang.String toDateString(java.util.Date date)
          Transforms a Date object into string representation compliant with the dateTime type of XML Schema
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

L

public static final java.lang.Class<Leaf> L
Constant for the leaf node type.


N

public static final java.lang.Class<InnerNode> N
Constant for the inner node type.

Constructor Detail

Nodes

public Nodes()
Method Detail

gdoc

public static GDoc gdoc(GDoc doc)
Clones a given document.

Parameters:
doc - the document.
Returns:
the clone.

gdoc

public static GDoc gdoc(java.lang.String collID,
                        java.lang.String id,
                        Edge... edges)
Creates a document tree in a given collection with a given identifier and given edges.

Parameters:
collID - the collection identifier.
id - the identifier.
edges - the edges.
Returns:
the tree.

gdoc

public static GDoc gdoc(java.lang.String id,
                        Edge... edges)
Creates a document tree with a given identifier and given edges.

Parameters:
id - the identifier.
edges - the edges.
Returns:
the tree.

gdoc

public static GDoc gdoc(Edge... edges)
Creates a document tree with given edges.

Parameters:
edges - the edges.
Returns:
the tree.

gdoc

public static InnerNode gdoc(InnerNode n)
Clones a given node.

Parameters:
n - the document.
Returns:
the clone.

n

public static InnerNode n(java.lang.String id,
                          Edge... edges)
Creates a node in a document tree with a given identifier and given edges.

Parameters:
id - the identifier.
edges - the edges.
Returns:
the node.

n

public static InnerNode n(Edge... edges)
Creates a node in a document tree with given edges.

Parameters:
edges - the edges.
Returns:
the node.

e

public static Edge e(Edge e)
Clones a given edge.

Parameters:
e - the edge.
Returns:
the clone.

e

public static Edge e(java.lang.String prefix,
                     java.lang.String ns,
                     java.lang.String name,
                     Node node)
              throws java.lang.IllegalArgumentException
Creates an edge to a node in a document tree.

Parameters:
prefix - the prefix of the edge label.
ns - the namespace of the edge label.
name - the local name of the edge label.
node - the node.
Returns:
the edge.
Throws:
java.lang.IllegalArgumentException - if the prefix or local name are null.

e

public static Edge e(java.lang.String ns,
                     java.lang.String name,
                     Node node)
              throws java.lang.IllegalArgumentException
Creates an edge to a node in a document tree.

Parameters:
ns - the namespace of the edge label.
name - the local name of the edge label.
node - the node.
Returns:
the edge.
Throws:
java.lang.IllegalArgumentException - if the local name is null.

e

public static Edge e(java.lang.String name,
                     Node node)
              throws java.lang.IllegalArgumentException
Creates an edge to a node in a document tree.

Parameters:
name - the local name of the edge label.
node - the node.
Returns:
the edge.
Throws:
java.lang.IllegalArgumentException - if the local name is null.

e

public static Edge e(java.lang.String ns,
                     java.lang.String name,
                     java.lang.Object v)
              throws java.lang.IllegalArgumentException
Creates an edge to a leaf node in a document tree.

Parameters:
ns - the namespace of the edge label.
name - the local name of the edge label.
v - the value of the leaf node.
Returns:
the edge.
Throws:
java.lang.IllegalArgumentException - if the local name is null.

e

public static Edge e(java.lang.String prefix,
                     java.lang.String ns,
                     java.lang.String name,
                     java.lang.Object v)
Creates an edge to a leaf node in a document tree.

Parameters:
prefix - the prefix of the edge label.
ns - the namespace of the edge label.
name - the local name of the edge label.
v - the value of the leaf node.
Returns:
the edge.
Throws:
java.lang.IllegalArgumentException - if the prefix or local name are null.

e

public static Edge e(java.lang.String l,
                     java.lang.Object v)
              throws java.lang.IllegalArgumentException
Creates an edge to a leaf node in a document tree.

Parameters:
name - the local name of the edge label.
v - the value of the leaf node.
Returns:
the edge.
Throws:
java.lang.IllegalArgumentException - if the local name is null.

l

public static Leaf l(Leaf l)
Clones a given leaf.

Parameters:
l - the leaf.
Returns:
the clone.

l

public static Leaf l(java.lang.String id,
                     java.lang.Object v)
Returns a leaf with a given identifier and a given value.

Parameters:
id - the identifier.
v - the value.
Returns:
the leaf.

l

public static Leaf l(java.lang.Object v)
Returns a leaf with a given value.

Parameters:
v - the value.
Returns:
the leaf.

attr

public static <N extends Node> N attr(N n,
                                      org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute attribute,
                                      org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute... as)
Returns a given node annotated with one or more attributes

Type Parameters:
NEW - the type of the node.
Parameters:
n - the node.
attribute - the first attribute.
attributes - the remaining attributes.
Returns:
the input node, annotated.

a

public static org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute a(java.lang.String name,
                                                                                             java.lang.Object v)
                                                                                      throws java.lang.IllegalArgumentException
Builds an attribute with a given name and a given value.

Parameters:
name - the local name of the attribute.
v - the value.
Returns:
the attribute.
Throws:
java.lang.IllegalArgumentException - if the local name is null.

a

public static org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute a(java.lang.String ns,
                                                                                             java.lang.String local,
                                                                                             java.lang.Object v)
                                                                                      throws java.lang.IllegalArgumentException
Builds an attribute with a given name and a given value.

Parameters:
ns - the namespace of the attribute.
name - the local name of the attribute.
v - the value.
Returns:
the attribute.
Throws:
java.lang.IllegalArgumentException - if the local name is null.

a

public static org.gcube.contentmanagement.contentmanager.stubs.model.trees.Nodes.Attribute a(javax.xml.namespace.QName n,
                                                                                             java.lang.Object v)
Builds an attribute with a given name and a given value.

Parameters:
n - the name.
v - the value.
Returns:
the attribute.

addURIs

public static void addURIs(GDoc doc)
                    throws java.lang.IllegalArgumentException
Marks a document and all its descendants with their content URIs.

Parameters:
n - the node.
Throws:
java.lang.IllegalArgumentException - if the document does not belong to a collection.

addURIs

public static void addURIs(Node n)
Marks a node and all its descendants with their content URIs.

Parameters:
n - the node.

removeURIs

public static void removeURIs(InnerNode n)
Removes content URIs from a node and all its descendants.

Parameters:
n - the node.

toDateString

public static java.lang.String toDateString(java.util.Date date)
Transforms a Date object into string representation compliant with the dateTime type of XML Schema

Parameters:
date - the date.
Returns:
the string.

toDate

public static java.util.Date toDate(java.lang.String date)
                             throws java.lang.IllegalArgumentException
Transforms a string in the format of the dateTime type of XML Schema into a Date object.

Parameters:
date - the string.
Returns:
the date.
Throws:
java.lang.IllegalArgumentException - if the string is not a valid representation of date.

matches

public static boolean matches(javax.xml.namespace.QName lbl,
                              javax.xml.namespace.QName regexp)
Indicates whether a label matches a regular expession.

Parameters:
lbl - the label.
regexp - the expression
Returns:
true if it does, false otherwise.