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

java.lang.Object
  extended by org.gcube.contentmanagement.contentmanager.stubs.model.trees.Node
      extended by org.gcube.contentmanagement.contentmanager.stubs.model.trees.InnerNode
Direct Known Subclasses:
GDoc

public class InnerNode
extends Node

A (thread-safe) Node with an identity and outgoing edges.

Author:
Fabio Simeoni (University of Strathclyde)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gcube.contentmanagement.contentmanager.stubs.model.trees.Node
Node.State
 
Constructor Summary
InnerNode()
          Creates an instance.
InnerNode(Edge... edges)
          Constructs an instance with a given edges.
InnerNode(InnerNode n)
          Copy constructor, creates a clone of a given node.
InnerNode(java.lang.String id)
          Constructs an instance with a given identifier.
InnerNode(java.lang.String id, Edge... edges)
          Constructs an instance with a given identifier and edges.
InnerNode(java.lang.String id, java.util.Map<javax.xml.namespace.QName,java.lang.String> attributes, Edge... edges)
          Constructs an instance with a given identifier, attributes, and edges.
InnerNode(java.lang.String id, Node.State state, java.util.Map<javax.xml.namespace.QName,java.lang.String> attributes, Edge... edges)
          Constructs an instance with a given identifier, state, attributes, and edges.
 
Method Summary
 boolean add(Edge... es)
          Adds one or more edges.
 boolean add(java.util.List<Edge> es)
          Adds one or more edges.
<T extends Node>
T
child(java.lang.Class<T> type, javax.xml.namespace.QName label)
          Returns a child of this node with a given label and of a given node type, if exactly one exists.
<T extends Node>
T
child(java.lang.Class<T> type, java.lang.String name)
          Returns a child of this node with a given label and of a given node type, if exactly one exists.
<T extends Node>
T
child(java.lang.Class<T> type, java.lang.String ns, java.lang.String name)
          Returns a child of this node with a given label and of a given type, if exactly one exists.
 Node child(javax.xml.namespace.QName label)
          Returns a child of this node with a given label, if exactly one exists.
 Node child(java.lang.String name)
          Returns a child of this node with a given label, if exactly one exists.
 Node child(java.lang.String ns, java.lang.String name)
          Returns a child of this node with a given label, if exactly one exists.
 java.util.List<Node> children()
          Returns all the children of this node.
<T extends Node>
java.util.List<T>
children(java.lang.Class<T> type)
          Returns all the children of this node of a given node type.
<T extends Node>
java.util.List<T>
children(java.lang.Class<T> type, javax.xml.namespace.QName label)
          Returns all the children of this node with a given label and a given node type.
<T extends Node>
java.util.List<T>
children(java.lang.Class<T> type, java.lang.String name)
          Returns all the children of this node with a given label and a given node type.
<T extends Node>
java.util.List<T>
children(java.lang.Class<T> type, java.lang.String ns, java.lang.String name)
          Returns all the children of this node with a given label and given node type.
 java.util.List<Node> children(javax.xml.namespace.QName label)
          Returns all the children of this node with a given label.
 java.util.List<Node> children(java.lang.String name)
          Returns all the children of this node with a given label.
 java.util.List<Node> children(java.lang.String ns, java.lang.String name)
          Returns all the children of this node with a given label.
 InnerNode delta(Node f)
          Returns a node that reflects the delta between this document and a given input node.
<T extends Node>
T
descendant(java.lang.Class<T> type, java.lang.String... descendantIDs)
          Returns the descendant of this node of a given tree type which can be reached by following a given sequence of node identifiers.
 Node descendant(java.lang.String... descendantIDs)
          Returns the descendant of this node that can be reached by following a given sequence of node identifiers.
<T extends Node>
java.util.List<T>
descendants(java.lang.Class<T> type, javax.xml.namespace.QName... labels)
          Returns all the descendants of a given node type which can be reached by following a given sequence of labels.
<T extends Node>
java.util.List<T>
descendants(java.lang.Class<T> type, java.lang.String... labels)
          Returns all the descendants of a given node type that can be reached by following a given sequence of labels.
 java.util.List<Node> descendants(javax.xml.namespace.QName... labels)
          Returns all the descendants that can be reached by following a given sequence of labels.
 java.util.List<Node> descendants(java.lang.String... labels)
          Returns all the descendants that can be reached by following a given sequence of labels.
 Edge edge(javax.xml.namespace.QName l)
          Returns the edges with a given label, if exactly one exists.
 Edge edge(java.lang.String l)
          Returns the edges with a given label, if exactly one exists.
 Edge edge(java.lang.String ns, java.lang.String l)
          Returns the edges with a given label, if exactly one exists.
 java.util.List<Edge> edges()
          Returns all the edges.
 java.util.List<Edge> edges(javax.xml.namespace.QName l)
          Returns the outgoing edges with a given label.
 java.util.List<Edge> edges(java.lang.String l)
          Returns the outgoing edges with a given label.
 java.util.List<Edge> edges(java.lang.String ns, java.lang.String l)
          Returns the outgoing edges with a given label.
 boolean equals(java.lang.Object obj)
          
 boolean hasEdge(javax.xml.namespace.QName l)
          Indicates whether the node has at least an edge with a given label.
 boolean hasEdge(java.lang.String l)
          Indicates whether the node has at least an edge with a given label.
 boolean hasEdge(java.lang.String ns, java.lang.String l)
          Indicates whether the node has at least an edge with a given label.
 int hashCode()
          
 java.util.List<javax.xml.namespace.QName> labels()
          Returns the labels of all the outgoing edges.
 java.util.List<javax.xml.namespace.QName> labels(javax.xml.namespace.QName l)
          Returns all the labels that match a given one.
static void main(java.lang.String[] args)
           
 boolean remove(Edge... es)
          Removes one or more edges.
 boolean remove(java.util.List<Edge> es)
          Removes one or more edges.
 java.util.List<Node> remove(java.lang.String... childIDs)
          Removes one or more children.
 Node remove(java.lang.String childID)
          Removes a child.
 java.lang.String toString()
          
 
Methods inherited from class org.gcube.contentmanagement.contentmanager.stubs.model.trees.Node
ancestors, ancestorsAndSelf, attribute, attribute, attribute, attributes, hasAttribute, hasAttribute, hasAttribute, id, parent, removeAttribute, removeAttribute, removeAttribute, setAttribute, setAttribute, setAttribute, state, uri
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InnerNode

public InnerNode(InnerNode n)
Copy constructor, creates a clone of a given node.

Parameters:
n - the node.

InnerNode

public InnerNode()
Creates an instance.


InnerNode

public InnerNode(java.lang.String id)
Constructs an instance with a given identifier.

Parameters:
id - the identifier.

InnerNode

public InnerNode(java.lang.String id,
                 Edge... edges)
Constructs an instance with a given identifier and edges.

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

InnerNode

public InnerNode(Edge... edges)
Constructs an instance with a given edges.

Parameters:
edges - the edges.

InnerNode

public InnerNode(java.lang.String id,
                 java.util.Map<javax.xml.namespace.QName,java.lang.String> attributes,
                 Edge... edges)
Constructs an instance with a given identifier, attributes, and edges.

Parameters:
id - the identifier.
attributes - the attributes.
edges - the edges.

InnerNode

public InnerNode(java.lang.String id,
                 Node.State state,
                 java.util.Map<javax.xml.namespace.QName,java.lang.String> attributes,
                 Edge... edges)
Constructs an instance with a given identifier, state, attributes, and edges.

Parameters:
id - the identifier.
state -
attributes - the attributes.
edges - the edges.
Method Detail

children

public java.util.List<Node> children()
Returns all the children of this node.

Returns:
the children.

children

public <T extends Node> java.util.List<T> children(java.lang.Class<T> type)
Returns all the children of this node of a given node type.

Parameters:
the - node type.
Returns:
the children.

children

public java.util.List<Node> children(javax.xml.namespace.QName label)
Returns all the children of this node with a given label.

Returns:
the children.

children

public <T extends Node> java.util.List<T> children(java.lang.Class<T> type,
                                                   javax.xml.namespace.QName label)
Returns all the children of this node with a given label and a given node type.

Parameters:
the - node type.
Returns:
the children.

children

public java.util.List<Node> children(java.lang.String name)
                              throws java.lang.IllegalArgumentException
Returns all the children of this node with a given label.

Parameters:
name - the label's local name.
Returns:
the children.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.

children

public <T extends Node> java.util.List<T> children(java.lang.Class<T> type,
                                                   java.lang.String name)
                                        throws java.lang.IllegalArgumentException
Returns all the children of this node with a given label and a given node type.

Parameters:
the - node type.
name - the label's local name.
Returns:
the children.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.

children

public java.util.List<Node> children(java.lang.String ns,
                                     java.lang.String name)
                              throws java.lang.IllegalArgumentException
Returns all the children of this node with a given label.

Parameters:
ns - the label's namespace.
name - the label's local name.
Returns:
the children.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.

children

public <T extends Node> java.util.List<T> children(java.lang.Class<T> type,
                                                   java.lang.String ns,
                                                   java.lang.String name)
                                        throws java.lang.IllegalArgumentException
Returns all the children of this node with a given label and given node type.

Parameters:
the - node type.
ns - the label's namespace.
name - the label's local name.
Returns:
the children.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.

descendant

public Node descendant(java.lang.String... descendantIDs)
                throws java.lang.IllegalArgumentException,
                       java.lang.IllegalStateException
Returns the descendant of this node that can be reached by following a given sequence of node identifiers.

Parameters:
descendantIDs - the identifiers.
Returns:
the descendant.
Throws:
java.lang.IllegalStateException - if the sequence does not lead to a descendant of this node.
java.lang.IllegalArgumentException

descendant

public <T extends Node> T descendant(java.lang.Class<T> type,
                                     java.lang.String... descendantIDs)
                          throws java.lang.IllegalStateException
Returns the descendant of this node of a given tree type which can be reached by following a given sequence of node identifiers.

Parameters:
the - tree type.
descendantIDs - the identifiers.
Returns:
the descendant.
Throws:
java.lang.IllegalStateException - if the sequence does not lead to a descendant of this node of the given type.

descendants

public java.util.List<Node> descendants(javax.xml.namespace.QName... labels)
                                 throws java.lang.IllegalArgumentException
Returns all the descendants that can be reached by following a given sequence of labels.

Parameters:
labels - the labels.
Returns:
the descendants.
Throws:
java.lang.IllegalArgumentException - if no labels are specified.

descendants

public <T extends Node> java.util.List<T> descendants(java.lang.Class<T> type,
                                                      javax.xml.namespace.QName... labels)
                                           throws java.lang.IllegalArgumentException
Returns all the descendants of a given node type which can be reached by following a given sequence of labels.

Parameters:
the - node type.
labels - the labels.
Returns:
the descendants.
Throws:
java.lang.IllegalArgumentException - if no labels are specified.

descendants

public java.util.List<Node> descendants(java.lang.String... labels)
                                 throws java.lang.IllegalArgumentException
Returns all the descendants that can be reached by following a given sequence of labels.

Parameters:
labels - the local names of the labels.
Returns:
the descendants.
Throws:
java.lang.IllegalArgumentException - if no labels are specified.

descendants

public <T extends Node> java.util.List<T> descendants(java.lang.Class<T> type,
                                                      java.lang.String... labels)
                                           throws java.lang.IllegalArgumentException
Returns all the descendants of a given node type that can be reached by following a given sequence of labels.

Parameters:
the - node type.
labels - the local names of the labels.
Returns:
the descendants.
Throws:
java.lang.IllegalArgumentException - if no labels are specified.

child

public Node child(javax.xml.namespace.QName label)
           throws java.lang.IllegalStateException
Returns a child of this node with a given label, if exactly one exists.

Parameters:
label - the label.
Returns:
the child.
Throws:
java.lang.IllegalStateException - if the node has zero or more than one children with the given label.

child

public <T extends Node> T child(java.lang.Class<T> type,
                                javax.xml.namespace.QName label)
                     throws java.lang.IllegalStateException
Returns a child of this node with a given label and of a given node type, if exactly one exists.

Parameters:
type - the node type.
label - the label.
Returns:
the child.
Throws:
java.lang.IllegalStateException - if the node has zero or more than one children with the given label and of the given type.

child

public Node child(java.lang.String name)
           throws java.lang.IllegalArgumentException,
                  java.lang.IllegalStateException
Returns a child of this node with a given label, if exactly one exists.

Parameters:
name - the label's local name.
Returns:
the child.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.
java.lang.IllegalStateException - if the node has zero or more than one children with the given label.

child

public <T extends Node> T child(java.lang.Class<T> type,
                                java.lang.String name)
                     throws java.lang.IllegalArgumentException,
                            java.lang.IllegalStateException
Returns a child of this node with a given label and of a given node type, if exactly one exists.

Parameters:
the - node type.
name - the label's local name.
Returns:
the child.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.
java.lang.IllegalStateException - if the node has zero or more than one children with the given label and of the given type.

child

public Node child(java.lang.String ns,
                  java.lang.String name)
           throws java.lang.IllegalArgumentException,
                  java.lang.IllegalStateException
Returns a child of this node with a given label, if exactly one exists.

Parameters:
ns - the label's namespace.
name - the label's local name.
Returns:
the child.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.
java.lang.IllegalStateException - if the node has zero or more than one children with the given label.

child

public <T extends Node> T child(java.lang.Class<T> type,
                                java.lang.String ns,
                                java.lang.String name)
                     throws java.lang.IllegalArgumentException,
                            java.lang.IllegalStateException
Returns a child of this node with a given label and of a given type, if exactly one exists.

Parameters:
the - node type.
ns - the label's namespace.
name - the label's local name.
Returns:
the child.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.
java.lang.IllegalStateException - if the node has zero or more than one children with the given label and of the given type.

edges

public java.util.List<Edge> edges()
Returns all the edges.

Returns:
the edges.

edges

public java.util.List<Edge> edges(javax.xml.namespace.QName l)
Returns the outgoing edges with a given label.

Parameters:
l - the label.
Returns:
the edges.

edges

public java.util.List<Edge> edges(java.lang.String ns,
                                  java.lang.String l)
                           throws java.lang.IllegalArgumentException
Returns the outgoing edges with a given label.

Parameters:
ns - the label's namespace.
l - the label's local name.
Returns:
the edges.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null

edges

public java.util.List<Edge> edges(java.lang.String l)
                           throws java.lang.IllegalArgumentException
Returns the outgoing edges with a given label.

Parameters:
l - the label's local name.
Returns:
the edges.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.

hasEdge

public boolean hasEdge(javax.xml.namespace.QName l)
Indicates whether the node has at least an edge with a given label.

Parameters:
l - the label.
Returns:
true if it does, false otherwise.

hasEdge

public boolean hasEdge(java.lang.String l)
                throws java.lang.IllegalArgumentException
Indicates whether the node has at least an edge with a given label.

Parameters:
l - the label's local name.
Returns:
true if it does, false otherwise.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.

hasEdge

public boolean hasEdge(java.lang.String ns,
                       java.lang.String l)
                throws java.lang.IllegalArgumentException
Indicates whether the node has at least an edge with a given label.

Parameters:
the - label's namespace.
l - the label's local name.
Returns:
true if it does, false otherwise.
Throws:
java.lang.IllegalArgumentException - if the label's local name is null.

edge

public Edge edge(javax.xml.namespace.QName l)
          throws java.lang.IllegalStateException
Returns the edges with a given label, if exactly one exists.

Parameters:
l - the label.
Returns:
the edge.
Throws:
java.lang.IllegalStateException - if there no edge or more than one edge with a give label.

edge

public Edge edge(java.lang.String l)
          throws java.lang.IllegalStateException,
                 java.lang.IllegalArgumentException
Returns the edges with a given label, if exactly one exists.

Parameters:
l - the label's local name.
Returns:
the edge.
Throws:
java.lang.IllegalStateException - if there no edge or more than one edge with a give label.
java.lang.IllegalArgumentException - if the label's local name is null.

edge

public Edge edge(java.lang.String ns,
                 java.lang.String l)
          throws java.lang.IllegalStateException,
                 java.lang.IllegalArgumentException
Returns the edges with a given label, if exactly one exists.

Parameters:
ns - the label's namespace.
l - the label's local name.
Returns:
the edge.
Throws:
java.lang.IllegalStateException - if there no edge or more than one edge with a give label.
java.lang.IllegalArgumentException - if the label's local name is null.

labels

public java.util.List<javax.xml.namespace.QName> labels()
Returns the labels of all the outgoing edges.

Returns:
the labels.

labels

public java.util.List<javax.xml.namespace.QName> labels(javax.xml.namespace.QName l)
Returns all the labels that match a given one.

Parameters:
l - the label to match.
Returns:
the matching labels.

remove

public boolean remove(java.util.List<Edge> es)
Removes one or more edges.

Parameters:
es - the edges.
Returns:
true if any edge was actually removed, false otherwise.

remove

public boolean remove(Edge... es)
Removes one or more edges.

Parameters:
es - the edges.
Returns:
true if any edge was actually removed, false otherwise.

remove

public Node remove(java.lang.String childID)
            throws java.lang.IllegalStateException
Removes a child.

Parameters:
childID - the child's identifier.
Returns:
true if the child was actually removed, false otherwise.
Throws:
java.lang.IllegalStateException - if the child does not exist.

remove

public java.util.List<Node> remove(java.lang.String... childIDs)
Removes one or more children.

Parameters:
childIDs - the children's identifiers.
Returns:
the children actually removed.

add

public boolean add(java.util.List<Edge> es)
Adds one or more edges.

Parameters:
es - the edges.
Returns:
true if any edge was actually added, false otherwise.

add

public boolean add(Edge... es)
Adds one or more edges.

Parameters:
es - the edges.
Returns:
true if any edge was actually added, false otherwise.

delta

public InnerNode delta(Node f)
                throws java.lang.IllegalArgumentException,
                       java.lang.IllegalStateException
Returns a node that reflects the delta between this document and a given input node.

The delta node is computed under the expectation that the the input node is (or simply looks like) a future version of this node, as if it was originally cloned from this node and had evolved since.

Under this assumption, the delta node has:

Parameters:
future - the input node.
Throws:
java.lang.IllegalArgumentException - in the following circumstances:
  • this node or one its descendants has no identifier;
  • the descendants of this node and the input node which have the same identifier have instead different types;
  • there are descendants of the input node that have no counterpart below this node but do have identifiers.
java.lang.IllegalStateException

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class Node

hashCode

public int hashCode()

Overrides:
hashCode in class Node

main

public static void main(java.lang.String[] args)