Class Operator
java.lang.Object
org.netbeans.jemmy.operators.Operator
- All Implemented Interfaces:
Outputable, Timeoutable
- Direct Known Subclasses:
ComponentOperator
Keeps all environment and low-level methods.
- Author:
- Alexandre Iline (alexandre.iline@sun.com)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface used to make component visible invalid input: '&' ready to to make operations with.static classUsed for parsing of path-like strings where path components are separated by a string-separator: "drive|directory|subdirectory|file".static classDefault StringComparator implementation.static classAllows to bind a compponent by a component type.protected classCan be used to simplify nonprimitive type component's methods mapping.protected classCan be used to simplify boolean component's methods mapping.protected classCan be used to simplify byte component's methods mapping.protected classCan be used to simplify char component's methods mapping.protected classCan be used to simplify double component's methods mapping.protected classCan be used to simplify float component's methods mapping.protected classCan be used to simplify int component's methods mapping.protected classCan be used to simplify long component's methods mapping.protected classCan be used to simplify void component's methods mapping.protected classCan be used to make nonblocking operation implementation.static interfaceUsed for parsing of path-like strings.static interfaceInterface to compare string resources like labels, button text, ... -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddOperatorPackage(String pkgName) Adds package to the list of packages containing operators.protected String[]Adds array of objects to dump hashtable.protected String[]Adds two dimentional array of objects to dump hashtable.voidcopyEnvironment(Operator anotherOperator) Copies all environment (output, timeouts, visualizer) from another operator.static ComponentOperatorcreateOperator(Component comp) Creates operator for component.Returns CharBindingMap used for keyboard operations.intgetCharKey(char c) Returns key code to be pressed for character typing.intgetCharModifiers(char c) Returns modifiers mask for character typing.int[]getCharsKeys(char[] c) Returns key codes to by pressed for characters typing.int[]Returns key codes to by pressed for the string typing.int[]getCharsModifiers(char[] c) Returns modifiers masks for characters typing.int[]Returns modifiers masks for the string typing.Returns object which is used for string comparison.static Operator.ComponentVisualizerReturns an object to be used by default to prepare component.static intReturns default mouse button mask.static Operator.PathParserReturns an object used for parsing of path-like strings.static Operator.StringComparatorReturns string comparator used to init operators.static booleanSays weither newly created operators perform operations verifications by default.getDump()Returns information about component.static OperatorReturns an operator containing default environment.Returns print output streams or writers.String[]getParentPath(String[] path) Creates new array which has all elements from first array, except last element.getParentPath(ComponentChooser[] path) Returns object which is used for parsing of path-like strings.static intReturns mask of mouse button which used to popup expanding.Returns a JemmyProperty object assigned to this operator.Returns QueueTool is used to work with queue.abstract ComponentReturns object operator is used for.Return current timeouts.booleanSays weither operator performs operation verifications.Returns component visualizer.booleanisCaptionEqual(String caption, String match) Compares string using getComparator StringComparator.static booleanisCaptionEqual(String caption, String match, boolean ce, boolean ccs) Deprecated.use another methods with the same name.static booleanisCaptionEqual(String caption, String match, Operator.StringComparator comparator) Compares caption (button text, window title, ...) with a sample text.protected voidEquivalent togetQueue().lock();.String[]parseString(String path) Parses a string to a string array using a PathParser assigned to this operator.String[]parseString(String path, String delim) Parses strings like "1|2|3" into arrays {"1", "2", "3"}.voidPrints component information into operator output.protected voidPerforms an operation without time control.protected voidproduceNoBlocking(Operator.NoBlockingAction action, Object param) Performs an operation without time control.protected ObjectproduceTimeRestricted(Action action, long wholeTime) Performs an operation with time control.protected ObjectproduceTimeRestricted(Action action, Object param, long wholeTime) Performs an operation with time control.protected ObjectrunMapping(Operator.MapAction action) To map nonprimitive type component's method.protected booleanrunMapping(Operator.MapBooleanAction action) To map boolean component's method.protected byterunMapping(Operator.MapByteAction action) To map byte component's method.protected charTo map char component's method.protected doublerunMapping(Operator.MapDoubleAction action) To map double component's method.protected floatrunMapping(Operator.MapFloatAction action) To map float component's method.protected intrunMapping(Operator.MapIntegerAction action) To map int component's method.protected longrunMapping(Operator.MapLongAction action) To map long component's method.protected voidrunMapping(Operator.MapVoidAction action) To map void component's method.voidDefines CharBindingMap.voidsetComparator(Operator.StringComparator comparator) Defines object which is used for string comparison.static Operator.ComponentVisualizerSpecifies an object to be used by default to prepare component.static Operator.PathParserSpecifies an object used for parsing of path-like strings.static Operator.StringComparatorsetDefaultStringComparator(Operator.StringComparator comparator) Defines string comparator to be assigned in constructor.static booleansetDefaultVerification(boolean verification) Defines weither newly created operators should perform operation verifications by default.voidDefines print output streams or writers.voidsetPathParser(Operator.PathParser parser) Specifies object which is used for parsing of path-like strings.setProperties(JemmyProperties properties) Assigns a JemmyProperty object to this operator.voidsetTimeouts(Timeouts timeouts) Defines current timeouts.booleansetVerification(boolean verification) Defines weither operator should perform operation verifications.voidChanges component visualizer.Returns toString() result from component of this operator.protected voidUnlocks Queue and then throw exception.protected voidEquivalent togetQueue().unlock();.voidwaitState(ComponentChooser state) Waits a state specified by a ComponentChooser instance.
-
Field Details
-
CLASS_DPROP
-
TO_STRING_DPROP
-
-
Constructor Details
-
Operator
public Operator()Inits environment.
-
-
Method Details
-
setDefaultComponentVisualizer
public static Operator.ComponentVisualizer setDefaultComponentVisualizer(Operator.ComponentVisualizer visualizer) Specifies an object to be used by default to prepare component. Each new operator created after the method using will have defined visualizer. Default implementation is org.netbeans.jemmy.util.DefaultVisualizer class.- Parameters:
visualizer- ComponentVisualizer implementation- Returns:
- previous value
- See Also:
-
getDefaultComponentVisualizer
Returns an object to be used by default to prepare component.- Returns:
- Object is used by default to prepare component
- See Also:
-
setDefaultStringComparator
public static Operator.StringComparator setDefaultStringComparator(Operator.StringComparator comparator) Defines string comparator to be assigned in constructor.- Parameters:
comparator- the comparator to be used by default.- Returns:
- previous value.
- See Also:
-
getDefaultStringComparator
Returns string comparator used to init operators.- Returns:
- the comparator used by default.
- See Also:
-
setDefaultPathParser
Specifies an object used for parsing of path-like strings.- Parameters:
parser- the parser.- Returns:
- a previous value.
- See Also:
-
getDefaultPathParser
Returns an object used for parsing of path-like strings.- Returns:
- a parser used by default.
- See Also:
-
setDefaultVerification
public static boolean setDefaultVerification(boolean verification) Defines weither newly created operators should perform operation verifications by default.- Parameters:
verification- a verification mode to be used by default.- Returns:
- a prevoius value.
- See Also:
-
getDefaultVerification
public static boolean getDefaultVerification()Says weither newly created operators perform operations verifications by default.- Returns:
- a verification mode used by default.
- See Also:
-
isCaptionEqual
Deprecated.use another methods with the same name.Compares caption (button text, window title, ...) with a sample text.- Parameters:
caption- String to be compared with match. Method returns false, if parameter is null.match- Sample to compare with. Method returns true, if parameter is null.ce- Compare exactly. If true, text can be a substring of caption.ccs- Compare case sensitively. If true, both text and caption are converted to upper case before comparison.- Returns:
- true is the captions matched the match.
- See Also:
-
isCaptionEqual
public static boolean isCaptionEqual(String caption, String match, Operator.StringComparator comparator) Compares caption (button text, window title, ...) with a sample text.- Parameters:
caption- String to be compared with matchmatch- Sample to compare withcomparator- StringComparator instance.- Returns:
- true is the captions matched the match.
- See Also:
-
getDefaultMouseButton
public static int getDefaultMouseButton()Returns default mouse button mask.- Returns:
InputEvent.BUTTON*_MASKfield value
-
getPopupMouseButton
public static int getPopupMouseButton()Returns mask of mouse button which used to popup expanding. (InputEvent.BUTTON3_MASK)- Returns:
InputEvent.BUTTON*_MASKfield value
-
createOperator
Creates operator for component. Tries to find class with "operator package"."class name"Operator name, where "operator package" is a package from operator packages list, and "class name" is the name of class or one of its superclasses.- Parameters:
comp- Component to create operator for.- Returns:
- a new operator with default environment.
- See Also:
-
addOperatorPackage
Adds package to the list of packages containing operators.
"org.netbeans.jemmy.operators" is in the list by default.- Parameters:
pkgName- Package name.- See Also:
-
getEnvironmentOperator
Returns an operator containing default environment.- Returns:
- an empty operator (not having any component source) having default environment.
-
getSource
Returns object operator is used for.- Returns:
- an instance of java.awt.Component subclass which this operator was created for.
-
getQueueTool
-
copyEnvironment
Copies all environment (output, timeouts, visualizer) from another operator.- Parameters:
anotherOperator- an operator to copy the environment to.
-
setTimeouts
Description copied from interface:TimeoutableDefines current timeouts.- Specified by:
setTimeoutsin interfaceTimeoutable- Parameters:
timeouts- A collection of timeout assignments.- See Also:
-
getTimeouts
Description copied from interface:TimeoutableReturn current timeouts.- Specified by:
getTimeoutsin interfaceTimeoutable- Returns:
- the collection of current timeout assignments.
- See Also:
-
getVisualizer
Returns component visualizer. Visualizer is used from from makeComponentVisible() method.- Returns:
- a visualizer assigned to this operator.
- See Also:
-
setVisualizer
Changes component visualizer. Visualizer is used from from makeComponentVisible() method.- Parameters:
vo- a visualizer to assign to this operator.- See Also:
-
getProperties
Returns a JemmyProperty object assigned to this operator.- Returns:
- a JemmyProperty object got from the top of property stack or from another operator by copyuing environment.
- See Also:
-
setProperties
Assigns a JemmyProperty object to this operator.- Parameters:
properties- a properties to assign to this operator.- Returns:
- previously assigned properties.
- See Also:
-
setCharBindingMap
Defines CharBindingMap.- Parameters:
map- a CharBindingMap to use for keyboard operations.- See Also:
-
getCharBindingMap
Returns CharBindingMap used for keyboard operations.- Returns:
- a map assigned to this object.
- See Also:
-
setOutput
Description copied from interface:OutputableDefines print output streams or writers.- Specified by:
setOutputin interfaceOutputable- Parameters:
out- Identify the streams or writers used for print output.- See Also:
-
getOutput
Description copied from interface:OutputableReturns print output streams or writers.- Specified by:
getOutputin interfaceOutputable- Returns:
- an object that contains references to objects for printing to output and err streams.
- See Also:
-
getComparator
Returns object which is used for string comparison.- Returns:
- a comparator assigned to this operator.
- See Also:
-
setComparator
Defines object which is used for string comparison.- Parameters:
comparator- a comparator to use for string comparision.- See Also:
-
getPathParser
Returns object which is used for parsing of path-like strings.- Returns:
- a comparator assigned to this operator.
- See Also:
-
setPathParser
Specifies object which is used for parsing of path-like strings.- Parameters:
parser- a parser to use for path parsing.- See Also:
-
setVerification
public boolean setVerification(boolean verification) Defines weither operator should perform operation verifications.- Parameters:
verification- new value.- Returns:
- old value
- See Also:
-
getVerification
public boolean getVerification()Says weither operator performs operation verifications.- Returns:
- old value
- See Also:
-
getParentPath
-
getParentPath
-
parseString
-
parseString
-
getCharKey
public int getCharKey(char c) Returns key code to be pressed for character typing.- Parameters:
c- Character to be typed.- Returns:
- a value of one of the
KeyEvent.VK_*fields. - See Also:
-
getCharModifiers
public int getCharModifiers(char c) Returns modifiers mask for character typing.- Parameters:
c- Character to be typed.- Returns:
- a combination of
InputEvent.*_MASKfields. - See Also:
-
getCharsKeys
public int[] getCharsKeys(char[] c) Returns key codes to by pressed for characters typing.- Parameters:
c- Characters to be typed.- Returns:
- an array of
KeyEvent.VK_*values. - See Also:
-
getCharsModifiers
public int[] getCharsModifiers(char[] c) Returns modifiers masks for characters typing.- Parameters:
c- Characters to be typed.- Returns:
- an array of a combination of
InputEvent.*_MASKfields. - See Also:
-
getCharsKeys
Returns key codes to by pressed for the string typing.- Parameters:
s- String to be typed.- Returns:
- an array of
KeyEvent.VK_*values. - See Also:
-
getCharsModifiers
Returns modifiers masks for the string typing.- Parameters:
s- String to be typed.- Returns:
- an array of a combination of
InputEvent.*_MASKfields. - See Also:
-
isCaptionEqual
-
printDump
public void printDump()Prints component information into operator output. -
getDump
Returns information about component. All records marked by simbolic constants defined in public static final*_DPROPfields for each operator type.- Returns:
- a Hashtable containing name-value pairs.
-
waitState
Waits a state specified by a ComponentChooser instance.- Parameters:
state- a ComponentChooser defining the state criteria.- Throws:
TimeoutExpiredException- if the state has not achieved in a value defined by"ComponentOperator.WaitStateTimeout"
-
produceTimeRestricted
-
produceTimeRestricted
-
produceNoBlocking
Performs an operation without time control.- Parameters:
action- an action to execute.param- an action parameters.
-
produceNoBlocking
Performs an operation without time control.- Parameters:
action- an action to execute.
-
lockQueue
protected void lockQueue()Equivalent togetQueue().lock();. -
unlockQueue
protected void unlockQueue()Equivalent togetQueue().unlock();. -
unlockAndThrow
Unlocks Queue and then throw exception.- Parameters:
e- an exception to be thrown.
-
runMapping
To map nonprimitive type component's method.- Parameters:
action- a mapping action.- Returns:
- an action result.
- See Also:
-
runMapping
To map char component's method.- Parameters:
action- a mapping action.- Returns:
- an action result.
- See Also:
-
runMapping
To map byte component's method.- Parameters:
action- a mapping action.- Returns:
- an action result.
- See Also:
-
runMapping
To map int component's method.- Parameters:
action- a mapping action.- Returns:
- an action result.
- See Also:
-
runMapping
To map long component's method.- Parameters:
action- a mapping action.- Returns:
- an action result.
- See Also:
-
runMapping
To map float component's method.- Parameters:
action- a mapping action.- Returns:
- an action result.
- See Also:
-
runMapping
To map double component's method.- Parameters:
action- a mapping action.- Returns:
- an action result.
- See Also:
-
runMapping
To map boolean component's method.- Parameters:
action- a mapping action.- Returns:
- an action result.
- See Also:
-
runMapping
To map void component's method.- Parameters:
action- a mapping action.- See Also:
-
addToDump
Adds array of objects to dump hashtable. Is used for multiple properties such as list items and tree nodes.- Parameters:
table- a table to add properties to.title- property names prefix. Property names are constructed by adding a number to the prefix:title + "_" + Iteger.toString("ordinal index")items- an array of property values.- Returns:
- an array of property names (with added numbers).
-
addToDump
Adds two dimentional array of objects to dump hashtable. Is used for multiple properties such as table cells.- Parameters:
table- a table to add properties to.title- property names prefix. Property names are constructed by adding two numbers to the prefix:title + "_" + Iteger.toString("row index") + "_" + Iteger.toString("column index")items- an array of property values.- Returns:
- an array of property names (with added numbers).
-
toStringSource
Returns toString() result from component of this operator. It callsgetSource().toString() in dispatch thread.- Returns:
- toString() result from component of this operator.
-