com.jagacy
Class Session3270

java.lang.Object
  extended bycom.jagacy.AbstractSession
      extended bycom.jagacy.Session3270

public class Session3270
extends AbstractSession

Supports a TN3270 screen-scraping session.

Author:
Robert M. Preston

Constructor Summary
Session3270(java.lang.String name)
          Creates a new session.
Session3270(java.lang.String name, java.lang.String host)
          Creates a new session.
Session3270(java.lang.String name, java.lang.String host, int port)
          Creates a new session.
Session3270(java.lang.String name, java.lang.String host, int port, java.lang.String terminal)
          Creates a new session.
Session3270(java.lang.String name, java.lang.String host, java.lang.String terminal)
          Creates a new session.
 
Method Summary
protected  UserInterface createUi()
          Creates a user interface.
 int getPositionField(int position, int[] offset, int[] length)
          Used internally.
 void open(java.lang.String deviceName)
          Opens the session.
 java.lang.String readField(int field, int offset, int length)
          Reads a string at the given field and offset.
 java.lang.String readField(java.lang.String propertyPrefix)
          Reads a string at the given field and offset.
 int readFieldLength(int field)
          Returns the length of a field.
 int readFieldLength(java.lang.String fieldProperty)
          Returns the length of a field.
 Field[] readFields()
          Returns an array of all the fields on the screen.
 boolean waitForField(int field, int offset, java.lang.String value, int timeout)
          Waits (in 100 millisecond intervals) for the value to appear at the given field and offset.
 boolean waitForField(java.lang.String propertyPrefix, int timeout)
          Waits (in 100 millisecond intervals) for the value to appear at the given field and offset.
 boolean waitForField(java.lang.String propertyPrefix, java.lang.String timeoutProperty)
          Waits (in 100 millisecond intervals) for the value to appear at the given field and offset.
 boolean waitForField(java.lang.String propertyPrefix, java.lang.String value, int timeout)
          Waits (in 100 millisecond intervals) for the value to appear at the given field and offset.
 boolean waitForField(java.lang.String propertyPrefix, java.lang.String value, java.lang.String timeoutProperty)
          Waits (in 100 millisecond intervals) for the value to appear at the given field and offset.
 void writeField(int field, int offset, java.lang.String value)
          Writes a string at the given field and offset.
 void writeField(java.lang.String propertyPrefix)
          Writes a string at the field and offset given by the properties.
 void writeField(java.lang.String propertyPrefix, java.lang.String value)
          Writes a string at the field and offset given by the properties.
 
Methods inherited from class com.jagacy.AbstractSession
abort, close, createLocation, createLocation, finalize, getAttributeForPosition, getHeight, getLogger, getName, getProperties, getWidth, isInsertOn, logoff, logon, open, read, read, readAlarmCount, readCursor, readCursorLocation, readPosition, readPosition, readPosition, readRow, readScreen, readScreenText, waitForChange, waitForChange, waitForPosition, waitForPosition, waitForPosition, waitForPosition, waitForPosition, waitForPosition, waitForUnlock, waitForUnlock, writeAfterLabel, writeAfterLabel, writeAfterLabelProperty, writeCursor, writeCursor, writeCursor, writeKey, writeKey, writePosition, writePosition, writePosition, writePosition, writeProperty, writeString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Session3270

public Session3270(java.lang.String name)
            throws JagacyException
Creates a new session.

Parameters:
name - The session name (also the name of the .properties file).
Throws:
JagacyException - If an error occurs.

Session3270

public Session3270(java.lang.String name,
                   java.lang.String host)
            throws JagacyException
Creates a new session.

Parameters:
name - The session name (also the name of the .properties file).
host - The session's host.
Throws:
JagacyException - If an error occurs.
Since:
Jagacy 3270 1.3

Session3270

public Session3270(java.lang.String name,
                   java.lang.String host,
                   int port,
                   java.lang.String terminal)
            throws JagacyException
Creates a new session.

Parameters:
name - The session name (also the name of the .properties file).
host - The session's host.
port - The session's port number.
terminal - The session's terminal type.
Throws:
JagacyException - If an error occurs.
Since:
Jagacy 3270 1.3

Session3270

public Session3270(java.lang.String name,
                   java.lang.String host,
                   java.lang.String terminal)
            throws JagacyException
Creates a new session.

Parameters:
name - The session name (also the name of the .properties file).
host - The session's host.
terminal - The session's terminal type.
Throws:
JagacyException - If an error occurs.
Since:
Jagacy 3270 1.3

Session3270

public Session3270(java.lang.String name,
                   java.lang.String host,
                   int port)
            throws JagacyException
Creates a new session.

Parameters:
name - The session name (also the name of the .properties file).
host - The session's host.
port - The session's port number.
Throws:
JagacyException - If an error occurs.
Since:
Jagacy 3270 1.3
Method Detail

createUi

protected UserInterface createUi()
                          throws JagacyException
Description copied from class: AbstractSession
Creates a user interface.

Specified by:
createUi in class AbstractSession
Returns:
The user interface.
Throws:
JagacyException - If an error occurs.

open

public void open(java.lang.String deviceName)
          throws JagacyException
Opens the session.

Parameters:
deviceName - The session's device name.
Throws:
JagacyException - If an error occurs.
Since:
Jagacy 3270 1.3

writeField

public void writeField(int field,
                       int offset,
                       java.lang.String value)
                throws JagacyException
Writes a string at the given field and offset. Afterwards, the cursor is placed at the end of the newly written string.

Parameters:
field - Field (indexed from 1).
offset - Offset in the field (indexed from 1).
value - String to write.
Throws:
JagacyException - If an error occurs.

writeField

public void writeField(java.lang.String propertyPrefix)
                throws JagacyException
Writes a string at the field and offset given by the properties. Afterwards, the cursor is placed at the end of the newly written string. This method expects the property file to have the following entries:
<propertyPrefix>.field
<propertyPrefix>.offset
<propertyPrefix>.value

Parameters:
propertyPrefix - Prefix used to lookup properties.
Throws:
JagacyException - If an error occurs.

writeField

public void writeField(java.lang.String propertyPrefix,
                       java.lang.String value)
                throws JagacyException
Writes a string at the field and offset given by the properties. Afterwards, the cursor is placed at the end of the newly written string. This method expects the property file to have the following entries:
<propertyPrefix>.field
<propertyPrefix>.offset

Parameters:
propertyPrefix - Prefix used to lookup properties.
value - String to write.
Throws:
JagacyException - If an error occurs.

readFields

public Field[] readFields()
                   throws JagacyException
Returns an array of all the fields on the screen. If the screen is unformatted, one field is returned (field number = 0).

Returns:
An array of Fields.
Throws:
JagacyException - If an error occurs.
See Also:
Field

readField

public java.lang.String readField(int field,
                                  int offset,
                                  int length)
                           throws JagacyException
Reads a string at the given field and offset.

Parameters:
field - Field (indexed from 1).
offset - Offset (indexed from 1).
length - Length of string to read.
Returns:
String read.
Throws:
JagacyException - If an error occurs.

readField

public java.lang.String readField(java.lang.String propertyPrefix)
                           throws JagacyException
Reads a string at the given field and offset. This method expects the property file to have the following entries:
<propertyPrefix>.field
<propertyPrefix>.offset
<propertyPrefix>.length

Parameters:
propertyPrefix - Prefix used to lookup properties.
Returns:
String read.
Throws:
JagacyException - If an error occurs.

readFieldLength

public int readFieldLength(int field)
                    throws JagacyException
Returns the length of a field.

Parameters:
field - Field (indexed from 1).
Returns:
Length of field.
Throws:
JagacyException - If an error occurs.

readFieldLength

public int readFieldLength(java.lang.String fieldProperty)
                    throws JagacyException
Returns the length of a field.

Parameters:
fieldProperty - Property to lookup.
Returns:
Length of field.
Throws:
JagacyException - If an error occurs.

waitForField

public boolean waitForField(int field,
                            int offset,
                            java.lang.String value,
                            int timeout)
                     throws JagacyException
Waits (in 100 millisecond intervals) for the value to appear at the given field and offset.

Parameters:
field - Field (indexed from 1).
offset - Offset (indexed from 1).
value - Value to appear.
timeout - Amount of time to wait (in milliseconds).
Returns:
true if the value appeared; false otherwise.
Throws:
JagacyException - If an error occurs.

waitForField

public boolean waitForField(java.lang.String propertyPrefix,
                            java.lang.String timeoutProperty)
                     throws JagacyException
Waits (in 100 millisecond intervals) for the value to appear at the given field and offset. This method expects the property file to have the following entries:
<propertyPrefix>.field
<propertyPrefix>.offset
<propertyPrefix>.value

Parameters:
propertyPrefix - Prefix used to lookup properties.
timeoutProperty - Property to lookup (if property ends with '.seconds', value will be converted to milliseconds).
Returns:
true if the value appeared; false otherwise.
Throws:
JagacyException - If an error occurs.

waitForField

public boolean waitForField(java.lang.String propertyPrefix,
                            int timeout)
                     throws JagacyException
Waits (in 100 millisecond intervals) for the value to appear at the given field and offset. This method expects the property file to have the following entries:
<propertyPrefix>.field
<propertyPrefix>.offset
<propertyPrefix>.value

Parameters:
propertyPrefix - Prefix used to lookup properties.
timeout - Amount of time to wait (in milliseconds).
Returns:
true if the value appeared; false otherwise.
Throws:
JagacyException - If an error occurs.

waitForField

public boolean waitForField(java.lang.String propertyPrefix,
                            java.lang.String value,
                            java.lang.String timeoutProperty)
                     throws JagacyException
Waits (in 100 millisecond intervals) for the value to appear at the given field and offset. This method expects the property file to have the following entries:
<propertyPrefix>.field
<propertyPrefix>.offset

Parameters:
propertyPrefix - Prefix used to lookup properties.
value - Value to appear.
timeoutProperty - Property to lookup (if property ends with '.seconds', value will be converted to milliseconds).
Returns:
true if the value appeared; false otherwise.
Throws:
JagacyException - If an error occurs.

waitForField

public boolean waitForField(java.lang.String propertyPrefix,
                            java.lang.String value,
                            int timeout)
                     throws JagacyException
Waits (in 100 millisecond intervals) for the value to appear at the given field and offset. This method expects the property file to have the following entries:
<propertyPrefix>.field
<propertyPrefix>.offset

Parameters:
propertyPrefix - Prefix used to lookup properties.
value - Value to appear.
timeout - Amount of time to wait (in milliseconds).
Returns:
true if the value appeared; false otherwise.
Throws:
JagacyException - If an error occurs.

getPositionField

public int getPositionField(int position,
                            int[] offset,
                            int[] length)
                     throws JagacyException
Used internally. Returns the field information for the given coordinates.

Parameters:
position - Position to find.
offset - Offset within field.
length - Length of field.
Returns:
Field (indexed from 1)
Throws:
JagacyException - If an error occurs.