Serializablepublic class CharacterDataArea extends DataArea implements Serializable
The following example demonstrates the use of CharacterDataArea:
// Prepare to work with the system named "My400".
AS400 system = new AS400("My400");
// Create a CharacterDataArea object.
QSYSObjectPathName path = new QSYSObjectPathName("MYLIB", "MYDATA", "DTAARA");
CharacterDataArea dataArea = new CharacterDataArea(system, path.getPath());
// Create the character data area on the system using default values.
dataArea.create();
// Clear the data area.
dataArea.clear();
// Write to the data area.
dataArea.write("Hello world");
// Read from the data area.
String data = dataArea.read();
// Delete the data area from the system.
dataArea.delete();
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().
| Constructor | Description |
|---|---|
CharacterDataArea() |
Constructs a CharacterDataArea object.
|
CharacterDataArea(AS400 system,
String path) |
Constructs a CharacterDataArea object.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
clear() |
Resets the data area to contain all blanks.
|
void |
create() |
Creates a character data area on the system.
|
void |
create(int length,
String initialValue,
String textDescription,
String authority) |
Creates a character data area with the specified attributes.
|
void |
delete() |
Removes the data area from the system.
|
String |
getPath() |
Returns the integrated file system path name of the object represented by the data area.
|
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 |
setPath(String path) |
Sets the fully qualified data area name.
|
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.
|
addDataAreaListener, addPropertyChangeListener, addVetoableChangeListener, getLength, getName, getSystem, refreshAttributes, removeDataAreaListener, removePropertyChangeListener, removeVetoableChangeListener, setSystempublic CharacterDataArea()
public CharacterDataArea(AS400 system, String path)
system - The system that contains the data area.path - The fully qualified integrated file system path name. The
integrated file system file extension for a data area is DTAARA. An example of a
fully qualified integrated file system path to a data area "MYDATA" in library
"MYLIB" is: /QSYS.LIB/MYLIB.LIB/MYDATA.DTAARApublic void clear()
throws AS400SecurityException,
ErrorCompletingRequestException,
InterruptedException,
IOException,
ObjectDoesNotExistException
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.public void create()
throws AS400SecurityException,
ErrorCompletingRequestException,
InterruptedException,
IOException,
ObjectAlreadyExistsException,
ObjectDoesNotExistException
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.ObjectAlreadyExistsException - If the system object already exists.ObjectDoesNotExistException - If the system object does not exist.public void create(int length,
String initialValue,
String textDescription,
String authority)
throws AS400SecurityException,
ErrorCompletingRequestException,
InterruptedException,
IOException,
ObjectAlreadyExistsException,
ObjectDoesNotExistException
length - The maximum number of bytes in the data area.
Valid values are 1 through 2000.initialValue - The initial value for the data area.textDescription - The text description for the data area.
The maximum length is 50 characters.authority - The public authority level for the data area. Valid
values are *ALL, *CHANGE, *EXCLUDE, *LIBCRTAUT, *USE, or the name
of an authorization list. The maximum length is 10 characters.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.ObjectAlreadyExistsException - If the system object already exists.ObjectDoesNotExistException - If the system object does not exist.public void delete()
throws AS400SecurityException,
ErrorCompletingRequestException,
InterruptedException,
IOException,
ObjectDoesNotExistException
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 object does not exist.public String getPath()
public String read() throws AS400SecurityException, ErrorCompletingRequestException, IllegalObjectTypeException, InterruptedException, IOException, ObjectDoesNotExistException
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.public String read(int type) throws AS400SecurityException, ErrorCompletingRequestException, IllegalObjectTypeException, InterruptedException, IOException, ObjectDoesNotExistException
type - The Data Area bidi string type, as defined by the CDRA (Character
Data Representation Architecture). See
BidiStringType for more information and valid values.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.public String read(int dataAreaOffset, int dataLength) throws AS400SecurityException, ErrorCompletingRequestException, IllegalObjectTypeException, InterruptedException, IOException, ObjectDoesNotExistException
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).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.public String read(int dataAreaOffset, int dataLength, int type) throws AS400SecurityException, ErrorCompletingRequestException, IllegalObjectTypeException, InterruptedException, IOException, ObjectDoesNotExistException
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 Representation Architecture). See
BidiStringType for more information and valid values.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.public int read(byte[] dataBuffer,
int dataBufferOffset,
int dataAreaOffset,
int dataLength)
throws AS400SecurityException,
ErrorCompletingRequestException,
IllegalObjectTypeException,
InterruptedException,
IOException,
ObjectDoesNotExistException
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).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.write(byte[],int,int,int)public void setPath(String path) throws PropertyVetoException
// Create a CharacterDataArea object.
CharacterDataArea dataArea = new CharacterDataArea();
// Set its path to be the data area "MYDATA" in the library "MYLIB".
dataArea.setPath("/QSYS.LIB/MYLIB.LIB/MYDATA.DTAARA");
path - The fully qualified integrated file system path name of the data area.PropertyVetoException - If the change is vetoed.public void write(String data) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException
data - The data to be written.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.public void write(String data, int dataAreaOffset) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException
data - The data to be written.dataAreaOffset - The offset in the data area at which to start writing.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.public void write(String data, int dataAreaOffset, int type) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException
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 Representation Architecture). See
BidiStringType for more information and valid values.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.public void write(byte[] dataBuffer,
int dataBufferOffset,
int dataAreaOffset,
int dataLength)
throws AS400SecurityException,
ErrorCompletingRequestException,
InterruptedException,
IOException,
ObjectDoesNotExistException
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.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.Copyright © 2024. All rights reserved.