jbcl.model Package
java.lang.Object +----com.borland.jbcl.model.GraphModelSearch
Variables Constructors Properties Methods
Implements Serializable
This class is designed to facilitate searching through GraphModel
data structures. It supports four types of top-down searching:
GraphModel
structure and returns the GraphLocation
address (or null if not found).
GraphModel
structure, and subsequently drills deeper into the GraphModel
structure until each data object is located. The search returns the located GraphLocation
address (or null if not found). The passed data object array need not correspond directly to the heirarchy of the GraphModel
, but each data object must exist in the GraphModel
and it must exist under the same parent line.
GraphModel
structure, and subsequently drills deeper into the GraphModel
structure until each data object is located - and finally returning the deepest located GraphLocation
address that was found. This method returns a GraphLocation
address for the last data object it was successful in finding, ignoring the rest of the data object array contents.
GraphModel
structure, and subsequently drills deeper into the GraphModel
structure as each data object is located in the child list - and finally returning the located GraphLocation
address (or null if not found). This method requires the passed data object array to directly correspond to the hierarchy of the GraphModel
, following the exact parent hierarchy.
All searching algorithm logic can be modified by setting the depthFirstSearch
and fullSearch
properties.
The depthFirstSearch
property, which defaults to false, tells the search algorithms to check all sibling children of a node before drilling down into the first child node's children, and so on. This results in the first (most shallow) occurrence of a data object to be located. If the depthFirstSearch
property is set to true, the search drills to the absolute bottom of each node before moving onto the next. This results in a potentially deeper GraphLocation
as a search result.
The fullSearch
property tells the different search methods whether or not to fetch children when node returns TriState.UNKNOWN to the GraphLocation.hasChildren()
method. Typically, UNKNOWN is only returned by an implementor of GraphLocation
when the process of fetching the children is potentially costly (in CPU cycles). If the fullSearch
property is set to false, all search algorithms treat an UNKNOWN response to GraphLocation.hasChildren()
as NO and continue on without fetching the children of that node. This can potentially affect search results in that any nodes below an UNKNOWN child node is not checked. By default, this property is true, and all children are checked.
protected boolean depthFirstSearch
protected boolean fullSearch
protected transient GraphModel model
public GraphModelSearch()Constructs a
GraphModelSearch
object with all default settings, which is a null model, depthFirstSearch
= true, and fullSearch
= true.
public GraphModelSearch(GraphModel model)Constructs a
GraphModelSearch
object with the specified model setting. (depthFirstSearch
= false and fullSearch
= true)
Parameters:
model
GraphModel
to use for searching
public GraphModelSearch(GraphModel model, boolean depthFirstSearch)Constructs a
GraphModelSearch
object with the specified model and depthFirstSearch
settings. (fullSearch
= true)
Parameters:
model
GraphModel
to use for searching
depthFirstSearch
public GraphModelSearch(GraphModel model, boolean depthFirstSearch, boolean fullSearch)Constructs a
GraphModelSearch
object with the specified model
, depthFirstSearch
, and fullSearch
settings.
Parameters:
model
GraphModel
to use for searching.
depthFirstSearch
fullSearch
GraphLocation.getChildren()
method.
public boolean isDepthFirstSearch() public void setDepthFirstSearch(boolean depthFirstSearch)The
depthFirstSearch
property specifies whether the search algorithms should check all sibling children of a node before drilling down into the first child node's children, etc.
The default setting is false, which results in the most shallow occurrence of a data object to be located. If this property is set to true, the search drills to the absolute bottom of each node before moving onto the next. This results in a potentially deeper GraphLocation
as a search result.
Parameters:
depthFirstSearch
public boolean isFullSearch() public void setFullSearch(boolean fullSearch)The
fullSearch
property tells the different search methods whether to fetch children when the node returns TriState.UNKNOWN to the GraphLocation.hasChildren()
method. Typically, UNKNOWN is only returned by an implementor of GraphLocation
when the process of fetching the children is potentially costly (in CPU cycles). If the fullSearch
property is set to false, all search algorithms treats an UNKNOWN response to GraphLocation.hasChildren()
as NO and continue on without fetching the child nodes of that node. This can potentially effect search results in that any nodes below an UNKNOWN children node is not checked. By default, this property is true, and all children are checked.
Parameters:
fullSearch
GraphLocation.hasChildren()
returns TriState.UNKNOWN.
public GraphModel getModel() public void setModel(GraphModel model)The
model
property specifies a GraphModel
to search. This property must be set before any search routines can be called.
Parameters:
model
GraphModel
to use for searching
protected boolean checkMatch(Object first, Object second)This method (called from several other methods) compares the two passed data objects see if they matc h,first with a straight '==' check, then with a '.equals' check.
NOTE: subclasses may wish to override this method to allow for incremental searching or partial matches.
Parameters:
first
second
protected void checkModel()This method (called from nearly all other methods) checks to make sure the model property is correctly set before proceeding. It throws an IllegalStateException if no model is set.
public GraphLocation exactPathSearch(GraphLocation node, Object[] data)This path searching method will search the
GraphModel
structure (starting at the passed node), looking for matches to the passed data objects. As each data object is found in the immediate child list of the previous, the algorythm will dig deeper under that node to find the next data object. If the last data object is found, this method returns a GraphLocation
representing its address in the GraphModel
structure. If the last data object cannot be found in the GraphModel
structure, or any of the passed data objects cannot be found in order in the child list of the previous found node, this method returns null. The passed data object array need not directly correspond to the heirarchy of the GraphModel
, following the exact parent hierarchy.
Parameters:
data
GraphModel
public GraphLocation exactPathSearch(Object[] data)This path searching method will search the entire
GraphModel
structure (starting at the root node), looking for matches to the passed data objects. As each data object is found in the immediate child list of the previous, the algorithm digs deeper under that node to find the next data object. If the last data object is found, this method returns a GraphLocation
representing its address in the GraphModel
structure. If the last data object cannot be found in the GraphModel
structure, or any of the passed data objects cannot be found in order in the child list of the previous found node, this method returns null. This method requires the passed data object array to directly correspond to the heirarchy of the GraphModel
, following the exact parent hierarchy.
Parameters:
data
GraphModel
public GraphLocation partialPathSearch(GraphLocation node, Object[] data)This path searching method will search the
GraphModel
structure (starting at the passed node), looking for matches to the passed data objects. As each data object is found, the algorythm will dig deeper under that node to find the next data object. If a data object cannot be found, it will return a GraphLocation
representing the deepest object it was able to locate - ignoring the rest of the data object array contents.
Parameters:
data
GraphModel
.
public GraphLocation partialPathSearch(Object[] data)This path searching method searches the entire
GraphModel
structure (starting at the root node), looking for matches to the passed data objects. As each data object is found, the algorithm digs deeper under that node to find the next data object. If a data object cannot be found, it returns a GraphLocation
representing the deepest object it was able to locate,ignoring the rest of the data object array contents.
Parameters:
data
GraphModel
public GraphLocation pathSearch(GraphLocation node, Object[] data)This path searching method will search the
GraphModel
structure (starting at the passed node), looking for matches to the passed data objects. As each data object is found, the algorithm digs deeper under that node to find the next data object. If the last data object is found, it returns a GraphLocation
representing its address. If the last data object cannot be found in the GraphModel
structure, this method returns null. The passed data object array need not directly correspond to the heirarchy of the GraphModel
, but each data object must exist in the GraphModel
and must exist under the same parent hierarchy.
Parameters:
data
GraphModel
public GraphLocation pathSearch(Object[] data)This path searching method searches the entire
GraphModel
structure (starting at the root node), looking for matches to the passed data objects. As each data object is found, the algorithm digs deeper under that node to find the next data object. If the last data object is found, it returns a GraphLocation
representing its address. If the last data object cannot be found in the GraphModel
structure, this method returns null. The passed data object array need not directly correspond to the heirarchy of the GraphModel
, but each data object must exist in the GraphModel
and must exist under the same parent hierarchy.
Parameters:
data
GraphModel
protected GraphLocation scanNodes(GraphLocation[] nodes, Object data)This method (called from several other methods) scans the passed
GraphLocation
array to see if the corresponding data objects in the GraphModel
are equal to the passed data object.
Parameters:
nodes
GraphLocations
to scan
data
public GraphLocation search(GraphLocation node, Object data)This search method searches the
GraphModel
structure starting at the passed node and down, looking for a match to the passed data object. If the data object is found, it returna a GraphLocation
representing the address of the data object. If the data object cannot be found in the GraphModel
structure, this method returns null.
NOTE: This is a recursive method (it calls itself), and subclasses should be consider this carefully when overriding this method.
Parameters:
node
GraphLocation
to begin searching under for the data object
data
GraphModel
public GraphLocation search(Object data)This search method searches the entire
GraphModel
structure (starting at the root node), looking for a match to the passed data object. If the data object is found, it returns a GraphLocation
representing the address of the data object. If the data object cannot be found in the GraphModel
structure, this method returns null.
Parameters:
data
GraphModel