| |
|
| java.lang.Object com.jamonapi.utils.NodeTree
NodeTree | public class NodeTree extends java.lang.Object (Code) | | A NodeTree works with Compositenodes and LeafNodes to create heirarchical object trees. An example is a file system where directories
can be viewed LeafNodes and directories can be viewed as CompoisteNodes. TreeNodes can be viewed as the top level of the tree structures.
For JAMon monitors are grouped in heirarchical with the CompositeNodes being MonitorComposite. MonitorComposites can contain other
MonitorComposites or LeafNodes which are the actual Monitors. Monitors are identified by monitor lables which are strings seperated
by a common delimiter for example "MyApp.jsp.homePage". The first two levels of the heirarchy are CompositeNodes/MonitorComposites
(MyApp and jsp), and the entry after the last delimiter is always the LeafNode (in this case a Monitor).
Note that NodeTrees/CompositeNodes/LeafNodes can represent ANY hierarchical/tree structure. JAMon uses this generic pattern to
model Monitors.
NodeTree's use the first non-alphanumeric to represent the token delimiter. For example any combination of
the following are considered token delimiters. (i.e. the following are all valid)
pages.homepage (token delimeter is .)
pages\homepage (token delimeter is \)
pages\homepage.button (token delimeter is \ not .)
note - Exception to the rule that token delimeters are the first non-alphanumeric characters are - and _.
They are considered part of the variable name. A token delimeter can be any of the following: !@#$%^&*()+=[]\\{}|;':\",./<>?`~
|
compositeNodeExists | public boolean compositeNodeExists(String locator)(Code) | | Determine if the CompositeNode represented by the locator string exists.
Sample Call:
if (nodeTree.compositeNodeExists("MyApp.jsp"))
...
|
getCompositeNode | public CompositeNode getCompositeNode(String locator)(Code) | | Return the NodeTree's CompositeNode object that is identified by the locator. Also add it to the
NodeTree.
This method uses the StringTokenizer to parse the locator String. StringTokenizer is notoriously slow
and this code could be replaced in the future.
Sample Call:
CompositeNode compositeNode=nodeTree.getCompositeNode("MyApp.jsp");
|
getLeafNode | public LeafNode getLeafNode(String locator, String type)(Code) | | Return the NodeTree's LeafNode object that is identified by the locator and type. Also add it to the
NodeTree.
This method uses the StringTokenizer to parse the locator String. StringTokenizer is notoriously slow
and this code could be replaced in the future.
Sample Call:
LeafNode leafNode=nodeTree.getLeafNode("MyApp.jsp.homePage", "type");
The variable "type" is can be any string that is useful to the developer when creating a LeafNode.
Note:
getLeafNode(...) recursively calls getCompositeNode(...) for each NodeTree in the label. In the above example
getCompositeNode(...) would be called once for "MyApp" and once for "jsp".
|
getRootNode | public CompositeNode getRootNode()(Code) | | Return the highest level CompositeNode in the NodeTree. i.e. the entry point to all other CompositeNodes and LeafNodes.
To use the file system analogy then the root node would be the root directory in Unix or c:\ in Windows.
|
leafNodeExists | public boolean leafNodeExists(String locator)(Code) | | Determine if the leaf represented by the locator string exists.
Sample Call:
if (nodeTree.leafNodeExists("MyApp.jsp.homePage"))
...
|
nodeExists | public boolean nodeExists(String locator)(Code) | | Determine if the Node represented by the locator string exists. The node can be either a CompositeNode or LeafNode.
Sample Call:
if (nodeTree.nodeExists("MyApp.jsp.homePage"))
...
|
|
|
|