All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.AS400File

java.lang.Object
   |
   +----com.ibm.as400.access.AS400File

public abstract class AS400File
extends Object
implements Serializable
The AS400File class represents an AS/400 physical or logical file. It allows the user to do the following: AS400File objects generate the following events:


Variable Index

 o COMMIT_LOCK_LEVEL_ALL
Constant indicating a commit lock level of *ALL.
 o COMMIT_LOCK_LEVEL_CHANGE
Constant indicating a commit lock level of *CHANGE.
 o COMMIT_LOCK_LEVEL_CURSOR_STABILITY
Constant indicating a commit lock level of *CS.
 o COMMIT_LOCK_LEVEL_DEFAULT
Constant indicating that the commit lock level specified on the startCommitmentControl() method should be used.
 o COMMIT_LOCK_LEVEL_NONE
Constant indicating that no commitment control should be used for the file.
 o impl_
 o READ_ALLOW_SHARED_READ_LOCK
Constant indicating lock type of read willing to share with other readers.
 o READ_ALLOW_SHARED_WRITE_LOCK
Constant indicating lock type of read willing to share with updaters.
 o READ_EXCLUSIVE_LOCK
Constant indicating lock type of read willing to share with no one.
 o READ_ONLY
Constant indicating open type of read only.
 o READ_WRITE
Constant indicating open type of read/write.
 o WRITE_ALLOW_SHARED_READ_LOCK
Constant indicating lock type of update willing to share with readers.
 o WRITE_ALLOW_SHARED_WRITE_LOCK
Constant indicating lock type of update willing to share with updaters.
 o WRITE_EXCLUSIVE_LOCK
Constant indicating lock type of update willing to share with no one.
 o WRITE_ONLY
Constant indicating open type of write only.

Constructor Index

 o AS400File()
Constructs an AS400File object.
 o AS400File(AS400, String)
Constructs an AS400File object.

Method Index

 o addFileListener(FileListener)
Adds a listener to be notified when a FileEvent is fired.
 o addPhysicalFileMember(String, String)
Adds a physical file member to the file represented by this object.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property is changed.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property is changed.
 o close()
Closes the file on the AS400.
 o commit()
Commits all transactions since the last commit boundary.
 o create(int, String, String)
Creates a physical file with the specified record length and file type.
 o create(RecordFormat, String)
Creates a physical file using the specified record format.
 o create(RecordFormat, String, String, String, String, String, boolean, String, String)
Creates a physical file using the specified record format and any specified keywords.
 o create(String, String)
Creates a physical file using the specified DDS source file.
 o createImplementation()
Creates the proper implementation.
 o delete()
Deletes the file.
 o deleteCurrentRecord()
Deletes the record at the current cursor position.
 o deleteMember()
Deletes the member associated with this object from the file.
 o endCommitmentControl()
Ends commitment control for this connection.
 o finalize()
Closes the file when this object is garbage collected.
 o getBlockingFactor()
Returns the blocking factor being used for this file.
 o getCommitLockLevel()
Returns the commit lock level for this file as specified on open.
 o getExplicitLocks()
Returns any explicit locks that have been obtained for this file.
 o getFileName()
Returns the file name.
 o getMemberName()
Returns the member name.
 o getPath()
Returns the integrated file system pathname for the file as specified on the constructor or the setPath() method.
 o getRecordFormat()
Returns the record format of this file.
 o getSystem()
Returns the AS400 system object for this object.
 o isCommitmentControlStarted()
Indicates if commitment control is started for the connection.
 o isOpen()
Indicates if the file is open.
 o isReadNoUpdate()
Indicates if the records should be locked for update when doing reads in a READ_WRITE open mode.
 o isReadOnly()
Indicates if this object is open for read only.
 o isReadWrite()
Indicates if this object is open for read/write.
 o isWriteOnly()
Indicates if this object is open for write only.
 o lock(int)
Obtains a lock on the file.
 o open(int, int, int)
Opens the file.
 o openFile(int, int, int, String)
Opens the file.
 o positionCursorAfterLast()
Positions the file cursor to after the last record.
 o positionCursorBeforeFirst()
Positions the file cursor to before the first record.
 o positionCursorToFirst()
Positions the file cursor to the first record.
 o positionCursorToLast()
Positions the file cursor to the last record.
 o positionCursorToNext()
Positions the file cursor to the next record.
 o positionCursorToPrevious()
Positions the file cursor to the previous record.
 o read()
Reads the record at the current cursor position.
 o readAll()
Reads all the records in the file.
 o readFirst()
Reads the first record in the file.
 o readLast()
Reads the last record in the file.
 o readNext()
Reads the next record in the file from the current cursor position.
 o readPrevious()
Reads the previous record in the file from the current cursor position.
 o refreshRecordCache()
Refreshes the record cache for this file.
 o releaseExplicitLocks()
Releases all locks acquired via the lock() method.
 o removeFileListener(FileListener)
Removes a listener from the file listeners list.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a listener from the change list.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a listener from the veto change listeners list.
 o rollback()
Rolls back any transactions since the last commit/rollback boundary.
 o setPath(String)
Sets the integrated file system pathname for the file.
 o setReadNoUpdate(boolean)
Sets the readNoUpdate flag, which determines whether the records should be locked for update when doing reads in a READ_WRITE open mode.
 o setRecordFormat(RecordFormat)
Sets the record format to be used for this file.
 o setSystem(AS400)
Sets the system to which to connect.
 o startCommitmentControl(int)
Starts commitment control on this file (for this connection).
 o update(Record)
Updates the record at the current cursor position.
 o write(Record)
Writes a record to the file.
 o write(Record[])
Writes an array of records to the file.

Variables

 o COMMIT_LOCK_LEVEL_ALL
 public static final int COMMIT_LOCK_LEVEL_ALL
Constant indicating a commit lock level of *ALL. Every record accessed in the file is locked until the transaction is committed or rolled back.

See Also:
startCommitmentControl
 o COMMIT_LOCK_LEVEL_CHANGE
 public static final int COMMIT_LOCK_LEVEL_CHANGE
Constant indicating a commit lock level of *CHANGE. Every record read for update is locked. If a record is updated, added, or deleted, that record remains locked until the transaction is committed or rolled back. Records that are accessed for update but are released without being updated are unlocked.

See Also:
startCommitmentControl
 o COMMIT_LOCK_LEVEL_CURSOR_STABILITY
 public static final int COMMIT_LOCK_LEVEL_CURSOR_STABILITY
Constant indicating a commit lock level of *CS. Every record accessed is locked. Records that are not updated or deleted are locked only until a different record is accessed. Records that are updated, added, or deleted are locked until the transaction is committed or rolled back.

See Also:
startCommitmentControl
 o COMMIT_LOCK_LEVEL_DEFAULT
 public static final int COMMIT_LOCK_LEVEL_DEFAULT
Constant indicating that the commit lock level specified on the startCommitmentControl() method should be used. The record locking specified by the commitLockLevel parameter on the startCommitmentControl() method will apply to transactions using this file.

 o COMMIT_LOCK_LEVEL_NONE
 public static final int COMMIT_LOCK_LEVEL_NONE
Constant indicating that no commitment control should be used for the file. No commitment control will apply to this file.

See Also:
startCommitmentControl
 o READ_ALLOW_SHARED_READ_LOCK
 public static final int READ_ALLOW_SHARED_READ_LOCK
Constant indicating lock type of read willing to share with other readers. This is the equivalent of specifying *SHRNUP on the AS/400 Allocate Object (ALCOBJ) command.

See Also:
lock
 o READ_ALLOW_SHARED_WRITE_LOCK
 public static final int READ_ALLOW_SHARED_WRITE_LOCK
Constant indicating lock type of read willing to share with updaters. This is the equivalent of specifying *SHRRD on the AS/400 Allocate Object (ALCOBJ) command.

See Also:
lock
 o READ_EXCLUSIVE_LOCK
 public static final int READ_EXCLUSIVE_LOCK
Constant indicating lock type of read willing to share with no one. This is the equivalent of specifying *EXCL on the AS/400 Allocate Object (ALCOBJ) command.

See Also:
lock
 o READ_ONLY
 public static final int READ_ONLY
Constant indicating open type of read only.

See Also:
open
 o READ_WRITE
 public static final int READ_WRITE
Constant indicating open type of read/write.

See Also:
open
 o WRITE_ALLOW_SHARED_READ_LOCK
 public static final int WRITE_ALLOW_SHARED_READ_LOCK
Constant indicating lock type of update willing to share with readers. This is the equivalent of specifying *EXCLRD on the AS/400 Allocate Object (ALCOBJ) command.

See Also:
lock
 o WRITE_ALLOW_SHARED_WRITE_LOCK
 public static final int WRITE_ALLOW_SHARED_WRITE_LOCK
Constant indicating lock type of update willing to share with updaters. This is the equivalent of specifying *SHRUPD on the AS/400 Allocate Object (ALCOBJ) command.

See Also:
lock
 o WRITE_EXCLUSIVE_LOCK
 public static final int WRITE_EXCLUSIVE_LOCK
Constant indicating lock type of update willing to share with no one. This is the equivalent of specifying *EXCL on the AS/400 Allocate Object (ALCOBJ) command.

See Also:
lock
 o WRITE_ONLY
 public static final int WRITE_ONLY
Constant indicating open type of write only.

See Also:
open
 o impl_
 protected transient AS400FileImpl impl_

Constructors

 o AS400File
 public AS400File()
Constructs an AS400File object.

 o AS400File
 public AS400File(AS400 system,
                  String name)
Constructs an AS400File object. It uses the system and file name specified. 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.

Methods

 o addFileListener
 public synchronized void addFileListener(FileListener listener)
Adds a listener to be notified when a FileEvent is fired.

Parameters:
listener - The FileListener.
See Also:
removeFileListener
 o addPhysicalFileMember
 public void addPhysicalFileMember(String name,
                                   String textDescription) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Adds a physical file member to the file represented by this object.

Parameters:
name - The name of the member to create. The name cannot exceed 10 characters in length. The name cannot be null.
textDescription - The text description with which to create the file. This value must be 50 characters or less. If this value is null, the text description will be blank.
The name of the file and the AS400 system to which to connect must be set prior to invoking this method.
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.
See Also:
AS400File, setPath, setSystem
 o addPropertyChangeListener
 public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property is changed. The propertyChange method will be be called.

Parameters:
listener - The PropertyChangeListener.
See Also:
removePropertyChangeListener
 o addVetoableChangeListener
 public synchronized void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property is changed. The vetoableChange method will be called.

Parameters:
listener - The VetoableChangeListener.
See Also:
removeVetoableChangeListener
 o close
 public synchronized void close() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Closes the file on the AS400. All file locks held by this connection are released. All uncommitted transactions against the file are rolled back if commitment control has been started.

Throws: AS400Exception
If the AS/400 system returns an error message.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
 o commit
 public void commit() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Commits all transactions since the last commit boundary. Invoking this method will cause all transactions under commitment control for this connection to be committed. This means that any AS400File object opened under this connection, for which a commit lock level was specified, will have outstanding transactions committed. If commitment control has not been started for the connection, no action is taken.
The AS400 system to which to connect must be set prior to invoking this method.

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.
See Also:
AS400File, setSystem
 o create
 public void create(int recordLength,
                    String fileType,
                    String textDescription) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Creates a physical file with the specified record length and file type. The record format for this object will be set by this method. The record format for the file is determined as follows: Note: The file is created using the default values for the AS/400 Create Physical File command (CRTPF). Use the CommandCall class to issue a CHGPF command to change the file after it has been created.
The name of the file and the AS400 system to which to connect must be set prior to invoking this method.

Parameters:
recordLength - The record length with which to create the file. Valid values are 1 through 32766 inclusive.
fileType - The file type with which to create the file. Valid values are *DATA or *SRC. If *DATA is specified, the record format for the file contains one field. If *SRC is specified, the record format for the file contains three fields: source sequence number, date, and source statement.
textDescription - The text description with which to create the file. This value must be between 1 and 50 characters inclusive. If this value is null, the empty string, or *BLANK, the text description is blank.
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.
See Also:
AS400File, setPath, setSystem
 o create
 public void create(String ddsSourceFile,
                    String textDescription) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Creates a physical file using the specified DDS source file. Note: The file is created using the default values for AS/400 Create Physical File (CRTPF) command. Use the CommandCall class to issue a CHGPF to change the file after it has been created.
The name of the file and the AS400 system to which to connect must be set prior to invoking this method.

Parameters:
ddsSourceFile - The integrated file system pathname of the file containing the DDS source for the file being created.
textDescription - The text description with which to create the file. This value must be between 1 and 50 characters inclusive. If this value is null, the empty string, or *BLANK, the text description will be blank. Specify *SRCMBRTXT for the text description if the text description from ddsSourceFile is to be used.
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.
See Also:
AS400File, setPath, setSystem
 o create
 public void create(RecordFormat recordFormat,
                    String textDescription) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Creates a physical file using the specified record format. The record format for this object will be set by this method. Note: The file is created using the default values for AS/400 Create Physical File (CRTPF) command. Use the CommandCall class to issue a CHGPF to change the file after it has been created.
The name of the file and the AS400 system to which to connect must be set prior to invoking this method.

Parameters:
recordFormat - The record format for the file.
textDescription - The text description with which to create the file. This value must be between 1 and 50 characters inclusive. If this value is null, the empty string, or *BLANK, the text description will be blank.
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.
See Also:
AS400File, setPath, setSystem
 o create
 public void create(RecordFormat recordFormat,
                    String textDescription,
                    String altSeq,
                    String ccsid,
                    String order,
                    String ref,
                    boolean unique,
                    String format,
                    String text) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Creates a physical file using the specified record format and any specified keywords. The record format for this object will be set by this method. Note: The file is created using the default values for AS/400 Create Physical File (CRTPF) command. Use the CommandCall class to issue a CHGPF to change the file after it has been created.
The name of the file and the AS400 system to which to connect must be set prior to invoking this method.

Parameters:
recordFormat - The record format of the file.
textDescription - The text description with which to create the file. This value must be between 1 and 50 characters inclusive. If this value is null, the empty string, or *BLANK, the text description will be blank.
altSeq - The value to be specified for the file-level keyword ALTSEQ. If no value is to be specified, null may be specified.
ccsid - The value to be specified for the file-level keyword CCSID. If no value is to be specified, null may be specified.
order - The value to be specified to indicate in which order records will be retrieved from the file. Valid values are one of the following file-level keywords:
  • FIFO
  • LIFO
  • FCFO
If no ordering value is to be specified, null may be specified.
ref - The value to be specified for the file-level keyword REF. If no value is to be specified, null may be specified.
unique - The value that indicates if the file-level keyword UNIQUE is to be specified. true if UNIQUE should be specified; false otherwise.
format - The value to be specified for the record-level keyword FORMAT. If no value is to be specified, null may be specified.
text - The value to be specified for the record-level keyword TEXT. If no value is to be specified, null may be specified. The single quotes required to surround the TEXT keyword value are added by this class.
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.
See Also:
AS400File, setPath, setSystem
 o createImplementation
 protected void createImplementation() throws IOException, UnsupportedEncodingException
Creates the proper implementation.

 o delete
 public void delete() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Deletes the file. The object cannot be open when calling this method. The file and all its members will be deleted. Use deleteMember() to delete only the member associated with this object.
The name of the file and the AS400 system to which to connect must be set prior to invoking this method.

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.
See Also:
AS400File, setPath, setSystem, deleteMember
 o deleteCurrentRecord
 public void deleteCurrentRecord() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Deletes the record at the current cursor position. The file must be open and the cursor must be positioned on an active 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.
 o deleteMember
 public void deleteMember() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Deletes the member associated with this object from the file. The object cannot be open when invoking this method.
The name of the file and the AS400 system to which to connect must be set prior to invoking this method.

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.
See Also:
AS400File, setPath, setSystem
 o endCommitmentControl
 public void endCommitmentControl() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Ends commitment control for this connection. If commitment control has not been started for the connection, no action is taken.

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.
 o finalize
 protected void finalize() throws Throwable
Closes the file when this object is garbage collected.

Throws: Throwable
If an exception is thrown while cleaning up.
Overrides:
finalize in class Object
 o getBlockingFactor
 public int getBlockingFactor()
Returns the blocking factor being used for this file.

Returns:
The blocking factor for this file. Zero will be returned if the file is not open.
See Also:
open
 o getCommitLockLevel
 public int getCommitLockLevel()
Returns the commit lock level for this file as specified on open.

Returns:
The commit lock level for this file. If commitment control has not been started for the connection or if file has not been opened, -1 is returned. Possible return values are:
  • COMMIT_LOCK_LEVEL_ALL
  • COMMIT_LOCK_LEVEL_CHANGE
  • COMMIT_LOCK_LEVEL_CURSOR_STABILITY
  • COMMIT_LOCK_LEVEL_DEFAULT
  • COMMIT_LOCK_LEVEL_NONE
  • -1
 o getExplicitLocks
 public int[] getExplicitLocks()
Returns any explicit locks that have been obtained for this file. Any locks that have been obtained through the lock(int) method are returned.

Returns:
The explicit file locks held for this file. Possible lock values are:
  • READ_EXCLUSIVE_LOCK
  • READ_ALLOW_SHARED_READ_LOCK
  • READ_ALLOW_SHARED_WRITE_LOCK
  • WRITE_EXCLUSIVE_LOCK
  • WRITE_ALLOW_SHARED_READ_LOCK
  • WRITE_ALLOW_SHARED_WRITE_LOCK
If no explicit locks have been obtained for the file, an array of size zero is returned.
See Also:
lock
 o getFileName
 public String getFileName()
Returns the file name.

Returns:
The file name. If the integrated file system pathname has not been set for the object, an empty string is returned.
 o getMemberName
 public String getMemberName()
Returns the member name.

Returns:
The member name. If the special value %FIRST% or %LAST% was specified for the member portion of the file name and the file is not open, the special value is returned. If the special value %FIRST% or %LAST% was specified for the member portion of the file name and the file is open, the member name is returned. If the integrated file system pathname has not been set for the object, an empty string is returned.
 o getPath
 public String getPath()
Returns the integrated file system pathname for the file as specified on the constructor or the setPath() method.

Returns:
The integrated file system pathname associated with this object. If the integrated file system pathname has not been set for the object, an empty string is returned.
See Also:
AS400File, setPath
 o getRecordFormat
 public RecordFormat getRecordFormat()
Returns the record format of this file.

Returns:
The record format of the file. If the record format has not been set, null is returned.
See Also:
create, setRecordFormat
 o getSystem
 public AS400 getSystem()
Returns the AS400 system object for this object.

Returns:
The AS400 system for this object. If the system has not been set, null is returned.
See Also:
AS400File, setSystem
 o isCommitmentControlStarted
 public boolean isCommitmentControlStarted()
Indicates if commitment control is started for the connection.

Returns:
true if commitment control has been started; false otherwise.
 o isOpen
 public boolean isOpen()
Indicates if the file is open.

Returns:
true if the file is open; false otherwise.
 o isReadNoUpdate
 public boolean isReadNoUpdate()
Indicates if the records should be locked for update when doing reads in a READ_WRITE open mode. By default, the records will be locked for update when doing reads in a READ_WRITE open mode.

Returns:
true if the records should not be locked for update when doing reads in a READ_WRITE open mode; false otherwise.
See Also:
setReadNoUpdate
 o isReadOnly
 public boolean isReadOnly()
Indicates if this object is open for read only.

Returns:
true if the file is open for read only; false otherwise.
 o isReadWrite
 public boolean isReadWrite()
Indicates if this object is open for read/write.

Returns:
true if the file is open for read/write; false otherwise.
 o isWriteOnly
 public boolean isWriteOnly()
Indicates if this object is open for write only.

Returns:
true if the file is open for write only; false otherwise.
 o lock
 public void lock(int lockToObtain) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Obtains a lock on the file. The name of the file and the AS400 system to which to connect must be set prior to invoking this method.

Parameters:
lockToObtain - The type of lock to acquire on the file. Valid lock values are:
  • READ_EXCLUSIVE_LOCK
  • READ_ALLOW_SHARED_READ_LOCK
  • READ_ALLOW_SHARED_WRITE_LOCK
  • WRITE_EXCLUSIVE_LOCK
  • WRITE_ALLOW_SHARED_READ_LOCK
  • WRITE_ALLOW_SHARED_WRITE_LOCK
If lockToObtain has already been obtained, no action is taken.
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.
See Also:
AS400File, setPath, setSystem
 o open
 public abstract 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 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.
See Also:
AS400File, setPath, setSystem, refreshRecordCache, setRecordFormat
 o openFile
 protected synchronized void openFile(int openType,
                                      int blockingFactor,
                                      int commitLockLevel,
                                      String access) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Opens the file. Helper function to open file for keyed or sequential files.

Parameters:
openType - The manner in which to open the file.
blockingFactor - The number of records to retrieve or to write during a read or write operation.
commitLockLevel - Used to control record locking during a transaction if commitment control has been started for the connection.
access - The type of file access for which to open the 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.
Throws: ServerStartupException
If the AS/400 server cannot be started..
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o positionCursorAfterLast
 public void positionCursorAfterLast() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Positions the file cursor to after the last record. The file must be open when invoking this method.

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.
 o positionCursorBeforeFirst
 public void positionCursorBeforeFirst() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Positions the file cursor to before the first record. The file must be open when invoking this method.

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.
 o positionCursorToFirst
 public void positionCursorToFirst() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Positions the file cursor to the first record. The file must be open when invoking this method.

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.
 o positionCursorToLast
 public void positionCursorToLast() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Positions the file cursor to the last record. The file must be open when invoking this method.

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.
 o positionCursorToNext
 public void positionCursorToNext() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Positions the file cursor to the next record. The file must be open when invoking this method.

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.
 o positionCursorToPrevious
 public void positionCursorToPrevious() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Positions the file cursor to the previous record. The file must be open when invoking this method.

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.
 o read
 public Record read() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Reads the record at the current cursor position. The file must be open when invoking this method. The cursor position does not change when this method is invoked.

Returns:
The record read.
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.
 o readAll
 public abstract Record[] readAll() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
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.
 o readFirst
 public Record readFirst() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Reads the first record in the file. The file must be open when invoking this method. The cursor is positioned to the first record of the file as a result of invoking this method.

Returns:
The record read.
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.
 o readLast
 public Record readLast() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Reads the last record in the file. The file must be open when invoking this method. The cursor is positioned to the last record of the file as a result of invoking this method.

Returns:
The record read.
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.
 o readNext
 public Record readNext() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Reads the next record in the file from the current cursor position. The file must be open when invoking this method. The cursor is positioned to the first active record after the current cursor position as a result of invoking this method. If this method is invoked when the cursor is positioned at the last record of the file, null will be returned and the cursor is positioned after the last record of the file.

Returns:
The record read.
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.
 o readPrevious
 public Record readPrevious() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Reads the previous record in the file from the current cursor position. The file must be open when invoking this method. The cursor is positioned to the first active record prior to the current cursor position as a result of invoking this method. If this method is invoked when the cursor is positioned at the first record of the file, null is returned and the cursor is positioned before the first record of the file.

Returns:
The record read.
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.
 o refreshRecordCache
 public void refreshRecordCache() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Refreshes the record cache for this file. Invoking this method will cause the retrieval of records from the AS/400. The cursor position is set to the first record of the file. This method only needs to be invoked if a blocking factor greater than 1 is being used, and the user wants to refresh the records in the cache. The file must be open when invoking this method. No action is taken if records are not being cached (for example, the blocking factor is set to one).

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.
 o releaseExplicitLocks
 public void releaseExplicitLocks() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Releases all locks acquired via the lock() method. If no locks have been explicitly obtained, no action is taken.

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.
See Also:
lock
 o removeFileListener
 public synchronized void removeFileListener(FileListener listener)
Removes a listener from the file listeners list. If the listener is not on the list, does nothing.

Parameters:
listener - The FileListener.
See Also:
addFileListener
 o removePropertyChangeListener
 public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener from the change list. If the listener is not on the list, does nothing.

Parameters:
listener - The PropertyChangeListener.
See Also:
addPropertyChangeListener
 o removeVetoableChangeListener
 public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a listener from the veto change listeners list. If the listener is not on the list, does nothing.

Parameters:
listener - The VetoableChangeListener.
See Also:
addVetoableChangeListener
 o rollback
 public void rollback() throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Rolls back any transactions since the last commit/rollback boundary. Invoking this method will cause all transactions under commitment control for this connection to be rolled back. This means that any AS400File object for which a commit lock level was specified and that was opened under this connection will have outstanding transactions rolled back.

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.
 o setPath
 public void setPath(String name) throws PropertyVetoException
Sets the integrated file system pathname for the file.

Parameters:
name - The integrated file system pathname of the file.
Throws: PropertyVetoException
If a change is vetoed.
 o setReadNoUpdate
 public void setReadNoUpdate(boolean readNoUpdate)
Sets the readNoUpdate flag, which determines whether the records should be locked for update when doing reads in a READ_WRITE open mode.

Parameters:
readNoUpdate - true if the records should not be locked for update when doing reads in a READ_WRITE open mode; false otherwise.
See Also:
isReadNoUpdate
 o setRecordFormat
 public void setRecordFormat(RecordFormat recordFormat) throws PropertyVetoException
Sets the record format to be used for this file. This method must be invoked prior to invoking open() or readAll().

Parameters:
recordFormat - The record format for this file.
Throws: PropertyVetoException
If a change is vetoed.
 o setSystem
 public void setSystem(AS400 system) throws PropertyVetoException
Sets the system to which to connect.

Parameters:
system - The system to which to connect.
Throws: PropertyVetoException
If a change is vetoed.
 o startCommitmentControl
 public void startCommitmentControl(int commitLockLevel) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Starts commitment control on this file (for this connection). If commitment control has already been started for the connection, an exception is thrown.

Parameters:
commitLockLevel - The type of commitment control to exercise. Valid values are:
  • COMMIT_LOCK_LEVEL_ALL
  • COMMIT_LOCK_LEVEL_CHANGE
  • COMMIT_LOCK_LEVEL_CURSOR_STABILITY
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.
 o update
 public void update(Record record) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Updates the record at the current cursor position. The file must be open when invoking this method. The cursor must be positioned to an active record. The last operation on the file must have been a cursor positioning operation or a read operation. If an attempt is made to update a record more than once without reading the record or positioning the cursor to the record in between updates, an AS400Exception is thrown. The cursor position is not changed when this method is invoked.

Parameters:
record - The record with which to update. The record must be a record whose format matches the record format of this object. To ensure that this requirement is met, use the RecordFormat.getNewRecord() method to obtain a default record whose fields can be set appropriately by the Java program and then written to the 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.
 o write
 public void write(Record record) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Writes a record to the file. The file must be open when invoking this method. The record is written to the end of the file. The cursor is positioned to after the last record of the file as a result of invoking this method.

Parameters:
record - The record to write. The record must be a record whose format matches the record format of this object. To ensure that this requirement is met, use the RecordFormat.getNewRecord() method to obtain a default record whose fields can be set appropriately by the Java program and then written to the 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.
 o write
 public void write(Record records[]) throws AS400Exception, AS400SecurityException, InterruptedException, IOException
Writes an array of records to the file. The file must be open when invoking this method. The records are written to the end of the file. The cursor is positioned to after the last record of the file as a result of invoking this method.

Parameters:
records - The records to write. The records must have a format which matches the record format of this object. To ensure that this requirement is met, use the RecordFormat.getNewRecord() method to obtain default records whose fields can be set appropriately by the Java program and then written to the 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.

All Packages  Class Hierarchy  This Package  Previous  Next  Index