it.eng.spagobi.engines.qbe.crosstable
Class Node

java.lang.Object
  extended by it.eng.spagobi.engines.qbe.crosstable.Node
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<Node>

public class Node
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable<Node>


Field Summary
static java.lang.String CROSSTAB_NODE_JSON_CHILDS
           
static java.lang.String CROSSTAB_NODE_JSON_DESCRIPTION
           
static java.lang.String CROSSTAB_NODE_JSON_KEY
           
 
Constructor Summary
Node(java.lang.String value)
           
Node(java.lang.String value, java.lang.String description)
           
 
Method Summary
 void addChild(Node child)
           
 void addOrderedChild(Node child)
           
 void buildSubTree(int height, int branch)
          For test
 Node clone()
          Clone only the value and the children
 int compareTo(Node arg0)
           
 boolean equals(java.lang.Object obj)
           
 CrossTab.CellType getCellType()
           
 java.util.List<Node> getChilds()
           
 java.lang.String getDescription()
           
 int getDistanceFromLeaves()
          Returns the level distance between the node and its leaves (it is assumed that the tree is balanced, therefore every leaf has the same distance to this node).
 int getDistanceFromRoot()
          Returns the depth level of the node: root is depth 0, its children are depth 1 and so on...
 int getLeafPosition()
           
 java.util.List<java.lang.Integer> getLeafPositionsForCF()
           
 java.util.List<Node> getLeafs()
          Return the list of leafs of the subtree with this node as radix
 int getLeafsNumber()
          Get the number of leafs in the tree
 java.util.List<Node> getLevel(int level)
          return the list of nodes of the passed level
 int getRightMostLeafPositionCF()
           
 int getSubTreeDepth()
           
 java.lang.String getValue()
           
 int hashCode()
           
 boolean isChild(Node child)
           
 void orderedSubtree()
           
 void removeNodeFromTree()
          Remove this node from the tree..
 void setCellType(CrossTab.CellType cellType)
           
 void setChilds(java.util.List<Node> childs)
           
 void setLeafPositions()
          Initialize the variable leafPosition
 void setLeafPositionsForCF(java.util.List<java.lang.Integer> leafPositionsForCF)
           
 org.json.JSONObject toJSONObject()
          Serialize the node and the subtree
 java.lang.String toString()
           
 void updateFathers()
          Update the fathers of this tree
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CROSSTAB_NODE_JSON_CHILDS

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

CROSSTAB_NODE_JSON_KEY

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

CROSSTAB_NODE_JSON_DESCRIPTION

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

Node

public Node(java.lang.String value)

Node

public Node(java.lang.String value,
            java.lang.String description)
Method Detail

getValue

public java.lang.String getValue()

getDescription

public java.lang.String getDescription()

getChilds

public java.util.List<Node> getChilds()

setChilds

public void setChilds(java.util.List<Node> childs)

addOrderedChild

public void addOrderedChild(Node child)

addChild

public void addChild(Node child)

isChild

public boolean isChild(Node child)

getLeafsNumber

public int getLeafsNumber()
Get the number of leafs in the tree

Returns:

toJSONObject

public org.json.JSONObject toJSONObject()
                                 throws org.json.JSONException
Serialize the node and the subtree

Returns:
Throws:
org.json.JSONException

getLeafPosition

public int getLeafPosition()

setLeafPositions

public void setLeafPositions()
Initialize the variable leafPosition


getLeafPositionsForCF

public java.util.List<java.lang.Integer> getLeafPositionsForCF()

setLeafPositionsForCF

public void setLeafPositionsForCF(java.util.List<java.lang.Integer> leafPositionsForCF)

getLevel

public java.util.List<Node> getLevel(int level)
return the list of nodes of the passed level

Parameters:
level -
Returns:

getDistanceFromRoot

public int getDistanceFromRoot()
Returns the depth level of the node: root is depth 0, its children are depth 1 and so on...

Returns:
the depth level of the node: root is depth 0, its children are depth 1 and so on...

getDistanceFromLeaves

public int getDistanceFromLeaves()
Returns the level distance between the node and its leaves (it is assumed that the tree is balanced, therefore every leaf has the same distance to this node). If the node is a leaf, 0 is returned.

Returns:
the level distance between the node and its leaves (it is assumed that the tree is balanced, therefore every leaf has the same distance to this node). If the node is a leaf, 0 is returned.

getLeafs

public java.util.List<Node> getLeafs()
Return the list of leafs of the subtree with this node as radix

Returns:

updateFathers

public void updateFathers()
Update the fathers of this tree


getSubTreeDepth

public int getSubTreeDepth()

removeNodeFromTree

public void removeNodeFromTree()
Remove this node from the tree.. IThe fathers must be valued for all the tree


getRightMostLeafPositionCF

public int getRightMostLeafPositionCF()

clone

public Node clone()
Clone only the value and the children

Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

buildSubTree

public void buildSubTree(int height,
                         int branch)
For test

Parameters:
height -
branch -

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getCellType

public CrossTab.CellType getCellType()

setCellType

public void setCellType(CrossTab.CellType cellType)

compareTo

public int compareTo(Node arg0)
Specified by:
compareTo in interface java.lang.Comparable<Node>

orderedSubtree

public void orderedSubtree()