org.javasimon.callback.calltree
Class CallTreeNode

java.lang.Object
  extended by org.javasimon.callback.calltree.CallTreeNode

public class CallTreeNode
extends Object

Call tree node is one Simon one for one call level, all splits for this Simon+Level(+Thread) tuple are kept for later analysis. Simon name is unique within parent tree node. Said differently a tree node can not have two children with same name.

Since:
3.2
Author:
gquintana

Field Summary
private  Map<String,CallTreeNode> children
          Child tree nodes.
private  String name
          Name, used as a key.
private  CallTreeNode parent
          Parent tree node.
private  List<Split> splits
          Splits.
 
Constructor Summary
CallTreeNode(String name)
          Main constructor.
 
Method Summary
 CallTreeNode addChild(String name)
          Adds a child to this tree node.
 void addSplit(Split split)
          Adds a split to the current tree node.
 CallTreeNode getChild(String name)
          Returns the child node by Simon name.
 Collection<CallTreeNode> getChildren()
          Returns all child nodes.
 String getName()
          Returns Simon name.
 CallTreeNode getOrAddChild(String name)
          Returns a child node with given name or creates it if it does not exists.
 CallTreeNode getParent()
          Returns parent tree node.
 Integer getPercent()
          Returns the part of time spent in this node compared to parent.
 int getSplitCount()
          Returns the number of splits in this node.
 long getTotal()
          Returns the total time of splits using Split.runningFor().
 void print(PrintWriter printWriter)
          Recursively prints this tree node to given print writer.
private  void print(PrintWriter printWriter, String prefix, Long parentTotal)
          Recursively prints this tree node to given print writer.
 String toString()
          Returns a string representing the tree from this tree node, visiting recursively this tree branch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private final String name
Name, used as a key.


splits

private final List<Split> splits
Splits. Size defaults to 1, because most of the time there are no loops.


children

private Map<String,CallTreeNode> children
Child tree nodes.


parent

private CallTreeNode parent
Parent tree node. null for root tree node.

Constructor Detail

CallTreeNode

public CallTreeNode(String name)
Main constructor.

Parameters:
name - Simon name
Method Detail

getName

public String getName()
Returns Simon name.

Returns:
Name

addSplit

public void addSplit(Split split)
Adds a split to the current tree node. In case of loops, child nodes can have many splits.

Parameters:
split - Split

getSplitCount

public int getSplitCount()
Returns the number of splits in this node.

Returns:
Split count

getTotal

public long getTotal()
Returns the total time of splits using Split.runningFor().

Returns:
total time of splits

getPercent

public Integer getPercent()
Returns the part of time spent in this node compared to parent.

Returns:
Percent time

addChild

public CallTreeNode addChild(String name)
Adds a child to this tree node.

Parameters:
name - Child Simon name
Returns:
Created child node

getChild

public CallTreeNode getChild(String name)
Returns the child node by Simon name.

Parameters:
name - Simon name
Returns:
Child corresponding to given name, or null if any

getChildren

public Collection<CallTreeNode> getChildren()
Returns all child nodes.

Returns:
children

getOrAddChild

public CallTreeNode getOrAddChild(String name)
Returns a child node with given name or creates it if it does not exists.

Parameters:
name - Simon name
Returns:
Child node

getParent

public CallTreeNode getParent()
Returns parent tree node.

Returns:
Parent tree node

print

private void print(PrintWriter printWriter,
                   String prefix,
                   Long parentTotal)
Recursively prints this tree node to given print writer.

Parameters:
printWriter - Output print writer
prefix - Line prefix (used internally for indentation)
parentTotal - Duration of parent node (used to compute duration ratio for child nodes), null for root nodes

print

public void print(PrintWriter printWriter)
Recursively prints this tree node to given print writer.

Parameters:
printWriter - Output print writer

toString

public String toString()
Returns a string representing the tree from this tree node, visiting recursively this tree branch.

Overrides:
toString in class Object
Returns:
String


Copyright © 2013. All Rights Reserved.