Class Conditions

java.lang.Object
com.rs.seagull.emulator.api.Conditions

public class Conditions extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final org.apache.logging.log4j.Logger
    The logger for Conditions
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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
    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
    cursorIn(Session session, String fieldName)
    Returns a Condition that is true when the cursor is in a particular field.
    static Condition
    cursorIn(Session session, String fieldName, int index)
    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
    cursorIn(String fieldName)
    Returns a Condition that is true when the cursor is in a particular field.
    static Condition
    cursorIn(String fieldName, int index)
    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
    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
    dataIn(Session session, String fieldName, String data)
    Returns a Condition that is true when the given field contains the given data value.
    static Condition
    dataIn(com.seagullsw.common.toolbox.geometry.Rectangle area, String data)
    Returns a Condition that is true when the given rectangle contains the given data value.
    static Condition
    dataIn(String fieldName, String data)
    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 condition
    static Condition
    Deprecated.
    Use the inputReady or emulatorState condition
    static Condition
    Returns a Condition that is true when the session is ready for input.
    static Condition
    Returns a Condition that is true when the session is ready for input.
    static Condition
    Returns a Condition that is true when the 3270-style keyboard restore count is greater or equals to a particular value.
    static Condition
    Returns a Condition that is true when the 3270-style keyboard restore count equals a particular value.
    static Condition
    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
    not(Condition 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
    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
    Returns a Condition that is true when the screen contents just to the left of the cursor match a given value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG

      public static final org.apache.logging.log4j.Logger LOG
      The logger for Conditions
  • Method Details

    • inputInhibitDown

      @Deprecated public static Condition inputInhibitDown(BareScreen screen) throws UnsupportedOperationException
      Deprecated.
      Use the inputReady or emulatorState condition
      Returns 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 public static Condition inputInhibitDown() throws UnsupportedOperationException
      Deprecated.
      Use the inputReady or emulatorState condition
      Returns 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 position
      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.
    • cursorAt

      public 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.
      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

      public static Condition 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 position
      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

      public 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.
      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

      public static Condition cursorIn(Session session, String fieldName)
      Returns a Condition that is true when the cursor is in a particular field.
      Parameters:
      session - the session for which to check the cursor position
      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.
    • cursorIn

      public static Condition cursorIn(String fieldName)
      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

      public static Condition dataIn(Session session, String fieldName, String data)
      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

      public static Condition dataIn(String fieldName, String data)
      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

      public static Condition dataIn(com.seagullsw.common.toolbox.geometry.Rectangle area, String data)
      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

      public static Condition cursorIn(Session session, String fieldName, int index)
      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 position
      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.
    • cursorIn

      public static Condition cursorIn(String fieldName, int index)
      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

      public static Condition cursorIsVisible(BareScreen screen)
      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

      public static Condition cursorIsVisible()
      Returns a Condition that is true when the cursor is visible.
      Returns:
      a Condition that is true when the cursor is visible.
    • keyboardRestoreCountEquals

      public static Condition keyboardRestoreCountEquals(BareScreen screen, int value)
      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 count
      value - the provided value
      Returns:
      a Condition that is true when the 3270-style keyboard restore count equals a particular value.
    • keyboardRestoreCountEquals

      public static Condition keyboardRestoreCountEquals(int value)
      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

      public 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.
      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

      public static Condition and(Condition c1, Condition c2)
      Returns a Condition that is true when two other conditions are both true.
      Parameters:
      c1 - condition 1
      c2 - condition 2
      Returns:
      a Condition that is true when two other conditions are both true.
    • or

      public static Condition or(Condition c1, Condition c2)
      Returns a Condition that is true when either of two other conditions are true.
      Parameters:
      c1 - condition 1
      c2 - condition 2
      Returns:
      a Condition that is true when either of two other conditions are true.
    • not

      public static Condition not(Condition condition)
      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

      public 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. 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

      public static Condition changeCount(BareSession session, int delta)
      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 count
      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.
    • changeCount

      public static Condition changeCount(int delta)
      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

      public static Condition changeCountAbsolute(long newValue)
      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

      public static Condition cancelInviteCount(int delta)
      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

      public static Condition cancelInviteCountAbsolute(long newValue)
      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

      public static Condition 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

      public static Condition alwaysTrue()
      Returns a Condition that is always true. Useful for...not sure what... but surely something.
      Returns:
      a Condition that is always true.
    • screenNamed

      public static Condition screenNamed(Session session, String screenName)
      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 name
      screenName - the screen name to match.
      Returns:
      a Condition that is true when the current screen name matches the given name.
    • screenNamed

      public static Condition screenNamed(String screenName)
      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

      public static Condition screenNotNamed(String screenName)
      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

      public 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.
      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

      public 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.
      Parameters:
      session - the session for which to check the screen names
      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

      public 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.
      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

      public static Condition 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

      public static Condition screenContains(String string)
      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

      public 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).
      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 state
      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) 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 state
      includeChangeCount - 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

      public static Condition inputReady(BareSession session)
      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

      public static Condition inputReady() throws UnsupportedOperationException
      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