com.sun.javatest
Class TRT_TreeNode

java.lang.Object
  extended by 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
static class TRT_TreeNode.Fault
           
 
Field Summary
protected static int debug
           
 
Method Summary
 void addObserver(TestResultTable.TreeNodeObserver obs)
          Add an observer to watch this node for changes.
 java.lang.Object getChild(int index)
          Get the child at the specified location.
 int getChildCount()
          Find out how many children this node contains.
 int[] getChildStatus()
          Get the statistics for the state of tests under this node.
 TestResultTable getEnclosingTable()
          Find out what TestResultTable this node is part of.
 int getEstimatedSize()
          Get the estimated number of tests below this node.
 int getIndex(java.lang.Object target)
          Search for a specific item in this node.
 java.lang.String getName()
          The name of this node, not including all the ancestors names.
 TestResultTable.TreeNode getParent()
          Get the parent of this node.
 int getSize()
          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.
 boolean isLeaf(int index)
          Is the given element of this node a leaf.
 boolean isRoot()
          Is this the root of a tree.
 boolean isUpToDate()
          Has the finder been used to scan this node from secondary storage?.
 TestResult matchTest(java.lang.String url)
          Finds a TestResult in this node with the given name.
 boolean refreshIfNeeded()
          Refresh this entire node if necessary.
 void removeObserver(TestResultTable.TreeNodeObserver obs)
          Remove an observer that was previously added.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected static int debug
Method Detail

addObserver

public void addObserver(TestResultTable.TreeNodeObserver obs)
Add an observer to watch this node for changes.

Specified by:
addObserver in interface TestResultTable.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:
removeObserver in interface TestResultTable.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:
getSize in interface TestResultTable.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.TreeNode
Get the parent of this node.

Specified by:
getParent in interface TestResultTable.TreeNode
Returns:
Null if this is the root. Another TreeNode otherwise.

isRoot

public boolean isRoot()
Description copied from interface: TestResultTable.TreeNode
Is this the root of a tree. A parent of null indicates this state.

Specified by:
isRoot in interface TestResultTable.TreeNode
Returns:
True if this is the root node, false otherwise.

getEnclosingTable

public TestResultTable getEnclosingTable()
Description copied from interface: TestResultTable.TreeNode
Find out what TestResultTable this node is part of.

Specified by:
getEnclosingTable in interface TestResultTable.TreeNode
Returns:
The TRT instance which this node is contained.

isUpToDate

public boolean isUpToDate()
Description copied from interface: TestResultTable.TreeNode
Has 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:
isUpToDate in interface TestResultTable.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:
getChildCount in interface TestResultTable.TreeNode
Returns:
The number of immediate children this node has.

getChild

public java.lang.Object getChild(int index)
Description copied from interface: TestResultTable.TreeNode
Get 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:
getChild in interface TestResultTable.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.TreeNode
Get any immediate children of this node which are test result objects.

Specified by:
getTestResults in interface TestResultTable.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:
getTreeNodes in interface TestResultTable.TreeNode
Returns:
List of children nodes objects in this node. null if none.

getName

public java.lang.String getName()
Description copied from interface: TestResultTable.TreeNode
The name of this node, not including all the ancestors names. This does not return a URL to this node from the root.

Specified by:
getName in interface TestResultTable.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.TreeNode
Is 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:
isLeaf in interface TestResultTable.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.TreeNode
Get the statistics for the state of tests under this node.

Specified by:
getChildStatus in interface TestResultTable.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.TreeNode
Search for a specific item in this node.

Specified by:
getIndex in interface TestResultTable.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.TreeNode
Finds 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:
matchTest in interface TestResultTable.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)


Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.