org.gcube.data.trees.data
Class Nodes

java.lang.Object
  extended by org.gcube.data.trees.data.Nodes

public class Nodes
extends Object

A set of static methods that implement a simple EDSL of tree expressions.

Author:
Fabio Simeoni

Nested Class Summary
static class Nodes.Attribute
          An attribute with a name and a value.
 
Field Summary
static Class<Leaf> L
          Constant for the Leaf node type.
static Class<InnerNode> N
          Constant for the InnerNode type.
 
Constructor Summary
Nodes()
           
 
Method Summary
static Nodes.Attribute a(QName name, Object v)
          Returns an Nodes.Attribute with a given name and a given value.
static Nodes.Attribute a(String name, Object v)
          Returns an Nodes.Attribute with a given name and a given value.
static
<N extends Node>
N
attr(N n, Nodes.Attribute attribute, Nodes.Attribute... attributes)
          Returns a Node annotated with one or more attributes.
static Edge e(Edge e)
          Clones a given Edge.
static Edge e(QName name, Node node)
          Creates an Edge to a Node.
static Edge e(QName name, Object v)
          Creates an Edge to a Leaf.
static Edge e(String name, Node node)
          Creates an Edge to a Node.
static Edge e(String name, Object v)
          Creates an Edge to a Leaf.
static Leaf l(Leaf l)
          Clones a Leaf.
static Leaf l(Object v)
          Returns a Leaf with a given value.
static Leaf l(String id, Object v)
          Returns a Leaf with a given identifier and a given value.
static boolean matches(QName lbl, QName regexp)
          Indicates whether a label matches a regular expression.
static InnerNode n(Edge... es)
          Creates an InnerNode with given Edges.
static InnerNode n(InnerNode n)
          Clones an InnerNode.
static InnerNode n(String id, Edge... es)
          Creates an InnerNode with a given identifier and given Edgee.
static QName q(String name)
          Returns a QName from a local name.
static QName q(String ns, String name)
          Returns a QName from a namespace and a local name.
static QName q(String prefix, String ns, String name)
          Returns a QName from a prefix, a namespace and a local name.
static Tree t(Edge... edges)
          Creates a Tree with given Edges.
static Tree t(String id, Edge... edges)
          Creates a Tree with a given identifier and given Edges.
static Tree t(String collID, String id, Edge... edges)
          Creates a Tree in a given collection with a given identifier and given Edges.
static Tree t(Tree root)
          Clones a Tree.
static Date toDate(String date)
          Transforms a String in the format of the dateTime type of XML Schema into a Date object.
static String toDateString(Date date)
          Transforms a Date object into String representation compliant with the dateTime type of XML Schema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

L

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


N

public static final Class<InnerNode> N
Constant for the InnerNode type.

Constructor Detail

Nodes

public Nodes()
Method Detail

q

public static QName q(String name)
Returns a QName from a local name.

Parameters:
name - the name
Returns:
the QName

q

public static QName q(String ns,
                      String name)
Returns a QName from a namespace and a local name.

Parameters:
ns - the namespace
name - the name
Returns:
the QName

q

public static QName q(String prefix,
                      String ns,
                      String name)
Returns a QName from a prefix, a namespace and a local name.

Parameters:
prefix - the prefix
ns - the namespace
name - the name
Returns:
the QName

t

public static Tree t(Tree root)
Clones a Tree.

Parameters:
root - the Tree
Returns:
the clone

t

public static Tree t(String collID,
                     String id,
                     Edge... edges)
Creates a 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

t

public static Tree t(String id,
                     Edge... edges)
Creates a Tree with a given identifier and given Edges.

Parameters:
id - the identifier
edges - the Edges
Returns:
the Tree

t

public static Tree t(Edge... edges)
Creates a Tree with given Edges.

Parameters:
edges - the Edges
Returns:
the Tree

n

public static InnerNode n(InnerNode n)
Clones an InnerNode.

Parameters:
n - the InnerNode
Returns:
the InnerNode's clone

n

public static InnerNode n(String id,
                          Edge... es)
Creates an InnerNode with a given identifier and given Edgee.

Parameters:
id - the identifier
es - the Edges
Returns:
the InnerNode

n

public static InnerNode n(Edge... es)
Creates an InnerNode with given Edges.

Parameters:
es - Edges
Returns:
the InnerNode

e

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

Parameters:
e - the Edge
Returns:
the clone

e

public static Edge e(QName name,
                     Node node)
Creates an Edge to a Node.

Parameters:
name - the Edge label
node - the Node
Returns:
the Edge

e

public static Edge e(String name,
                     Node node)
Creates an Edge to a Node.

Parameters:
name - the local name of the Edge label
node - the Node
Returns:
the Edge

e

public static Edge e(QName name,
                     Object v)
Creates an Edge to a Leaf.

Parameters:
name - the Edge label
v - the value of the Leaf
Returns:
the Edge

e

public static Edge e(String name,
                     Object v)
Creates an Edge to a Leaf.

Parameters:
name - the local name of the Edge label
v - the value of the Leaf
Returns:
the Edge

l

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

Parameters:
l - the Leaf
Returns:
the clone

l

public static Leaf l(String id,
                     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(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,
                                      Nodes.Attribute attribute,
                                      Nodes.Attribute... attributes)
Returns a Node annotated with one or more attributes.

Type Parameters:
N - the type of the Node
Parameters:
n - the Node
attribute - the first attribute
attributes - the remaining attributes
Returns:
the Node, annotated

a

public static Nodes.Attribute a(String name,
                                Object v)
                         throws IllegalArgumentException
Returns an Nodes.Attribute with a given name and a given value.

Parameters:
name - the local name of the Nodes.Attribute.
v - the value.
Returns:
the Nodes.Attribute.
Throws:
IllegalArgumentException - if the local name is null.

a

public static Nodes.Attribute a(QName name,
                                Object v)
Returns an Nodes.Attribute with a given name and a given value.

Parameters:
name - the Nodes.Attribute name.
v - the value.
Returns:
the Nodes.Attribute.
Throws:
IllegalArgumentException - if the local name is null.

toDateString

public static String toDateString(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 Date toDate(String date)
                   throws 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:
IllegalArgumentException - if the string is not a valid representation of date

matches

public static boolean matches(QName lbl,
                              QName regexp)
Indicates whether a label matches a regular expression.

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


Copyright © 2013. All Rights Reserved.