com.ibm.as400.access
Class KeyedFile

java.lang.Object
  extended by com.ibm.as400.access.AS400File
      extended by com.ibm.as400.access.KeyedFile
All Implemented Interfaces:
Serializable

public class KeyedFile
extends AS400File
implements Serializable

The KeyedFile class represents a physical or logical file on the system. It allows the user to do the following:

KeyedFile objects generate the following events:

See Also:
MemberList, Serialized Form

Field Summary
Modifier and Type Field and Description
static int KEY_EQ
          Constant indicating search type of equal.
static int KEY_GE
          Constant indicating search type of greater than or equal.
static int KEY_GT
          Constant indicating search type of greater than.
static int KEY_LE
          Constant indicating search type of less than or equal.
static int KEY_LT
          Constant indicating search type of less than.
protected static int[] TYPE_TABLE
           
 
Fields inherited from class com.ibm.as400.access.AS400File
BLANK, COMMIT_LOCK_LEVEL_ALL, COMMIT_LOCK_LEVEL_CHANGE, COMMIT_LOCK_LEVEL_CURSOR_STABILITY, COMMIT_LOCK_LEVEL_DEFAULT, COMMIT_LOCK_LEVEL_NONE, READ_ALLOW_SHARED_READ_LOCK, READ_ALLOW_SHARED_WRITE_LOCK, READ_EXCLUSIVE_LOCK, READ_ONLY, READ_WRITE, SOURCE_MEMBER_TEXT, TYPE_DATA, TYPE_SOURCE, WRITE_ALLOW_SHARED_READ_LOCK, WRITE_ALLOW_SHARED_WRITE_LOCK, WRITE_EXCLUSIVE_LOCK, WRITE_ONLY
 
Constructor Summary
Constructor and Description
KeyedFile()
          Constructs a KeyedFile object.
KeyedFile(AS400 system, String name)
          Constructs a KeyedFile object.
 
Method Summary
Modifier and Type Method and Description
 void deleteRecord(byte[] key, int numberOfKeyFields)
          Deletes the record specified by key.
 void deleteRecord(Object[] key)
          Deletes the record specified by key.
 void positionCursor(byte[] key, int numberOfKeyFields)
          Positions the file cursor to the first record matching the specified key.
 void positionCursor(byte[] key, int searchType, int numberOfKeyFields)
          Positions the file cursor to the first record meeting the specified search criteria based on key.
 void positionCursor(Object[] key)
          Positions the file cursor to the first record matching the specified key.
 void positionCursor(Object[] key, int searchType)
          Positions the file cursor to the first record meeting the specified search criteria based on key.
 void positionCursorAfter(byte[] key, int numberOfKeyFields)
          Positions the file cursor to the first record after the record specified by key.
 void positionCursorAfter(Object[] key)
          Positions the file cursor to the first record after the record specified by key.
 void positionCursorBefore(byte[] key, int numberOfKeyFields)
          Positions the file cursor to the first record before the record specified by key.
 void positionCursorBefore(Object[] key)
          Positions the file cursor to the first record before the record specified by key.
 Record read(byte[] key, int numberOfKeyFields)
          Reads the first record with the specified key.
 Record read(byte[] key, int searchType, int numberOfKeyFields)
          Reads the first record meeting the specified search criteria based on key.
 Record read(Object[] key)
          Reads the first record with the specified key.
 Record read(Object[] key, int searchType)
          Reads the first record meeting the specified search criteria based on key.
 Record readAfter(byte[] key, int numberOfKeyFields)
          Reads the first record after the record with the specified key.
 Record readAfter(Object[] key)
          Reads the first record after the record with the specified key.
 Record[] readAll()
          Reads all the records in the file.
 Record readBefore(byte[] key, int numberOfKeyFields)
          Reads the first record before the record with the specified key.
 Record readBefore(Object[] key)
          Reads the first record before the record with the specified key.
 Record readNextEqual()
          Reads the next record whose key matches the full key of the current record.
 Record readNextEqual(byte[] key, int numberOfKeyFields)
          Reads the next record whose key matches the specified key.
 Record readNextEqual(Object[] key)
          Reads the next record whose key matches the specified key.
 Record readPreviousEqual()
          Reads the previous record whose key matches the key of the current record.
 Record readPreviousEqual(byte[] key, int numberOfKeyFields)
          Reads the previous record whose key matches the specified key.
 Record readPreviousEqual(Object[] key)
          Reads the previous record whose key matches the specified key.
 void update(byte[] key, Record record, int numberOfKeyFields)
          Updates the record specified by key.
 void update(byte[] key, Record record, int searchType, int numberOfKeyFields)
          Updates the first record meeting the specified search criteria based on key.
 void update(Object[] key, Record record)
          Updates the record specified by key.
 void update(Object[] key, Record record, int searchType)
          Updates the first record meeting the specified search criteria based on key.
 
Methods inherited from class com.ibm.as400.access.AS400File
addFileListener, addPhysicalFileMember, addPropertyChangeListener, addVetoableChangeListener, close, commit, commit, create, create, create, create, delete, deleteCurrentRecord, deleteMember, endCommitmentControl, endCommitmentControl, finalize, getBlockingFactor, getCommitLockLevel, getExplicitLocks, getFileName, getLibraryName, getMemberName, getPath, getRecordFormat, getSystem, isCommitmentControlStarted, isCommitmentControlStarted, isOpen, isReadNoUpdate, isReadOnly, isReadWrite, isSSPFile, isWriteOnly, lock, open, open, positionCursorAfterLast, positionCursorBeforeFirst, positionCursorToFirst, positionCursorToLast, positionCursorToNext, positionCursorToPrevious, read, readFirst, readLast, readNext, readPrevious, refreshRecordCache, releaseExplicitLocks, removeFileListener, removePropertyChangeListener, removeVetoableChangeListener, rollback, rollback, runCommand, setPath, setReadNoUpdate, setRecordFormat, setRecordFormat, setRecordFormat, setRecordFormat, setSSPFile, setSystem, startCommitmentControl, startCommitmentControl, update, write, write
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_EQ

public static final int KEY_EQ
Constant indicating search type of equal.

See Also:
Constant Field Values

KEY_GT

public static final int KEY_GT
Constant indicating search type of greater than.

See Also:
Constant Field Values

KEY_GE

public static final int KEY_GE
Constant indicating search type of greater than or equal.

See Also:
Constant Field Values

KEY_LT

public static final int KEY_LT
Constant indicating search type of less than.

See Also:
Constant Field Values

KEY_LE

public static final int KEY_LE
Constant indicating search type of less than or equal.

See Also:
Constant Field Values

TYPE_TABLE

protected static final int[] TYPE_TABLE
Constructor Detail

KeyedFile

public KeyedFile()
Constructs a KeyedFile object.


KeyedFile

public KeyedFile(AS400 system,
                 String name)
Constructs a KeyedFile object. It uses the specified file. If the name for the file does not include a member, the first member of the file will be used.

Parameters:
system - The system to which to connect. The system cannot be null.
name - The integrated file system pathname of the file. The name cannot be null.
Method Detail

deleteRecord

public void deleteRecord(Object[] key)
                  throws AS400Exception,
                         AS400SecurityException,
                         InterruptedException,
                         IOException
Deletes the record specified by key. The file must be open when invoking this method.

Parameters:
key - The values that make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported. The number of elements in key cannot exceed the number of key fields in the record format for this file.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

deleteRecord

public void deleteRecord(byte[] key,
                         int numberOfKeyFields)
                  throws AS400Exception,
                         AS400SecurityException,
                         InterruptedException,
                         IOException
Deletes the record specified by key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
numberOfKeyFields - The number of key fields contained in the byte array key. This number cannot exceed the total number of key fields in the record format for this file.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

positionCursor

public void positionCursor(Object[] key)
                    throws AS400Exception,
                           AS400SecurityException,
                           InterruptedException,
                           IOException
Positions the file cursor to the first record matching the specified key. The file must be open when invoking this method.

Parameters:
key - The values that make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

positionCursor

public void positionCursor(byte[] key,
                           int numberOfKeyFields)
                    throws AS400Exception,
                           AS400SecurityException,
                           InterruptedException,
                           IOException
Positions the file cursor to the first record matching the specified key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
numberOfKeyFields - The number of key fields contained in the byte array key.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

positionCursor

public void positionCursor(Object[] key,
                           int searchType)
                    throws AS400Exception,
                           AS400SecurityException,
                           InterruptedException,
                           IOException
Positions the file cursor to the first record meeting the specified search criteria based on key. The searchType indicates that the cursor should be positioned to the record whose key first meets the search criteria when compared to key. The file must be open when invoking this method.

Parameters:
key - The values that make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
searchType - Constant indicating the type of match required. Valid values are:
  • KEY_EQ
    First record whose key is equal to key.
  • KEY_LT
    First record whose key is less than key.
  • KEY_LE
    First record whose key is less than or equal to key.
  • KEY_GT
    First record whose key is greater than key.
  • KEY_GE
    First record whose key is greater than or equal to key.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

positionCursor

public void positionCursor(byte[] key,
                           int searchType,
                           int numberOfKeyFields)
                    throws AS400Exception,
                           AS400SecurityException,
                           InterruptedException,
                           IOException
Positions the file cursor to the first record meeting the specified search criteria based on key. The searchType indicates that the cursor should be positioned to the record whose key first meets the search criteria when compared to key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
searchType - Constant indicating the type of match required. Valid values are:
  • KEY_EQ
    First record whose key is equal to key.
  • KEY_LT
    First record whose key is less than key.
  • KEY_LE
    First record whose key is less than or equal to key.
  • KEY_GT
    First record whose key is greater than key.
  • KEY_GE
    First record whose key is greater than or equal to key.
numberOfKeyFields - The number of key fields contained in the byte array key.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

positionCursorAfter

public void positionCursorAfter(Object[] key)
                         throws AS400Exception,
                                AS400SecurityException,
                                InterruptedException,
                                IOException
Positions the file cursor to the first record after the record specified by key. The file must be open when invoking this method.

Parameters:
key - The values which make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

positionCursorAfter

public void positionCursorAfter(byte[] key,
                                int numberOfKeyFields)
                         throws AS400Exception,
                                AS400SecurityException,
                                InterruptedException,
                                IOException
Positions the file cursor to the first record after the record specified by key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values which make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
numberOfKeyFields - The number of key fields contained in the byte array key.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

positionCursorBefore

public void positionCursorBefore(Object[] key)
                          throws AS400Exception,
                                 AS400SecurityException,
                                 InterruptedException,
                                 IOException
Positions the file cursor to the first record before the record specified by key. The file must be open when invoking this method.

Parameters:
key - The values which make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

positionCursorBefore

public void positionCursorBefore(byte[] key,
                                 int numberOfKeyFields)
                          throws AS400Exception,
                                 AS400SecurityException,
                                 InterruptedException,
                                 IOException
Positions the file cursor to the first record before the record specified by key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values which make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
numberOfKeyFields - The number of key fields contained in the byte array key.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

read

public Record read(Object[] key)
            throws AS400Exception,
                   AS400SecurityException,
                   InterruptedException,
                   IOException
Reads the first record with the specified key. The file must be open when invoking this method.

Parameters:
key - The values that make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

read

public Record read(byte[] key,
                   int numberOfKeyFields)
            throws AS400Exception,
                   AS400SecurityException,
                   InterruptedException,
                   IOException
Reads the first record with the specified key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
numberOfKeyFields - The number of key fields contained in the byte array key.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

read

public Record read(Object[] key,
                   int searchType)
            throws AS400Exception,
                   AS400SecurityException,
                   InterruptedException,
                   IOException
Reads the first record meeting the specified search criteria based on key. The searchType indicates that the record whose key first meets the search criteria when compared to key should be returned. The file must be open when invoking this method.

Parameters:
key - The values that make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
searchType - Constant indicating the type of match required. Valid values are:
  • KEY_EQ
    First record whose key is equal to key.
  • KEY_LT
    First record whose key is less than key.
  • KEY_LE
    First record whose key is less than or equal to key.
  • KEY_GT
    First record whose key is greater than key.
  • KEY_GE
    First record whose key is greater than or equal to key.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

read

public Record read(byte[] key,
                   int searchType,
                   int numberOfKeyFields)
            throws AS400Exception,
                   AS400SecurityException,
                   InterruptedException,
                   IOException
Reads the first record meeting the specified search criteria based on key. The searchType indicates that the record whose key first meets the search criteria when compared to key should be returned. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
searchType - Constant indicating the type of match required. Valid values are:
  • KEY_EQ
    First record whose key is equal to key.
  • KEY_LT
    First record whose key is less than key.
  • KEY_LE
    First record whose key is less than or equal to key.
  • KEY_GT
    First record whose key is greater than key.
  • KEY_GE
    First record whose key is greater than or equal to key.
numberOfKeyFields - The number of key fields contained in the byte array key.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readAfter

public Record readAfter(Object[] key)
                 throws AS400Exception,
                        AS400SecurityException,
                        InterruptedException,
                        IOException
Reads the first record after the record with the specified key. The file must be open when invoking this method.

Parameters:
key - The values that make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readAfter

public Record readAfter(byte[] key,
                        int numberOfKeyFields)
                 throws AS400Exception,
                        AS400SecurityException,
                        InterruptedException,
                        IOException
Reads the first record after the record with the specified key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
numberOfKeyFields - The number of key fields contained in the byte array key.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readAll

public Record[] readAll()
                 throws AS400Exception,
                        AS400SecurityException,
                        ConnectionDroppedException,
                        InterruptedException,
                        IOException,
                        ServerStartupException,
                        UnknownHostException
Reads all the records in the file. The file must be closed when invoking this method. The record format for the file must have been set prior to invoking this method.

Specified by:
readAll in class AS400File
Returns:
The records read. If no records are read, an array of size zero is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ServerStartupException - If the host server cannot be started.
UnknownHostException - If the system cannot be located.

readBefore

public Record readBefore(Object[] key)
                  throws AS400Exception,
                         AS400SecurityException,
                         InterruptedException,
                         IOException
Reads the first record before the record with the specified key. The file must be open when invoking this method.

Parameters:
key - The values that make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readBefore

public Record readBefore(byte[] key,
                         int numberOfKeyFields)
                  throws AS400Exception,
                         AS400SecurityException,
                         InterruptedException,
                         IOException
Reads the first record before the record with the specified key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
numberOfKeyFields - The number of key fields contained in the byte array key.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readNextEqual

public Record readNextEqual()
                     throws AS400Exception,
                            AS400SecurityException,
                            InterruptedException,
                            IOException
Reads the next record whose key matches the full key of the current record. The file must be open when invoking this method. The file must be positioned on an active record when invoking this method.
Note: If the application has previously called setReadNoUpdate(false), then this method issues a request to the server which locks the record returned to the client. The key comparison occurs on the client side. Therefore, even though the record may not match the key (and null is returned by readNextEqual), the server side will lock the most recent record which may have been read from the file. A subsequent call to any of the positionCursor() methods will unlock the last (i.e. most recent) record locked. In addition, the close() method will also unlock the last (i.e. most recent) record locked.

Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readNextEqual

public Record readNextEqual(Object[] key)
                     throws AS400Exception,
                            AS400SecurityException,
                            InterruptedException,
                            IOException
Reads the next record whose key matches the specified key. The search does not include the current record. The key may be a partial key. The file must be open when invoking this method.
Note: If the application has previously called setReadNoUpdate(false), then this method issues a request to the server which locks the record returned to the client. The key comparison occurs on the client side. Therefore, even though the record may not match the key (and null is returned by readNextEqual), the server side will lock the most recent record which may have been read from the file. A subsequent call to any of the positionCursor() methods will unlock the last (i.e. most recent) record locked. In addition, the close() method will also unlock the last (i.e. most recent) record locked.

Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readNextEqual

public Record readNextEqual(byte[] key,
                            int numberOfKeyFields)
                     throws AS400Exception,
                            AS400SecurityException,
                            InterruptedException,
                            IOException
Reads the next record whose key matches the specified key. The search does not include the current record. The key may be a partial key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
Note: If the application has previously called setReadNoUpdate(false), then this method issues a request to the server which locks the record returned to the client. The key comparison occurs on the client side. Therefore, even though the record may not match the key (and null is returned by readNextEqual), the server side will lock the most recent record which may have been read from the file. A subsequent call to any of the positionCursor() methods will unlock the last (i.e. most recent) record locked. In addition, the close() method will also unlock the last (i.e. most recent) record locked.
numberOfKeyFields - The number of key fields contained in the byte array key.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readPreviousEqual

public Record readPreviousEqual()
                         throws AS400Exception,
                                AS400SecurityException,
                                InterruptedException,
                                IOException
Reads the previous record whose key matches the key of the current record. The file must be open when invoking this method. The file must be positioned on an active record when invoking this method.

Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readPreviousEqual

public Record readPreviousEqual(Object[] key)
                         throws AS400Exception,
                                AS400SecurityException,
                                InterruptedException,
                                IOException
Reads the previous record whose key matches the specified key. The search does not include the current record. The key may be a partial key. The file must be open when invoking this method.

Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

readPreviousEqual

public Record readPreviousEqual(byte[] key,
                                int numberOfKeyFields)
                         throws AS400Exception,
                                AS400SecurityException,
                                InterruptedException,
                                IOException
Reads the previous record whose key matches the specified key. The search does not include the current record. The key may be a partial key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
numberOfKeyFields - The number of key fields contained in the byte array key.
Returns:
The record read. If the record is not found, null is returned.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

update

public void update(Object[] key,
                   Record record)
            throws AS400Exception,
                   AS400SecurityException,
                   InterruptedException,
                   IOException
Updates the record specified by key. The file must be open when invoking this method.

Parameters:
key - The values that make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
record - The record with which to update the existing record.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

update

public void update(byte[] key,
                   Record record,
                   int numberOfKeyFields)
            throws AS400Exception,
                   AS400SecurityException,
                   InterruptedException,
                   IOException
Updates the record specified by key. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
record - The record with which to update the existing record.
numberOfKeyFields - The number of key fields contained in the byte array key.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

update

public void update(Object[] key,
                   Record record,
                   int searchType)
            throws AS400Exception,
                   AS400SecurityException,
                   InterruptedException,
                   IOException
Updates the first record meeting the specified search criteria based on key. The searchType indicates that the record whose key first meets the search criteria when compared to key should be returned. The file must be open when invoking this method.

Parameters:
key - The values that make up the key with which to find the record. The key must contain at least one element. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
record - The record with which to update the existing record.
searchType - Constant indicating the type of match required. Valid values are:
  • KEY_EQ
    First record whose key is equal to key.
  • KEY_LT
    First record whose key is less than key.
  • KEY_LE
    First record whose key is less than or equal to key.
  • KEY_GT
    First record whose key is greater than key.
  • KEY_GE
    First record whose key is greater than or equal to key.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.

update

public void update(byte[] key,
                   Record record,
                   int searchType,
                   int numberOfKeyFields)
            throws AS400Exception,
                   AS400SecurityException,
                   InterruptedException,
                   IOException
Updates the first record meeting the specified search criteria based on key. The searchType indicates that the record whose key first meets the search criteria when compared to key should be returned. The file must be open when invoking this method.

Parameters:
key - The byte array that contains the byte values that make up the key with which to find the record. The byte array key must contain the byte values from at least one key field. The types and order of the elements that make up key must match the type and order of the key fields in the record format for this object. Null values for key fields are not supported.
record - The record with which to update the existing record.
searchType - Constant indicating the type of match required. Valid values are:
  • KEY_EQ
    First record whose key is equal to key.
  • KEY_LT
    First record whose key is less than key.
  • KEY_LE
    First record whose key is less than or equal to key.
  • KEY_GT
    First record whose key is greater than key.
  • KEY_GE
    First record whose key is greater than or equal to key.
numberOfKeyFields - The number of key fields contained in the byte array key.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.