Package com.rs.seagull.emulator.api
Class Conditions
java.lang.Object
com.rs.seagull.emulator.api.Conditions
Static methods for creating various common Conditions. Note that
most Conditions are only useful as a parameter to BareSession.waitFor,
not as a 'standalone' object. If the creation method takes a session
object as a parameter, then the Condition can be used 'standalone'.
- Version:
- $Id$
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.apache.logging.log4j.Logger
The logger forConditions
-
Method Summary
Modifier and TypeMethodDescriptionstatic Condition
Returns a Condition that is always false.static Condition
Returns a Condition that is always true.static Condition
Returns a Condition that is true when two other conditions are both true.static Condition
cancelInviteCount
(int delta) Returns a Conditions that is true when the CancelInviteCount property has incremented the given number of times.static Condition
cancelInviteCountAbsolute
(long newValue) Returns a Conditions that is true when the CancelInviteCount property has become the provided count.static Condition
changeCount
(int delta) Returns a Conditions that is true when the ChangeCount property has incremented the given number of times.static Condition
changeCount
(BareSession session, int delta) Returns a Conditions that is true when the ChangeCount property has incremented the given number of times.static Condition
changeCountAbsolute
(long newValue) Returns a Conditions that is true when the ChangeCount property has incremented to a new value.static Condition
cursorAt
(BareScreen screen, com.seagullsw.common.toolbox.geometry.Point point) Returns a Condition that is true when the cursor is at a particular screen location.static Condition
cursorAt
(com.seagullsw.common.toolbox.geometry.Point point) Returns a Condition that is true when the cursor is at a particular screen location.static Condition
cursorIn
(BareScreen screen, com.seagullsw.common.toolbox.geometry.Rectangle area) Returns a Condition that is true when the cursor is in a particular screen area.static Condition
Returns a Condition that is true when the cursor is in a particular field.static Condition
Returns a Condition that is true when the cursor is in a particular subfield of a multi-line or column field.static Condition
cursorIn
(com.seagullsw.common.toolbox.geometry.Rectangle area) Returns a Condition that is true when the cursor is in a particular screen area.static Condition
Returns a Condition that is true when the cursor is in a particular field.static Condition
Returns a Condition that is true when the cursor is in a particular subfield of a multi-line or column field.static Condition
Returns a Condition that is true when the cursor is visible.static Condition
cursorIsVisible
(BareScreen screen) Returns a Condition that is true when the cursor is visible.static Condition
Returns a Condition that is true whenever the cursor has moved.static Condition
Returns a Condition that is true when the given field contains the given data value.static Condition
Returns a Condition that is true when the given rectangle contains the given data value.static Condition
Returns a Condition that is true when the given field contains the given data value.static Condition
emulatorState
(BareScreen screen, com.seagullsw.common.emulator.physical.base.screen.EmulatorState emulatorState) Returns a Condition that is true when the emulator's state equals the provided emulator state.static Condition
emulatorState
(com.seagullsw.common.emulator.physical.base.screen.EmulatorState emulatorState) Returns a Condition that is true when the emulator's state equals the provided emulator state.static Condition
emulatorState
(com.seagullsw.common.emulator.physical.base.screen.EmulatorState emulatorState, boolean includeChangeCount) Returns a Condition that is true when the emulator's state equals the provided emulator state.static Condition
Deprecated.Use the inputReady or emulatorState conditionstatic Condition
inputInhibitDown
(BareScreen screen) Deprecated.Use the inputReady or emulatorState conditionstatic Condition
Returns a Condition that is true when the session is ready for input.static Condition
inputReady
(BareSession session) Returns a Condition that is true when the session is ready for input.static Condition
keyboardRestoreCountAtLeast
(int value) Returns a Condition that is true when the 3270-style keyboard restore count is greater or equals to a particular value.static Condition
keyboardRestoreCountEquals
(int value) Returns a Condition that is true when the 3270-style keyboard restore count equals a particular value.static Condition
keyboardRestoreCountEquals
(BareScreen screen, int value) Returns a Condition that is true when the 3270-style keyboard restore count equals a particular value.static Condition
lineContains
(int line, String string) Returns a Condition that is true when the screen contains a particular string anywhere on a particular line (zero-based).static Condition
Returns a Condition that is true when the given condition is false.static Condition
Returns a Condition that is true when either of two other conditions are true.static Condition
screenContains
(String string) Returns a Condition that is true when the screen contains a particular string anywhere on the screen.static Condition
Returns a Condition that is true when the current screen is identified.static Condition
screenNamed
(Session session, String screenName) Returns a Condition that is true when the current screen name matches the given name.static Condition
screenNamed
(Session session, List<String> screenNames) Returns a Condition that is true when the current screen name matches any one of a given list of names.static Condition
screenNamed
(String screenName) Returns a Condition that is true when the current screen name does not match the given name.static Condition
screenNamed
(String... screenNames) Returns a Condition that is true when the current screen name matches any one of a given list of names.static Condition
screenNamed
(List<String> screenNames) Returns a Condition that is true when the current screen name matches any one of a given list of names.static Condition
screenNotNamed
(String screenName) Returns a Condition that is true when the current screen name matches the given name.static Condition
stringAtEquals
(com.seagullsw.common.toolbox.geometry.Point aPoint, int length, String value) Returns a Condition that is true when the screen contains a particular value at a particular location.static Condition
stringBeforeCursorEquals
(String value) Returns a Condition that is true when the screen contents just to the left of the cursor match a given value.
-
Field Details
-
LOG
public static final org.apache.logging.log4j.Logger LOGThe logger forConditions
-
-
Method Details
-
inputInhibitDown
@Deprecated public static Condition inputInhibitDown(BareScreen screen) throws UnsupportedOperationException Deprecated.Use the inputReady or emulatorState conditionReturns a Condition that is true when the InputInhibit flag is false.- Parameters:
screen
- the screen for which to check the InputInhibit flag- Returns:
- a Condition that is true when the InputInhibit flag is false.
- Throws:
UnsupportedOperationException
- when the emulator does not support the input inhibit flag
-
inputInhibitDown
Deprecated.Use the inputReady or emulatorState conditionReturns a Condition that is true when the InputInhibit flag is false.- Returns:
- a Condition that is true when the InputInhibit flag is false.
- Throws:
UnsupportedOperationException
- when the emulator does not support the input inhibit flag
-
cursorAt
public static Condition cursorAt(BareScreen screen, com.seagullsw.common.toolbox.geometry.Point point) Returns a Condition that is true when the cursor is at a particular screen location.- Parameters:
screen
- the screen for which to check the cursor positionpoint
- the screen coordinate that the cursor needs to be at for the condition to return true.- Returns:
- a Condition that is true when the cursor is at a particular screen location.
-
cursorAt
Returns a Condition that is true when the cursor is at a particular screen location.- Parameters:
point
- the screen coordinate that the cursor needs to be at for the condition to return true.- Returns:
- a Condition that is true when the cursor is at a particular screen location.
-
cursorMoved
Returns a Condition that is true whenever the cursor has moved.- Returns:
- a Condition that is true whenever the cursor has noved.
-
cursorIn
public static Condition cursorIn(BareScreen screen, com.seagullsw.common.toolbox.geometry.Rectangle area) Returns a Condition that is true when the cursor is in a particular screen area.- Parameters:
screen
- the screen for which to check the cursor positionarea
- the screen area that the cursor needs to be in for the condition to return true.- Returns:
- a Condition that is true when the cursor is in a particular screen area.
-
cursorIn
Returns a Condition that is true when the cursor is in a particular screen area.- Parameters:
area
- the screen area that the cursor needs to be in for the condition to return true.- Returns:
- a Condition that is true when the cursor is in a particular screen area.
-
cursorIn
Returns a Condition that is true when the cursor is in a particular field.- Parameters:
session
- the session for which to check the cursor positionfieldName
- the name of the field that the cursor needs to be in for the condition to return true.- Returns:
- a Condition that is true when the cursor is in a particular field.
-
cursorIn
Returns a Condition that is true when the cursor is in a particular field.- Parameters:
fieldName
- the name of the field that the cursor needs to be in for the condition to return true.- Returns:
- a Condition that is true when the cursor is in a particular field.
-
dataIn
Returns a Condition that is true when the given field contains the given data value.- Parameters:
session
- the session for which to check the field data.fieldName
- the name of the field that the data needs to be in for the condition to return true.data
- the value the field must contain.- Returns:
- a Condition that is true when the given data is in the given field.
-
dataIn
Returns a Condition that is true when the given field contains the given data value.- Parameters:
fieldName
- the name of the field that the data needs to be in for the condition to return true.data
- the value the field must contain.- Returns:
- a Condition that is true when the given data is in the given field.
-
dataIn
Returns a Condition that is true when the given rectangle contains the given data value.- Parameters:
area
- the rectangle that the data needs to be in for the condition to return true.data
- the value the field must contain.- Returns:
- a Condition that is true when the given data is in the given rectangle.
-
cursorIn
Returns a Condition that is true when the cursor is in a particular subfield of a multi-line or column field.- Parameters:
session
- the session for which to check the cursor positionfieldName
- the name of the field that the cursor needs to be in for the condition to return true.index
- the (zero-based) line within the field- Returns:
- a Condition that is true when the cursor is in a particular field.
-
cursorIn
Returns a Condition that is true when the cursor is in a particular subfield of a multi-line or column field.- Parameters:
fieldName
- the name of the field that the cursor needs to be in for the condition to return true.index
- the (zero-based) line within the field- Returns:
- a Condition that is true when the cursor is in a particular field.
-
cursorIsVisible
Returns a Condition that is true when the cursor is visible.- Parameters:
screen
- the screen for which to check is the cursor is visible- Returns:
- a Condition that is true when the cursor is visible.
-
cursorIsVisible
Returns a Condition that is true when the cursor is visible.- Returns:
- a Condition that is true when the cursor is visible.
-
keyboardRestoreCountEquals
Returns a Condition that is true when the 3270-style keyboard restore count equals a particular value.- Parameters:
screen
- the screen for which to check the keyboard restore countvalue
- the provided value- Returns:
- a Condition that is true when the 3270-style keyboard restore count equals a particular value.
-
keyboardRestoreCountEquals
Returns a Condition that is true when the 3270-style keyboard restore count equals a particular value.- Parameters:
value
- the provided value- Returns:
- a Condition that is true when the 3270-style keyboard restore count equals a particular value.
-
keyboardRestoreCountAtLeast
Returns a Condition that is true when the 3270-style keyboard restore count is greater or equals to a particular value.- Parameters:
value
- the provided value- Returns:
- a Condition that is true when the 3270-style keyboard restore count is greater or equals a particular value.
-
stringAtEquals
public static Condition stringAtEquals(com.seagullsw.common.toolbox.geometry.Point aPoint, int length, String value) Returns a Condition that is true when the screen contains a particular value at a particular location.- Parameters:
aPoint
- the screen location to read from.length
- the number of characters to read.value
- the value to match to the screen contents.- Returns:
- a Condition that is true when the screen contains a particular value at a particular location.
-
and
Returns a Condition that is true when two other conditions are both true.- Parameters:
c1
- condition 1c2
- condition 2- Returns:
- a Condition that is true when two other conditions are both true.
-
or
Returns a Condition that is true when either of two other conditions are true.- Parameters:
c1
- condition 1c2
- condition 2- Returns:
- a Condition that is true when either of two other conditions are true.
-
not
Returns a Condition that is true when the given condition is false.- Parameters:
condition
- the given condition- Returns:
- a Condition that is true when the given condition is false.
-
stringBeforeCursorEquals
Returns a Condition that is true when the screen contents just to the left of the cursor match a given value. Case is ignored.- Parameters:
value
- the value to match.- Returns:
- a Condition that is true when the screen contents just to the left of the cursor match a given value.
-
changeCount
Returns a Conditions that is true when the ChangeCount property has incremented the given number of times.- Parameters:
session
- the session for which to check the change countdelta
- the number of times the ChangeCount property must increment.- Returns:
- a Conditions that is true when the ChangeCount property has incremented the given number of times.
-
changeCount
Returns a Conditions that is true when the ChangeCount property has incremented the given number of times.- Parameters:
delta
- the number of times the ChangeCount property must increment.- Returns:
- a Conditions that is true when the ChangeCount property has incremented the given number of times.
-
changeCountAbsolute
Returns a Conditions that is true when the ChangeCount property has incremented to a new value.- Parameters:
newValue
- the value to increment to.- Returns:
- a Conditions that is true when the ChangeCount property has incremented to a new value.
-
cancelInviteCount
Returns a Conditions that is true when the CancelInviteCount property has incremented the given number of times.- Parameters:
delta
- the number of times the CancelInviteCount property must increment.- Returns:
- a Conditions that is true when the CancelInviteCount property has incremented the given number of times.
-
cancelInviteCountAbsolute
Returns a Conditions that is true when the CancelInviteCount property has become the provided count.- Parameters:
newValue
- the provided count- Returns:
- a Conditions that is true when the CancelInviteCount property has become the provided count.
-
alwaysFalse
Returns a Condition that is always false. Useful for doing an ordinary 'pause' since it will always timeout.- Returns:
- a Condition that is always false.
-
alwaysTrue
Returns a Condition that is always true. Useful for...not sure what... but surely something.- Returns:
- a Condition that is always true.
-
screenNamed
Returns a Condition that is true when the current screen name matches the given name.- Parameters:
session
- the session for which to check the screen namescreenName
- the screen name to match.- Returns:
- a Condition that is true when the current screen name matches the given name.
-
screenNamed
Returns a Condition that is true when the current screen name does not match the given name.- Parameters:
screenName
- the screen name not to match.- Returns:
- a Condition that is true when the current screen name does not match the given name.
-
screenNotNamed
Returns a Condition that is true when the current screen name matches the given name.- Parameters:
screenName
- the screen name to match.- Returns:
- a Condition that is true when the current screen name matches the given name.
-
screenNamed
Returns a Condition that is true when the current screen name matches any one of a given list of names.- Parameters:
screenNames
- the list of possible screen names to match.- Returns:
- a Condition that is true when the current screen name matches any one of a given list of names.
-
screenNamed
Returns a Condition that is true when the current screen name matches any one of a given list of names.- Parameters:
session
- the session for which to check the screen namesscreenNames
- the list of possible screen names to match.- Returns:
- a Condition that is true when the current screen name matches any one of a given list of names.
-
screenNamed
Returns a Condition that is true when the current screen name matches any one of a given list of names.- Parameters:
screenNames
- the list of possible screen names to match.- Returns:
- a Condition that is true when the current screen name matches any one of a given list of names.
-
screenIdentified
Returns a Condition that is true when the current screen is identified.- Returns:
- a Condition that is true when the current screen is identified.
-
screenContains
Returns a Condition that is true when the screen contains a particular string anywhere on the screen.- Parameters:
string
- the value to match to the screen contents.- Returns:
- a Condition that is true when the screen contains a particular string anywhere on the screen.
-
lineContains
Returns a Condition that is true when the screen contains a particular string anywhere on a particular line (zero-based).- Parameters:
line
- the line number to search on (zero-based).string
- the value to match to the line contents.- Returns:
- a Condition that is true when the screen contains a particular string anywhere on a particular line.
-
emulatorState
public static Condition emulatorState(BareScreen screen, com.seagullsw.common.emulator.physical.base.screen.EmulatorState emulatorState) throws UnsupportedOperationException Returns a Condition that is true when the emulator's state equals the provided emulator state.- Parameters:
screen
- the screen for which to check the emulator stateemulatorState
- the provided emulator state- Returns:
- the Condition
- Throws:
UnsupportedOperationException
- when the emulator does not support the 'emulator state' property
-
emulatorState
public static Condition emulatorState(com.seagullsw.common.emulator.physical.base.screen.EmulatorState emulatorState) throws UnsupportedOperationException Returns a Condition that is true when the emulator's state equals the provided emulator state.- Parameters:
emulatorState
- the provided emulator state- Returns:
- the Condition
- Throws:
UnsupportedOperationException
- when the emulator does not support the 'emulator state' property
-
emulatorState
public static Condition emulatorState(com.seagullsw.common.emulator.physical.base.screen.EmulatorState emulatorState, boolean includeChangeCount) throws UnsupportedOperationException Returns a Condition that is true when the emulator's state equals the provided emulator state.- Parameters:
emulatorState
- the provided emulator stateincludeChangeCount
- a flag to indicate whether or not the ChangeCount should be included as trigger to test the emulator's state- Returns:
- the Condition
- Throws:
UnsupportedOperationException
- when the emulator does not support the 'emulator state' property
-
inputReady
Returns a Condition that is true when the session is ready for input. The specifics of the implementation vary depending on the emulator. For example, 5250 uses the emulatorState(EmulatorState.Normal), 3270 uses the emulatorState(EmulatorState.Normal) or keyboardRestoreCountAtLeast(1), and AnsiPlus(VT) uses alwaysTrue.- Parameters:
session
- The session.- Returns:
- a Condition that is true when the session is ready for input.
-
inputReady
Returns a Condition that is true when the session is ready for input. The specifics of the implementation vary depending on the emulator. For example, 5250 uses the emulatorState(EmulatorState.Normal), 3270 uses the emulatorState(EmulatorState.Normal) or keyboardRestoreCountAtLeast(1), and AnsiPlus(VT) uses alwaysTrue.- Returns:
- a Condition that is true when the session is ready for input.
- Throws:
UnsupportedOperationException
-