org.safs.rational
Class ProcessContainer

java.lang.Object
  extended by org.safs.rational.ProcessContainer

public class ProcessContainer
extends java.lang.Object

ProcessContainer is used to deduce recognition string information using the RobotJ API for objects like DomainTestObject and TestObject. Internally, ProcessContainer also relies on the general-purpose org.safs.PCTree object to correctly produce recognition matching that used for all SAFS-Engine tools using the SAFS algorithms for locating components.

Since:
MAY 08, 2003
MAY 08, 2003 (CNagle) Original Release
OCT 09, 2003 (DBauman) Reformatting, refactoring, commenting
OCT 31, 2003 (DBauman) now accept parameter 'withCommentsAndBlankLines' to space out the output a bit.
NOV 12, 2003 (DBauman) modifying such that if a component is a container and is invisible, then ignore
SEP 02, 2004 (CANAGL) Do not seek children in comboboxes
SEP 20, 2005 (CANAGL) Many enhancements for Functional Tester and object recognition in general.
See Also:
PCTree

Field Summary
static java.lang.String INDENT
           
static java.lang.String pathSep
           
 
Constructor Summary
ProcessContainer(DomainTestObject[] domains)
          Simplified constructor, takes array of DomainTestObject as the starting point, opens preset filename for write, then calls processDomain(domains[i]) for each domains[i] in the passed array, finally closes the output file.
ProcessContainer(DomainTestObject[] domains, java.lang.String filename, boolean withCommentsAndBlankLines)
          Intermediate constructor, takes array of DomainTestObject as the starting point, opens filename for write, then calls processDomain(domains[i]) for each domains[i] in the passed array, finally closes the file.
ProcessContainer(DomainTestObject[] domains, java.lang.String filename, boolean verbose, boolean iniVsTreeFormat, boolean withNameIncludeOnlyCaption, boolean withCommentsAndBlankLines, boolean ignoreInvisibleComponents, boolean append)
          Detailed constructor, takes array of DomainTestObject as the starting point, opens filename for write, then calls processDomain(domains[i]) for each domains[i] in the passed array, finally closes the file.
ProcessContainer(TestObject container, java.lang.String filename)
          Intermediate constructor, takes a TestObject as the starting point, opens filename for write, then calls processContainer(container), finally closes the file.
 
Method Summary
protected  void closeWriter(java.io.Writer writer)
          Closes the passed writer.
protected  java.lang.String genRecogString(PCTree pctree, TestObject container, java.util.Map properties, java.lang.String parentText)
          Used internally.
static boolean getAppendMode()
           
static boolean getIgnoreInvisibleComponents()
           
static boolean getIgnoreInvisibleTabPanes()
           
static boolean getINITreeFormat()
           
protected  java.lang.String getMappedClassType(TestObject tobj, java.lang.String objectClassName)
          Used internally.
static java.lang.String getRootFilename()
           
static boolean getShortenGeneralRecognition()
           
static boolean getShortenNamedRecognition()
           
static boolean getShowCommentsAndBlankLines()
           
static boolean getShowMethods()
           
static boolean getShowProperties()
           
static boolean getVerbose()
           
protected  java.lang.String makeName(java.lang.String text, java.lang.String compType)
          Used internally.
protected  java.io.Writer openWriter(java.lang.String filename, boolean append)
          Opens a new BufferedWriter(FileWriter(filename)).
protected  PCTree processChildren(TestObject[] children, java.lang.String parentText, PCTree parent)
          Used internally.
 PCTree processContainer(TestObject container, java.lang.String parentText, PCTree parent)
          Entry point to process a domain or object container.
protected  PCTree processDomain(DomainTestObject domain, PCTree parent)
          Used internally.
protected  PCTree processObjectContainer(TestObject container, java.lang.String parentText, PCTree parent)
          Used internally.
static void setAppendMode(boolean set)
          Set the status of the 'append' flag.
static void setIgnoreInvisibleComponents(boolean set)
          Set the status of the 'ignoreInvisibleComponents' flag.
static void setIgnoreInvisibleTabPanes(boolean set)
          Set the status of the 'ignoreInvisibleTabPanes' flag.
static void setINITreeFormat(boolean set)
          Set the status of the 'iniVsTreeFormat' flag.
static void setRootFilename(java.lang.String file)
          Set the current value of the 'rootFileName' String.
static void setShortenGeneralRecognition(boolean set)
          Set the status of the 'shortenGeneralRecognition' flag.
static void setShortenNamedRecognition(boolean set)
          Set the status of the 'withNameIncludeOnlyCaption' flag.
static void setShowCommentsAndBlankLines(boolean set)
          Set the status of the 'withCommentsAndBlankLines' flag.
static void setShowMethods(boolean show)
          Set the status of the 'showMethods' flag.
static void setShowProperties(boolean show)
          Set the status of the 'showProperties' flag.
static void setVerbose(boolean set)
          Set the status of the 'verbose' flag.
protected  void write(java.lang.String data)
          Writes String data to the writer ONLY if verbose is true.
protected  void writeMethods(MethodInfo[] methods)
          Write the methods info provided.
protected  void writeNewLine(java.io.Writer writer)
          Write a new line to the passed 'writer'
protected  void writeProperties(java.lang.String propType, java.util.Map properties)
          Write the passed property type line(propType) and then the values of the 'properties' The routine will not write the properties out if showProperties is false.
protected  void writeRaw(java.lang.String data)
          Write the raw data to the open writer.
protected  void writeState(TestObject container)
          Write the isEnabled and isShowing states of the 'container'
protected  void writeTree(PCTree tree)
          Write the PCTree data to the writer.
protected  void writeTreeXML(java.lang.String xmlfile, PCTree tree)
          Output the PCTree data in XML format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDENT

public static final java.lang.String INDENT
See Also:
Constant Field Values

pathSep

public static final java.lang.String pathSep
See Also:
Constant Field Values
Constructor Detail

ProcessContainer

public ProcessContainer(DomainTestObject[] domains)
Simplified constructor, takes array of DomainTestObject as the starting point, opens preset filename for write, then calls processDomain(domains[i]) for each domains[i] in the passed array, finally closes the output file.

This constructor is typically called after many of the static methods have been used to set operating criteria.

Parameters:
DomainTestObject[] - domains

ProcessContainer

public ProcessContainer(DomainTestObject[] domains,
                        java.lang.String filename,
                        boolean withCommentsAndBlankLines)
Intermediate constructor, takes array of DomainTestObject as the starting point, opens filename for write, then calls processDomain(domains[i]) for each domains[i] in the passed array, finally closes the file.

The settings provided by other constructors can also be preset through static method calls prior to calling this constructor.

Parameters:
domains, - DomainTestObject[]
filename, - String
withCommentsAndBlankLines, - boolean

ProcessContainer

public ProcessContainer(DomainTestObject[] domains,
                        java.lang.String filename,
                        boolean verbose,
                        boolean iniVsTreeFormat,
                        boolean withNameIncludeOnlyCaption,
                        boolean withCommentsAndBlankLines,
                        boolean ignoreInvisibleComponents,
                        boolean append)
Detailed constructor, takes array of DomainTestObject as the starting point, opens filename for write, then calls processDomain(domains[i]) for each domains[i] in the passed array, finally closes the file.

Parameters:
domains, - DomainTestObject[]
filename, - String
verbose, - boolean, puts out more info if true
iniVsTreeFormat, - boolean, if true then ini format, else tree
withNameIncludeOnlyCaption, - if false, include full recog string
withCommentsAndBlankLines, - boolean
ignoreInvisibleComponents, - boolean
append, - boolean

ProcessContainer

public ProcessContainer(TestObject container,
                        java.lang.String filename)
Intermediate constructor, takes a TestObject as the starting point, opens filename for write, then calls processContainer(container), finally closes the file.

The settings provided by other constructors can also be preset through static calls to the ProcessContainer.setXXX methods.

Parameters:
container, - TestObject
filename, - String
Method Detail

processDomain

protected PCTree processDomain(DomainTestObject domain,
                               PCTree parent)
Used internally. Called by either the constructor or used in recursion to process a domain.

Parameters:
domain, - DomainTestObject
parent, - PCTree passed along to processChildren
See Also:
processChildren(TestObject[], String, PCTree)

processContainer

public PCTree processContainer(TestObject container,
                               java.lang.String parentText,
                               PCTree parent)
Entry point to process a domain or object container. This routine will appropriately call either processDomain or processObjectContainer depending on which type the 'container' is.

Parameters:
container, - TestObject
parentText, - String, for menus, it is the path of our parent
See Also:
processDomain(DomainTestObject, PCTree), processObjectContainer(TestObject, String, PCTree)

processObjectContainer

protected PCTree processObjectContainer(TestObject container,
                                        java.lang.String parentText,
                                        PCTree parent)
Used internally. Entry point called from 'processContainer' to process a component\container. Process the TestObject container, and recursively, all of it's children through 'processChildren'.

Parameters:
container, - TestObject
parentText, - String, for menus, it is the path of our parent
SEP 02, 2004 (CANAGL) Do not seek children in comboboxes
See Also:
processChildren(TestObject[], String, PCTree)

processChildren

protected PCTree processChildren(TestObject[] children,
                                 java.lang.String parentText,
                                 PCTree parent)
Used internally. Essentially, processContainer(children[i]) for all children and handling parent, child, and sibling relationships.

Parameters:
children, - TestObject[] (can be null)
parentText, - String, typically for menus, it is the Path of our parent
pctree - PCTree, keeps the recognition string info, will be written
Returns:
firstpctree (the first PCTree generated for the children)
See Also:
processContainer(TestObject, String, PCTree)

getMappedClassType

protected java.lang.String getMappedClassType(TestObject tobj,
                                              java.lang.String objectClassName)
Used internally. Get the mapped class type (ultimately from something like JavaObjectsMap.dat) This is the derived "Window", "CheckBox", or "EditBox" class type for the given classname.

Parameters:
tobj, - TestObject
objectClassName, - String
Returns:
String, null if not found

genRecogString

protected java.lang.String genRecogString(PCTree pctree,
                                          TestObject container,
                                          java.util.Map properties,
                                          java.lang.String parentText)
Used internally. Generate the recognition string for this object. This does not include any parent hierarchy information. Only the portion of the recognition string that applies to this component.

Parameters:
pctree - PCTree, keeps the rcognition string info, will be written
container, - TestObject
properties, - Map
parentText, - String, for menus, it is the path of our parent
Returns:
Text/Name/Caption/Path property value if it exists, else null

makeName

protected java.lang.String makeName(java.lang.String text,
                                    java.lang.String compType)
Used internally. Creates a (unique) name based on the 'text', or if no text, then the 'compType'; If the name already exists in our nameMap then we append an index after the name to make it unique.

Parameters:
text, - String
compType, - String
Returns:
String, the comp name generated

writeProperties

protected void writeProperties(java.lang.String propType,
                               java.util.Map properties)
Write the passed property type line(propType) and then the values of the 'properties' The routine will not write the properties out if showProperties is false.

Parameters:
propType, - String simple description of the types of properties processed.
properties, - Map (can be null)
See Also:
showProperties, getShowProperties()

writeMethods

protected void writeMethods(MethodInfo[] methods)
Write the methods info provided. The routine will not write out if showMethods is false.

Parameters:
methods, - MethodInfo[] (can be null)
See Also:
showMethods, getShowMethods()

writeState

protected void writeState(TestObject container)
Write the isEnabled and isShowing states of the 'container'

Parameters:
container, - TestObject (can be null)

write

protected void write(java.lang.String data)
Writes String data to the writer ONLY if verbose is true.

Parameters:
data, - String
See Also:
verbose, getVerbose()

writeTree

protected void writeTree(PCTree tree)
Write the PCTree data to the writer. If iniVsTreeFormat is true uses the toIniString method. Otherwise uses the normal toString method.

Parameters:
tree, - PCTree
See Also:
iniVsTreeFormat, getINITreeFormat(), PCTree.toIniString(), PCTree.toString()

writeTreeXML

protected void writeTreeXML(java.lang.String xmlfile,
                            PCTree tree)
Output the PCTree data in XML format.

Parameters:
xmlfile, - String filename for output
tree, - PCTree to output in XML encoded format
See Also:
XMLEncoderDecoder.xmlEncode(Serializable)

writeRaw

protected void writeRaw(java.lang.String data)
Write the raw data to the open writer.

Parameters:
data, - String

writeNewLine

protected void writeNewLine(java.io.Writer writer)
                     throws java.io.IOException
Write a new line to the passed 'writer'

Parameters:
writer, - Writer
Throws:
java.io.IOException - Writer pass-thru

closeWriter

protected void closeWriter(java.io.Writer writer)
Closes the passed writer.

Parameters:
writer, - Writer

openWriter

protected java.io.Writer openWriter(java.lang.String filename,
                                    boolean append)
Opens a new BufferedWriter(FileWriter(filename)).

Parameters:
filename, - String
append, - boolean true if file is to be opened in Append mode.
Returns:
Writer, may be null if unsuccessful.

getShowMethods

public static boolean getShowMethods()
Returns:
the status of the 'showMethods' flag.
See Also:
showMethods

setShowMethods

public static void setShowMethods(boolean show)
Set the status of the 'showMethods' flag.

See Also:
showMethods

getShowProperties

public static boolean getShowProperties()
Returns:
the status of the 'showProperties' flag.
See Also:
showProperties

setShowProperties

public static void setShowProperties(boolean show)
Set the status of the 'showProperties' flag.

See Also:
showProperties

getVerbose

public static boolean getVerbose()
Returns:
the status of the 'verbose' flag.
See Also:
verbose

setVerbose

public static void setVerbose(boolean set)
Set the status of the 'verbose' flag.

See Also:
verbose

getINITreeFormat

public static boolean getINITreeFormat()
Returns:
the status of the 'iniVsTreeFormat' flag.
See Also:
iniVsTreeFormat

setINITreeFormat

public static void setINITreeFormat(boolean set)
Set the status of the 'iniVsTreeFormat' flag.

See Also:
iniVsTreeFormat

getShortenNamedRecognition

public static boolean getShortenNamedRecognition()
Returns:
the status of the 'withNameIncludeOnlyCaption' flag.
See Also:
withNameIncludeOnlyCaption

setShortenNamedRecognition

public static void setShortenNamedRecognition(boolean set)
Set the status of the 'withNameIncludeOnlyCaption' flag.

See Also:
withNameIncludeOnlyCaption

getShortenGeneralRecognition

public static boolean getShortenGeneralRecognition()
Returns:
the status of the 'shortenGeneralRecognition' flag.
See Also:
shortenGeneralRecognition

setShortenGeneralRecognition

public static void setShortenGeneralRecognition(boolean set)
Set the status of the 'shortenGeneralRecognition' flag.

See Also:
shortenGeneralRecognition

getShowCommentsAndBlankLines

public static boolean getShowCommentsAndBlankLines()
Returns:
the status of the 'withCommentsAndBlankLines' flag.
See Also:
withCommentsAndBlankLines

setShowCommentsAndBlankLines

public static void setShowCommentsAndBlankLines(boolean set)
Set the status of the 'withCommentsAndBlankLines' flag.

See Also:
withCommentsAndBlankLines

getIgnoreInvisibleComponents

public static boolean getIgnoreInvisibleComponents()
Returns:
the status of the 'ignoreInvisibleComponents' flag.
See Also:
ignoreInvisibleComponents

setIgnoreInvisibleComponents

public static void setIgnoreInvisibleComponents(boolean set)
Set the status of the 'ignoreInvisibleComponents' flag.

See Also:
ignoreInvisibleComponents

getIgnoreInvisibleTabPanes

public static boolean getIgnoreInvisibleTabPanes()
Returns:
the status of the 'ignoreInvisibleTabPanes' flag.
See Also:
ignoreInvisibleTabPanes

setIgnoreInvisibleTabPanes

public static void setIgnoreInvisibleTabPanes(boolean set)
Set the status of the 'ignoreInvisibleTabPanes' flag.

See Also:
ignoreInvisibleTabPanes

getAppendMode

public static boolean getAppendMode()
Returns:
the status of the 'append' flag.
See Also:
append

setAppendMode

public static void setAppendMode(boolean set)
Set the status of the 'append' flag.

See Also:
append

getRootFilename

public static java.lang.String getRootFilename()
Returns:
the current value of the 'rootFileName' String.
See Also:
rootFileName

setRootFilename

public static void setRootFilename(java.lang.String file)
Set the current value of the 'rootFileName' String.

See Also:
rootFileName