org.gcube.data.trees.data
Class Tree

java.lang.Object
  extended by org.gcube.data.trees.data.Node
      extended by org.gcube.data.trees.data.InnerNode
          extended by org.gcube.data.trees.data.Tree

public class Tree
extends InnerNode

An InnerNode at the root of a tree.

Author:
Fabio Simeoni

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gcube.data.trees.data.Node
Node.State
 
Constructor Summary
Tree()
          Creates an instance.
Tree(Edge... edges)
          Constructs an instance with given edges.
Tree(String id)
          Constructs an instance with a given identifier.
Tree(String id, Edge... edges)
          Constructs an instance with a given identifier and edges.
Tree(String id, Map<QName,String> attributes, Edge... edges)
          Constructs an instance with a given identifier, attributes, and edges.
Tree(String id, Node.State state, Map<QName,String> attributes, Edge... edges)
           
Tree(String sourceId, String id, Edge... edges)
          Constructs an instance in a given source with a given identifier and given edges.
Tree(Tree tree)
          Copy constructor, creates an instance as a clone of a given tree.
 
Method Summary
 Tree delta(Tree future)
          Returns a tree that reflects the delta between this tree and a given tree, or null if the tree are equals.
 boolean equals(Object obj)
          
 int hashCode()
          
 void setSourceId(String id)
          Sets the identifier of the tree source.
 String sourceId()
          Returns the identifier of the tree source.
 String toString()
          
 
Methods inherited from class org.gcube.data.trees.data.InnerNode
add, add, add, child, child, child, child, child, child, children, children, children, children, children, children, children, children, clearState, delete, delta, descendant, descendant, descendants, descendants, descendants, descendants, edge, edge, edge, edges, edges, edges, edges, find, find, hasEdge, hasEdge, hasEdge, labels, labels, markAsNew, remove, remove, remove, remove, remove, size, update
 
Methods inherited from class org.gcube.data.trees.data.Node
ancestors, ancestorsAndSelf, attribute, attribute, attributes, hasAttribute, hasAttribute, id, parent, removeAttribute, removeAttribute, setAttribute, setAttribute, setParent, state, state, uri, uri
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tree

public Tree(Tree tree)
Copy constructor, creates an instance as a clone of a given tree.

Parameters:
tree - the tree.

Tree

public Tree()
Creates an instance.


Tree

public Tree(String id)
Constructs an instance with a given identifier.

Parameters:
id - the identifier.

Tree

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

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

Tree

public Tree(Edge... edges)
Constructs an instance with given edges.

Parameters:
edges - the edges.

Tree

public Tree(String sourceId,
            String id,
            Edge... edges)
Constructs an instance in a given source with a given identifier and given edges.

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

Tree

public Tree(String id,
            Map<QName,String> attributes,
            Edge... edges)
Constructs an instance with a given identifier, attributes, and edges.

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

Tree

public Tree(String id,
            Node.State state,
            Map<QName,String> attributes,
            Edge... edges)
Method Detail

setSourceId

public void setSourceId(String id)
Sets the identifier of the tree source.

Parameters:
id - the identifier

sourceId

public String sourceId()
Returns the identifier of the tree source.

Returns:
the identifier

delta

public Tree delta(Tree future)
           throws IllegalArgumentException
Returns a tree that reflects the delta between this tree and a given tree, or null if the tree are equals.

The delta tree can only be computed if the input tree has the same identifier as this tree, and it is repeated recursively for all pairs of children that verify the same condition. For all purposes, in fact, the input tree is expected to be (or simply look like) a future version of this tree, as if it was originally cloned from this tree and had evolved since.

Under this assumption, the delta tree has:

Parameters:
future - the input tree
Throws:
IllegalArgumentException - in the following circumstances:
  • this tree has a different identifier from this tree;
  • the root of this tree or one its descendants has no identifier;
  • the descendants of the root of this tree and the input tree's which have the same identifier have instead different types;
  • there are descendants of the root of the input tree that have no counterpart in this tree and yet have identifiers.

toString

public String toString()

Overrides:
toString in class InnerNode

hashCode

public int hashCode()
Description copied from class: InnerNode

Overrides:
hashCode in class InnerNode

equals

public boolean equals(Object obj)
Description copied from class: InnerNode

Overrides:
equals in class InnerNode


Copyright © 2013. All Rights Reserved.