Data area
The IBM® Toolbox for Java™ DataArea class is an abstract base class that represents an IBM i data area object.
This base class has four subclasses that support the following: character data, decimal data, logical data, and local data areas that contain character data.
Using the DataArea class, you can do the following:
- Get the size of the data area
- Get the name of the data area
- Return the AS400 system object for the data area
- Refresh the attributes of the data area
- Set the system where the data area exists
Using the DataArea class causes the AS400 object to connect to the server. See managing connections for information about managing connections.
CharacterDataArea
The CharacterDataArea class represents a data area on the server that contains character data. Character data areas do not have a facility for tagging the data with the proper CCSID; therefore, the data area object assumes that the data is in the user's CCSID. When writing, the data area object converts from a string (Unicode) to the user's CCSID before writing the data to the server. When reading, the data area object assumes that the data is the CCSID of the user and converts from that CCSID to Unicode before returning the string to the program. When reading data from the data area, the amount of data read is by number of characters, not by the number of bytes.
Using the CharacterDataArea class, you can do the following:
- Clear the data area so that it contains all blanks.
- Create a character data area on the system using default property values
- Create a character data area with specific attributes
- Delete the data area from the system where the data area exists
- Return the IFS path name of the object represented by the data area.
- Read all of the data that is contained in the data area
- Read a specified amount of data from the data area starting at offset 0 or the offset that you specified
- Set the fully qualified integrated file system path name of the data area
- Write data to the beginning of the data area
- Write a specified amount of data to the data area starting at offset 0 or the offset that you specified
DecimalDataArea
The DecimalDataArea class represents a data area on the server that contains decimal data.
Using the DecimalDataArea class, you can do the following:
- Clear the data area so that it contains 0.0
- Create a decimal data area on the system using default property values
- Create a decimal data area with specified attributes
- Delete the data area from the server where the data area exists
- Return the number of digits to the right of the decimal point in the data area
- Return the IFS path name of the object represented by the data area.
- Read all of the data that is contained in the data area
- Set the fully qualified integrated file system path name of the data area
- Write data to the beginning of the data area
// Establish a connection to the server "MyServer".
AS400 system = new AS400("MyServer");
// Create a DecimalDataArea object.
QSYSObjectPathName path = new QSYSObjectPathName("MYLIB", "MYDATA", "DTAARA");
DecimalDataArea dataArea = new DecimalDataArea(system, path.getPath());
// Create the decimal data area on the server using default values.
dataArea.create();
// Clear the data area.
dataArea.clear();
// Write to the data area.
dataArea.write(new BigDecimal("1.2"));
// Read from the data area.
BigDecimal data = dataArea.read();
// Delete the data area from the server.
dataArea.delete();LocalDataArea
The LocalDataArea class represents a local data area on the server. A local data area exists as a character data area on the server, but the local data area does have some restrictions of which you should be aware.
The local data area is associated with a server job and cannot be accessed from another job. Therefore, you cannot create or delete the local data area. When the server job ends, the local data area associated with that server job is automatically deleted, and the LocalDataArea object that is referring to the job is no longer valid. You should also note that local data areas are a fixed size of 1024 characters on the server.
Using the LocalDataArea class, you can do the following:
- Clear the data area so that it contains all blanks
- Read all of the data that is contained in the data area
- Read a specified amount of data from the data area starting at offset that you specified
- Write data to the beginning of the data area
- Write a specified amount of data to the data area where the first character is written to offset
LogicalDataArea
The LogicalDataArea class represents a data area on the server that contains logical data.
Using the LogicalDataArea class, you can do the following:
- Clear the data area so that it contains false
- Create a character data area on the server using default property values
- Create a character data area with specified attributes
- Delete the data area from the server where the data area exists
- Return the IFS path name of the object represented by the data area.
- Read all of the data that is contained in the data area
- Set the fully qualified integrated file system path name of the data area
- Write data to the beginning of the data area
DataAreaEvent
The DataAreaEvent class represents a data area event.
You can use the DataAreaEvent class with any of the DataArea classes. Using the DataAreaEvent class, you can do the following:
- Get the identifier for the event
DataAreaListener
The DataAreaListener class provides an interface for receiving data area events.
You can use the the DataAreaListener class with any of the DataArea classes. You can invoke the DataAreaListener class when any of the following are performed:
- Clear
- Create
- Delete
- Read
- Write