org.safs
Class GuiChildIterator

java.lang.Object
  extended by org.safs.GuiChildIterator
Direct Known Subclasses:
RGuiChildIterator

public class GuiChildIterator
extends java.lang.Object


Nested Class Summary
 class GuiChildIterator.ClassTypeInfo
           
 
Field Summary
protected static java.util.Hashtable absindices
          Stores object references at absolute indices.
static int CLASSIC_SEARCH_MODE
          0=Classic Search Mode The default mode which attempts to mimic the IBM Rational Robot search algorithm in order to retain compatibility with IBM Rational Robot recognition strings.
static int FULLPATH_SEARCH_MODE
          1=Fullpath Search Mode (New, and incompatible with IBM Rational Robot) A new search mode which requires recognition strings to contain info for each hierarchical level in the parent/child ancestry tree.
protected  java.util.List gather
          Stores list of matching named items.
protected static boolean hasFinalMatch
          Flag indicating a final match was achieved for the object vector.
protected static java.util.Vector matches
          Stores object references that match pieces of our recognition strings.
protected static boolean notFound
          Flag indicating whether object searches should continue to iterate.
protected static int SEARCH_MODE
          Default is CLASSIC_SEARCH_MODE
 
Constructor Summary
GuiChildIterator(java.util.List gather)
          ONLY used internally by the initial GuiChildIterator for each subsequent child level in the hierarchy search.
GuiChildIterator(java.lang.Object aparent, GuiObjectVector agovVector, java.util.List gather)
          Called only once by some external routine kicking off a TestObject search.
 
Method Summary
static java.util.Hashtable getAbsoluteIndexStore()
          Returns stored absolute indices Hashtable.
 java.util.List getGather()
          Returns are stored List.
 java.lang.Object getMatchedGuiObject()
          Retrieves the final Object that satisfies the entire GuiObjectVector recognition string.
static java.util.Vector getMatches()
          Retrieves the final list of possible child matches.
static int getSearchMode()
           
protected  GuiChildIterator.ClassTypeInfo incrementClassTypeIndices(java.lang.Object child, GuiObjectVector govVector, int govLevel, int objLevel, java.util.Hashtable classindices, java.util.Hashtable typeindices, java.lang.String classname)
           
protected  void processChildren(java.lang.Object achild, GuiObjectVector agovVector, int agovLevel, int aobjLevel, java.util.Hashtable classindices, java.util.Hashtable typeindices, java.lang.String typeclass)
          See if the provided object reference has any children that may help satisfy the recognition string.
protected  void processNextLevel(java.lang.Object[] children, GuiObjectVector govVector, int govLevel, int objLevel, java.util.Hashtable entry_classindices, java.util.Hashtable entry_typeindices, boolean onlyOneChildVisible)
          Called internally by processChildren only.
protected  void processParent(java.lang.Object parent, GuiObjectVector agovVector, int agovLevel, int aobjLevel, java.util.Hashtable classindices, java.util.Hashtable typeindices, java.lang.String typeclass)
           
static void resetAbsoluteIndexStore()
          Reset\Clear stored absolute indices.
static void setSearchMode(int search_mode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSIC_SEARCH_MODE

public static final int CLASSIC_SEARCH_MODE
0=Classic Search Mode The default mode which attempts to mimic the IBM Rational Robot search algorithm in order to retain compatibility with IBM Rational Robot recognition strings. Hierarchy and class/type indices are incremented in the classic manner:
        1
        /\
       2  5
      /    \--\--\---\---\
     3      6  6  6  10? 10?
    /              \
   4                7
                     \
                      8
                       \
                        9
 

See Also:
Constant Field Values

FULLPATH_SEARCH_MODE

public static final int FULLPATH_SEARCH_MODE
1=Fullpath Search Mode (New, and incompatible with IBM Rational Robot) A new search mode which requires recognition strings to contain info for each hierarchical level in the parent/child ancestry tree. This mode will NOT search children of a parent that itself is not a match for the fullpath recognition string. Hierarchy and class/type indices are incremented uniquely (and reset?) at each hierarchy level. This is expected to improve performance (time) in locating matches at the expense of having longer recognition strings enabling the match at each level in the hierarchy. CLASSIC search mode would find the item #5 below after testing 14 objects. FULLPATH search mode should find the same #5 item after testing only 8 objects.
        1
        /\
       1  2
      /    \--\--\--\--\
     1      1  2  3  4  5
    /           \  \
   1             1  1
                     \--\
                      1  2
 

See Also:
Constant Field Values

SEARCH_MODE

protected static int SEARCH_MODE
Default is CLASSIC_SEARCH_MODE


matches

protected static java.util.Vector matches
Stores object references that match pieces of our recognition strings.


notFound

protected static boolean notFound
Flag indicating whether object searches should continue to iterate.


hasFinalMatch

protected static boolean hasFinalMatch
Flag indicating a final match was achieved for the object vector.


absindices

protected static java.util.Hashtable absindices
Stores object references at absolute indices.


gather

protected java.util.List gather
Stores list of matching named items.

Constructor Detail

GuiChildIterator

public GuiChildIterator(java.util.List gather)
ONLY used internally by the initial GuiChildIterator for each subsequent child level in the hierarchy search.

Parameters:
gather, - List containing names matched, if null, then match first name

GuiChildIterator

public GuiChildIterator(java.lang.Object aparent,
                        GuiObjectVector agovVector,
                        java.util.List gather)
Called only once by some external routine kicking off a TestObject search. The govLevel and objLevel in the ObjectVector will be assumed to be 0. The routine will install an initial class and type indices for the provided parent.

If we can deduce that the parent actually exists in the path vector then that govLevel of the vector will be matched and skipped. If we find that the parent info is NOT in the provided vector then we will not skip the govLevel.

We can assume the parent info is in the path if the path begins with "\;". The next item in the path is assumed to be the topmost parent.

We can ignore the first path info if it instead begins with ".\;". The next item would be considered to be the first child of the parent.

Parameters:
aparent - the topmost parent to search.

agovVector - the govVector (recognition string) to satisfy with the search.

gather, - List containing names matched, if null, then match first name
Method Detail

getSearchMode

public static int getSearchMode()
Returns:
the SEARCH_MODE

setSearchMode

public static void setSearchMode(int search_mode)
Parameters:
search_mode - the SEARCH_MODE to set

getGather

public java.util.List getGather()
Returns are stored List.


getAbsoluteIndexStore

public static java.util.Hashtable getAbsoluteIndexStore()
Returns stored absolute indices Hashtable.


resetAbsoluteIndexStore

public static void resetAbsoluteIndexStore()
Reset\Clear stored absolute indices.


getMatches

public static java.util.Vector getMatches()
Retrieves the final list of possible child matches. Each item in the Vector is an object of type MatchData.

Returns:
the never-null Vector list of matched objects (if any).

processChildren

protected void processChildren(java.lang.Object achild,
                               GuiObjectVector agovVector,
                               int agovLevel,
                               int aobjLevel,
                               java.util.Hashtable classindices,
                               java.util.Hashtable typeindices,
                               java.lang.String typeclass)
See if the provided object reference has any children that may help satisfy the recognition string. This is essentially how this Iterator is "reentrant". Objects matching pieces of our ObjectVector are added to the statically shared matches collection until the final Object satisfying the entire ObjectVector is found.

Throughout the process we must maintain an accurate count of each class and its associated object type in each child branch. In this way, we keep track of when we have found the nth Index of a class or an associated object type in the branch. Thus, for each object encountered, we must increment both the class count, and t he object type count for that class in this branch.

Note, as we go down an object hierarchy branch, the counts increment. However, when we reset back up to a higher level in the object hierarchy to go down a new branch, the counts must be reset to those counts that were valid on entry at that level.

This function is only called internally.

Parameters:
achild - the Object to process for children.

agovVector - the currently active GuiObjectVector.

agovLevel - the hierarchy level in the GuiObjectVector we are trying to satisfy.

aobjLevel - the level in the actual object hierarchy we are searching.

classindices - the storage of current class counts.

typeindices - the storage of current object type counts.

processParent

protected void processParent(java.lang.Object parent,
                             GuiObjectVector agovVector,
                             int agovLevel,
                             int aobjLevel,
                             java.util.Hashtable classindices,
                             java.util.Hashtable typeindices,
                             java.lang.String typeclass)

incrementClassTypeIndices

protected GuiChildIterator.ClassTypeInfo incrementClassTypeIndices(java.lang.Object child,
                                                                   GuiObjectVector govVector,
                                                                   int govLevel,
                                                                   int objLevel,
                                                                   java.util.Hashtable classindices,
                                                                   java.util.Hashtable typeindices,
                                                                   java.lang.String classname)
Parameters:
child -
govVector -
objLevel -
govLevel -
classindices -
typeindices -
classname -
Returns:
NULL if error occurs relating to gorInfo creation, or NULL if object is NOT to be processed. Otherwise, return a valid ClassTypeInfo object with all appropriate settings.

processNextLevel

protected void processNextLevel(java.lang.Object[] children,
                                GuiObjectVector govVector,
                                int govLevel,
                                int objLevel,
                                java.util.Hashtable entry_classindices,
                                java.util.Hashtable entry_typeindices,
                                boolean onlyOneChildVisible)
Called internally by processChildren only.

Parameters:
children - -- array of child objects to examine to see if any one of them satisfies the piece of the recognition string for the current object vector level--the current substring of the full recognition string. May be array of cached keys if GuiObjectVector is in EXTERNAL_PROCESSING_MODE.

govVector - -- the currently active GuiObjectVector.

govLevel - -- the hierarchy level (current substring)in the GuiObjectVector we are trying to satisfy.

objLevel - -- the depth in the actual application's object hierarchy currently being searched.

entry_classindices - -- the storage for class counts.

entry_typeindices - -- the storage for object type counts.

onlyOneChildVisible - -- true if parent is a TabControl-like component,

getMatchedGuiObject

public java.lang.Object getMatchedGuiObject()
Retrieves the final Object that satisfies the entire GuiObjectVector recognition string.

Returns:
valid Object if the recognition string was entirely satisfied.
null if it was not.