Class 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 Detail

      • LOG

        public static final org.apache.logging.log4j.Logger LOG
    • Method Detail

      • 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
      • 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)
      • 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)
      • 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​(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)
      • 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()
      • 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)
      • changeCountAbsolute

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

        public static Condition screenNotNamed​(String screenName)
      • screenNamed

        public static Condition screenNamed​(String... screenNames)
      • 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.
      • 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