com.ibm.as400.access
Class LocalDataArea

java.lang.Object
  extended by com.ibm.as400.access.DataArea
      extended by com.ibm.as400.access.LocalDataArea
All Implemented Interfaces:
Serializable

public class LocalDataArea
extends DataArea
implements Serializable

The LocalDataArea class represents a local data area on the system.

A local data area exists as a character data area on the system. It is automatically associated with a job and cannot be accessed from another job; hence, it cannot be directly created or deleted by the user.

Care must be taken when using local data areas so that the IBM i job is not ended prematurely. When the job ends, its local data area is automatically deleted, at which point the LocalDataArea object that is referencing it will no longer be valid.

The following example demonstrates the use of LocalDataArea:

// Prepare to work with the system named "My400".
AS400 system = new AS400("My400");

// Create a LocalDataArea object to access
// the local data area associated with this connection.
LocalDataArea dataArea = new LocalDataArea(system);

// Clear the data area
dataArea.clear();

// Write to the data area
dataArea.write("Hello world");

// Read from the data area
String data = dataArea.read();

Note: Most of the read() and write() methods of this class automatically convert characters between Unicode and the CCSID associated with the AS400 object. See AS400.getCcsid().

See Also:
Serialized Form

Constructor Summary
Constructor and Description
LocalDataArea()
          Constructs a LocalDataArea object.
LocalDataArea(AS400 system)
          Constructs a LocalDataArea object.
 
Method Summary
Modifier and Type Method and Description
 void clear()
          Resets the data area to contain all blanks.
 String read()
          Reads the data from the data area.
 int read(byte[] dataBuffer, int dataBufferOffset, int dataAreaOffset, int dataLength)
          Reads the data from the data area.
 String read(int type)
          Reads the data from the data area.
 String read(int dataAreaOffset, int dataLength)
          Reads the data from the data area.
 String read(int dataAreaOffset, int dataLength, int type)
          Reads the data from the data area.
 void write(byte[] dataBuffer, int dataBufferOffset, int dataAreaOffset, int dataLength)
          Writes the data to the data area.
 void write(String data)
          Writes the data to the data area.
 void write(String data, int dataAreaOffset)
          Writes the data to the data area.
 void write(String data, int dataAreaOffset, int type)
          Writes the data to the data area.
 
Methods inherited from class com.ibm.as400.access.DataArea
addDataAreaListener, addPropertyChangeListener, addVetoableChangeListener, getLength, getName, getSystem, refreshAttributes, removeDataAreaListener, removePropertyChangeListener, removeVetoableChangeListener, setSystem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalDataArea

public LocalDataArea()
Constructs a LocalDataArea object. It creates a default LocalDataArea object. The system property must be set before attempting a connection.


LocalDataArea

public LocalDataArea(AS400 system)
Constructs a LocalDataArea object. It creates a LocalDataArea instance that represents the local data area on system.

Parameters:
system - The system that contains the data area.
Method Detail

clear

public void clear()
           throws AS400SecurityException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException
Resets the data area to contain all blanks.

Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.

read

public String read()
            throws AS400SecurityException,
                   ErrorCompletingRequestException,
                   IllegalObjectTypeException,
                   InterruptedException,
                   IOException,
                   ObjectDoesNotExistException
Reads the data from the data area. It retrieves the entire contents of the data area. Note that if the data does not completely fill the data area, this method will return data padded with trailing blanks up to the length of the data area.

Returns:
The data read from the data area.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
IllegalObjectTypeException - If the system object is not the required type.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.

read

public String read(int type)
            throws AS400SecurityException,
                   ErrorCompletingRequestException,
                   IllegalObjectTypeException,
                   InterruptedException,
                   IOException,
                   ObjectDoesNotExistException
Reads the data from the data area. It retrieves the entire contents of the data area. Note that if the data does not completely fill the data area, this method will return data padded with trailing blanks up to the length of the data area.

Parameters:
type - The Local Data Area bidi string type, as defined by the CDRA (Character Data Representataion Architecture). See BidiStringType for more information and valid values.
Returns:
The data read from the data area.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
IllegalObjectTypeException - If the system object is not the required type.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.

read

public String read(int dataAreaOffset,
                   int dataLength)
            throws AS400SecurityException,
                   ErrorCompletingRequestException,
                   IllegalObjectTypeException,
                   InterruptedException,
                   IOException,
                   ObjectDoesNotExistException
Reads the data from the data area. It retrieves dataLength characters (or fewer if multi-byte characters) beginning at dataAreaOffset in the data area. The first character in the data area is at offset 0.

Parameters:
dataAreaOffset - The offset in the data area at which to start reading.
dataLength - The number of bytes to read. Valid values are from 1 through (data area size - dataAreaOffset).
Returns:
The data read from the data area.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
IllegalObjectTypeException - If the system object is not the required type.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.

read

public String read(int dataAreaOffset,
                   int dataLength,
                   int type)
            throws AS400SecurityException,
                   ErrorCompletingRequestException,
                   IllegalObjectTypeException,
                   InterruptedException,
                   IOException,
                   ObjectDoesNotExistException
Reads the data from the data area. It retrieves dataLength characters (or fewer if multi-byte characters) beginning at dataAreaOffset in the data area. The first character in the data area is at offset 0.

Parameters:
dataAreaOffset - The offset in the data area at which to start reading.
dataLength - The number of bytes to read. Valid values are from 1 through (data area size - dataAreaOffset).
type - The Data Area bidi string type, as defined by the CDRA (Character Data Representataion Architecture). See BidiStringType for more information and valid values.
Returns:
The data read from the data area.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
IllegalObjectTypeException - If the system object is not the required type.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.

read

public int read(byte[] dataBuffer,
                int dataBufferOffset,
                int dataAreaOffset,
                int dataLength)
         throws AS400SecurityException,
                ErrorCompletingRequestException,
                IllegalObjectTypeException,
                InterruptedException,
                IOException,
                ObjectDoesNotExistException
Reads the data from the data area. It retrieves up to dataLength bytes, without conversion, beginning at offset dataAreaOffset in the data area. Note that the first byte in the data area is at offset 0.

Parameters:
dataBuffer - The buffer into which to read the data. Must be non-null.
dataBufferOffset - The starting offset in dataBuffer.
dataAreaOffset - The offset in the data area at which to start reading.
dataLength - The number of bytes to read. Valid values are from 1 through (data area size - dataAreaOffset).
Returns:
The total number of bytes read into the buffer.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
IllegalObjectTypeException - If the system object is not the required type.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.
See Also:
write(byte[],int,int,int)

write

public void write(String data)
           throws AS400SecurityException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException
Writes the data to the data area. It writes data to the beginning of the data area. The remaining characters in the data area are blank padded.

Parameters:
data - The data to be written.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.

write

public void write(String data,
                  int dataAreaOffset)
           throws AS400SecurityException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException
Writes the data to the data area. It writes data.length() characters from data to the data area beginning at dataAreaOffset. The first character in the data area is at offset 0.

Parameters:
data - The data to be written.
dataAreaOffset - The offset in the data area at which to start writing.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.

write

public void write(String data,
                  int dataAreaOffset,
                  int type)
           throws AS400SecurityException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException
Writes the data to the data area. It writes data.length() characters from data to the data area beginning at dataAreaOffset. The first character in the data area is at offset 0.

Parameters:
data - The data to be written.
dataAreaOffset - The offset in the data area at which to start writing.
type - The Data Area bidi string type, as defined by the CDRA (Character Data Representataion Architecture). See BidiStringType for more information and valid values.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.

write

public void write(byte[] dataBuffer,
                  int dataBufferOffset,
                  int dataAreaOffset,
                  int dataLength)
           throws AS400SecurityException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException
Writes the data to the data area. It writes the specified bytes, without conversion, to the data area, at offset dataAreaOffset. Note that the first byte in the data area is at offset 0.

Parameters:
dataBuffer - The data to be written. Must be non-null.
dataBufferOffset - The starting offset in dataBuffer.
dataAreaOffset - The offset in the data area at which to start writing.
dataLength - The number of bytes to write.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.
See Also:
read(byte[],int,int,int)