All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.as400.access.KeyedFile
java.lang.Object
|
+----com.ibm.as400.access.AS400File
|
+----com.ibm.as400.access.KeyedFile
- public class KeyedFile
- extends AS400File
- implements Serializable
The KeyedFile class represents an AS/400 physical or logical file.
It allows the user to do the following:
- Create an AS/400 physical file by:
- Specifying a record length.
- Specifying an existing AS/400 DDS source file.
- Specifying a RecordFormat object that contains a description of the
record format for the file.
- Access the records in an AS/400 file sequentially or by key.
- Write records to an AS/400 file sequentially or by key.
- Update records in an AS/400 file sequentially or by key.
- Lock an AS/400 file for different types of access.
- Use commitment control when accessing an AS/400 file. The user can:
- Start commitment control for the connection.
- Specify different commitment control lock levels for the individual AS/400
files being accessed.
- Commit and rollback transactions for the connection.
- Delete an AS/400 physical or logical file or member.
KeyedFile objects generate the following events:
-
KEY_EQ
- Constant indicating search type of equal.
-
KEY_GE
- Constant indicating search type of greater than or equal.
-
KEY_GT
- Constant indicating search type of greater than.
-
KEY_LE
- Constant indicating search type of less than or equal.
-
KEY_LT
- Constant indicating search type of less than.
-
KeyedFile()
- Constructs a KeyedFile object.
-
KeyedFile(AS400, String)
- Constructs a KeyedFile object.
-
deleteRecord(Object[])
- Deletes the record specified by key.
-
open(int, int, int)
- Opens the file.
-
positionCursor(Object[])
- Positions the file cursor to the first record matching the specified
key.
-
positionCursor(Object[], int)
- Positions the file cursor to the first record meeting the specified search criteria
based on key.
-
positionCursorAfter(Object[])
- Positions the file cursor to the first record after the record specified
by key.
-
positionCursorBefore(Object[])
- Positions the file cursor to the first record before the record specified
by key.
-
read(Object[])
- Reads the first record with the specified key.
-
read(Object[], int)
- Reads the first record meeting the specified search criteria based on
key.
-
readAfter(Object[])
- Reads the first record after the record with the specified key.
-
readAll()
- Reads all the records in the file.
-
readBefore(Object[])
- Reads the first record before the record with the specified key.
-
readNextEqual()
- Reads the next record whose key matches the full key of the current record.
-
readNextEqual(Object[])
- Reads the next record whose key matches the specified key.
-
readPreviousEqual()
- Reads the previous record whose key matches the key of the current record.
-
readPreviousEqual(Object[])
- Reads the previous record whose key matches the specified key.
-
update(Object[], Record)
- Updates the record specified by key.
-
update(Object[], Record, int)
- Updates the first record meeting the specified search criteria based on
key.
KEY_EQ
public static final int KEY_EQ
- Constant indicating search type of equal.
KEY_GT
public static final int KEY_GT
- Constant indicating search type of greater than.
KEY_GE
public static final int KEY_GE
- Constant indicating search type of greater than or equal.
KEY_LT
public static final int KEY_LT
- Constant indicating search type of less than.
KEY_LE
public static final int KEY_LE
- Constant indicating search type of less than or equal.
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 AS/400 system to which to connect. The system cannot
be null.
- name - The integrated file system pathname of the file. The name
cannot be null.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
open
public void open(int openType,
int blockingFactor,
int commitLockLevel) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
- Opens the file. The file must not be open when invoking this method.
If commitment control is not started for the connection,
commitLockLevel is ignored. The file cursor is positioned prior
to the first record. If blockingFactor is greater than one (or
if zero is specified and a blocking factor greater than one is determined
by the object) and the file is opened for READ_ONLY, the record cache will
be filled with an initial set of records.
The record format for the file must be set prior to calling this method.
The name of the file and the AS400 system to which to connect must be set prior
to invoking this method.
- Parameters:
- openType - The manner in which to open the file. Valid values are:
- READ_ONLY
- READ_WRITE
- WRITE_ONLY
- blockingFactor - The number of records to retrieve or to write during a
read or write operation.
The AS400File object will attempt to anticipate the need for data by accessing
blocks of records if the openType is READ_ONLY. If the openType
is WRITE_ONLY, blockingFactor number of records will be written at one
time when writing an array of records.
If the open type is READ_WRITE, blockingFactor is ignored and a
blocking factor of 1 will be used for data integrity reasons.
Specify an appropriate blockingFactor for your performance needs.
If 0 is specified for blockingFactor, a default value will be calculated
by taking the integer result of dividing 2048 by the byte length of the record
plus 16.
If the user either specifies a blocking factor greater than 1, or specifies 0
which will cause a blocking factor to be calculated, there is the risk of
obtaining stale data when doing multiple read operations.
Invoke the refreshRecordCache() method prior to reading a record to cause the object
to read from the AS/400 if this is a problem.
- commitLockLevel - Used to control record locking during a transaction if
commitment control has been started for the connection.
Valid values are:
- COMMIT_LOCK_LEVEL_ALL
- COMMIT_LOCK_LEVEL_CHANGE
- COMMIT_LOCK_LEVEL_CURSOR_STABILITY
- COMMIT_LOCK_LEVEL_DEFAULT
- COMMIT_LOCK_LEVEL_NONE
The commitLockLevel is ignored if commitment control is not started for
the connection.
- Throws: AS400Exception
- If the AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
- Throws: ServerStartupException
- If the AS/400 server cannot be started.
- Throws: UnknownHostException
- If the AS/400 system cannot be located.
- Overrides:
- open in class AS400File
- See Also:
- AS400File, setPath, setSystem, refreshRecordCache, setRecordFormat
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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.
- Returns:
- The records read. If no records are read, an array of size zero is returned.
- Throws: AS400Exception
- If the AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
- Throws: ServerStartupException
- If the AS/400 server cannot be started.
- Throws: UnknownHostException
- If the AS/400 system cannot be located.
- Overrides:
- readAll in class AS400File
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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.
- Returns:
- The record read. If the record is not found, null is returned.
- Throws: AS400Exception
- If the AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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.
- Returns:
- The record read. If the record is not found, null is returned.
- Throws: AS400Exception
- If the AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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 AS/400 system returns an error message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ConnectionDroppedException
- If the connection is dropped unexpectedly.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
All Packages Class Hierarchy This Package Previous Next Index