Package com.sun.javatest
Class TRT_TreeNode
- java.lang.Object
-
- com.sun.javatest.TRT_TreeNode
-
- All Implemented Interfaces:
TestResultTable.TreeNode
public class TRT_TreeNode extends java.lang.Object implements TestResultTable.TreeNode
This is the implementation of a tree node structure for TestResultTable. Only the interface implementation is meant to be exposed. Assumptions are made that this is the only node class (implementation of TreeNode) used in the tree.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTRT_TreeNode.Fault
-
Field Summary
Fields Modifier and Type Field Description protected static intdebug
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObserver(TestResultTable.TreeNodeObserver obs)Add an observer to watch this node for changes.java.lang.ObjectgetChild(int index)Get the child at the specified location.intgetChildCount()Find out how many children this node contains.int[]getChildStatus()Get the statistics for the state of tests under this node.TestResultTablegetEnclosingTable()Find out what TestResultTable this node is part of.intgetEstimatedSize()Get the estimated number of tests below this node.intgetIndex(java.lang.Object target)Search for a specific item in this node.java.lang.StringgetName()The name of this node, not including all the ancestors names.TestResultTable.TreeNodegetParent()Get the parent of this node.intgetSize()Find out how many tests are in this node and below.TestResult[]getTestResults()Get any immediate children of this node which are test result objects.TestResultTable.TreeNode[]getTreeNodes()Get only the children of this node which are branches.booleanisLeaf(int index)Is the given element of this node a leaf.booleanisRoot()Is this the root of a tree.booleanisUpToDate()Has the finder been used to scan this node from secondary storage?.TestResultmatchTest(java.lang.String url)Finds a TestResult in this node with the given name.booleanrefreshIfNeeded()Refresh this entire node if necessary.voidremoveObserver(TestResultTable.TreeNodeObserver obs)Remove an observer that was previously added.
-
-
-
Method Detail
-
addObserver
public void addObserver(TestResultTable.TreeNodeObserver obs)
Add an observer to watch this node for changes.- Specified by:
addObserverin interfaceTestResultTable.TreeNode- Parameters:
obs- The observer to attach to this node. Should never be null.
-
removeObserver
public void removeObserver(TestResultTable.TreeNodeObserver obs)
Remove an observer that was previously added.- Specified by:
removeObserverin interfaceTestResultTable.TreeNode- Parameters:
obs- The observer to remove. No effect if it was never attached.
-
getSize
public int getSize()
Find out how many tests are in this node and below. If you invoke this on a node which is being lazily read from a TestFinder, this may cause a synchronous retrieval of data from the TestFinder. Use with caution!- Specified by:
getSizein interfaceTestResultTable.TreeNode- Returns:
- The number of tests under this node.
-
getEstimatedSize
public int getEstimatedSize()
Get the estimated number of tests below this node. Mainly useful for low contention hints about the size. No locking is involved in retrieving the information.
-
getParent
public TestResultTable.TreeNode getParent()
Description copied from interface:TestResultTable.TreeNodeGet the parent of this node.- Specified by:
getParentin interfaceTestResultTable.TreeNode- Returns:
- Null if this is the root. Another TreeNode otherwise.
-
isRoot
public boolean isRoot()
Description copied from interface:TestResultTable.TreeNodeIs this the root of a tree. A parent of null indicates this state.- Specified by:
isRootin interfaceTestResultTable.TreeNode- Returns:
- True if this is the root node, false otherwise.
-
getEnclosingTable
public TestResultTable getEnclosingTable()
Description copied from interface:TestResultTable.TreeNodeFind out what TestResultTable this node is part of.- Specified by:
getEnclosingTablein interfaceTestResultTable.TreeNode- Returns:
- The TRT instance which this node is contained.
-
isUpToDate
public boolean isUpToDate()
Description copied from interface:TestResultTable.TreeNodeHas the finder been used to scan this node from secondary storage?. This is an important performance consideration, since reading nodes may cause a noticable pause. This method may allow you to defer performance penalties. This method has no effect if a finder is not being used by the TestResultTable.- Specified by:
isUpToDatein interfaceTestResultTable.TreeNode- Returns:
- True if this location in tree has already been processed, false otherwise.
-
getChildCount
public int getChildCount()
Find out how many children this node contains. If you invoke this on a node which is being lazily read from a TestFinder, this may cause a synchronous retrieval of data from the TestFinder.- Specified by:
getChildCountin interfaceTestResultTable.TreeNode- Returns:
- The number of immediate children this node has.
-
getChild
public java.lang.Object getChild(int index)
Description copied from interface:TestResultTable.TreeNodeGet the child at the specified location. May be either a TestResult or TreeNode. If you invoke this on a node which is being lazily read from a TestFinder, this may cause a synchronous retrieval of data from the TestFinder.- Specified by:
getChildin interfaceTestResultTable.TreeNode- Parameters:
index- The location to retrieve.- Returns:
- Null if there are no children here or the specified index if out of range.
-
getTestResults
public TestResult[] getTestResults()
Description copied from interface:TestResultTable.TreeNodeGet any immediate children of this node which are test result objects.- Specified by:
getTestResultsin interfaceTestResultTable.TreeNode- Returns:
- List of TestResult objects in this node. null if none
-
getTreeNodes
public TestResultTable.TreeNode[] getTreeNodes()
Get only the children of this node which are branches.- Specified by:
getTreeNodesin interfaceTestResultTable.TreeNode- Returns:
- List of children nodes objects in this node. null if none.
-
getName
public java.lang.String getName()
Description copied from interface:TestResultTable.TreeNodeThe name of this node, not including all the ancestors names. This does not return a URL to this node from the root.- Specified by:
getNamein interfaceTestResultTable.TreeNode- Returns:
- Immediate name of this node, not the full name.
- See Also:
TestResultTable.getRootRelativePath(com.sun.javatest.TestResultTable.TreeNode)
-
isLeaf
public boolean isLeaf(int index)
Description copied from interface:TestResultTable.TreeNodeIs the given element of this node a leaf. In general this means that the element is a TestResult. It may also mean that the TreeNode is empty, which indicates a testsuite which is not well designed and needs trimming.- Specified by:
isLeafin interfaceTestResultTable.TreeNode- Parameters:
index- The element index of this node. An out of range index will return false.- Returns:
- True if the element at the given index is a leaf.
-
getChildStatus
public int[] getChildStatus()
Description copied from interface:TestResultTable.TreeNodeGet the statistics for the state of tests under this node.- Specified by:
getChildStatusin interfaceTestResultTable.TreeNode- Returns:
- An array of length Status.NUM_STATES, positionally representing the number of tests under this node with that state.
-
getIndex
public int getIndex(java.lang.Object target)
Description copied from interface:TestResultTable.TreeNodeSearch for a specific item in this node.- Specified by:
getIndexin interfaceTestResultTable.TreeNode- Parameters:
target- The target object should either be of type TreeNode or TestResult- Returns:
- The index at which the target object is located in this node. -1 if not found in in this node. -2 if the parameter is null
-
matchTest
public TestResult matchTest(java.lang.String url)
Description copied from interface:TestResultTable.TreeNodeFinds a TestResult in this node with the given name. This is a match against the test URL, not the filename. This is not recursive of course; it just does a straight match against all tests in this node.- Specified by:
matchTestin interfaceTestResultTable.TreeNode- Parameters:
url- The full name of the test to find.- Returns:
- The matching test result object, or null if not found. Also null if this node has no children.
- See Also:
TestDescription.getRootRelativeURL()
-
refreshIfNeeded
public boolean refreshIfNeeded()
Refresh this entire node if necessary. This means create any new nodes, and update any test descriptions.- Returns:
- True if some changes in this node were needed, false otherwise.
- See Also:
TestResultTable.refreshIfNeeded(String)
-
-