All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.as400.access.Record
java.lang.Object
|
+----com.ibm.as400.access.Record
- public class Record
- extends Object
- implements Serializable
The Record.java class represents the data described by a RecordFormat object.
It can represent:
- An entry in a data queue.
- The parameter data provided to or returned by a program call.
- A record to be written to or read from an AS/400 file.
- Any data returned from the AS/400 that needs to be converted
between AS/400 format and Java format.
Record objects generate the following events:
Examples
-
Record()
- Constructs a Record object.
-
Record(RecordFormat)
- Constructs a Record object.
-
Record(RecordFormat, byte[])
- Constructs a Record object.
-
Record(RecordFormat, byte[], int)
- Constructs a Record object.
-
Record(RecordFormat, byte[], int, String)
- Constructs a Record object.
-
Record(RecordFormat, byte[], String)
- Constructs a Record object.
-
Record(RecordFormat, String)
- Constructs a Record object.
-
addPropertyChangeListener(PropertyChangeListener)
- Adds a listener to be notified when the value of any bound
property is changed.
-
addRecordDescriptionListener(RecordDescriptionListener)
- Adds a listener to be notified when a RecordDescriptionEvent is fired.
-
addVetoableChangeListener(VetoableChangeListener)
- Adds a listener to be notified when the value of any constrained
property is changed.
-
getContents()
- Returns the contents of this record as a byte array of AS400 data.
-
getContents(OutputStream)
- Writes the contents of this record to the specified output stream.
-
getField(int)
- Returns the value of the field by index.
-
getField(String)
- Returns the value of the field by name.
-
getFields()
- Returns the values of the fields in the record.
-
getKeyFields()
- Returns the values of the key fields in the record.
-
getNumberOfFields()
- Returns the number of fields in this record.
-
getNumberOfKeyFields()
- Returns the number of key fields in this record.
-
getRecordFormat()
- Returns the record format for this record.
-
getRecordLength()
- Returns the record length of this record.
-
getRecordName()
- Returns the record name for this record.
-
getRecordNumber()
- Returns the record number of this record.
-
isNullField(int)
- Indicates if the field is null.
-
isNullField(String)
- Indicates if the field is null.
-
removePropertyChangeListener(PropertyChangeListener)
- Removes a listener from the change list.
-
removeRecordDescriptionListener(RecordDescriptionListener)
- Removes a listener from the record description listeners list.
-
removeVetoableChangeListener(VetoableChangeListener)
- Removes a listener from the veto change listeners list.
-
setContents(byte[])
- Sets the contents of this record from the specified byte array.
-
setContents(byte[], int)
- Sets the contents of this record from the specified byte array.
-
setContents(InputStream)
- Sets the contents of this record from the specified input stream.
-
setField(int, Object)
- Sets the contents of the field at index to value.
-
setField(String, Object)
- Sets the contents of the field with the specified name to value.
-
setRecordFormat(RecordFormat)
- Sets the record format for this record.
-
setRecordName(String)
- Sets the name for this record.
-
setRecordNumber(int)
- Sets the record number of this record.
-
toString()
- Returns the contents of this record formatted as a String.
Record
public Record()
- Constructs a Record object.
Record
public Record(RecordFormat recordFormat)
- Constructs a Record object. It uses the RecordFormat specified.
The contents of the record will be initialized to their default values. The default
values are determined as follows:
- Use the value specified for the DFT keyword on the FieldDescription object
contained in the RecordFormat object for a particular field.
- If no value was specified for the DFT keyword, use the default value from the
AS400DataType object specified when constructing the FieldDescription object for
a particular field.
- Parameters:
- recordFormat - Describes the contents of this record.
- See Also:
- RecordFormat
Record
public Record(RecordFormat recordFormat,
String recordName)
- Constructs a Record object. It uses the record's name and RecordFormat specified.
The contents of the record will be initialized to their default values. The default
values are determined as follows:
- Use the value specified for the DFT keyword on the FieldDescription object for
a particular field.
- If no value was specified for the DFT keyword, use the default value from the
AS400DataType object specified when constructing the FieldDescription object for
a particular field.
- Parameters:
- recordFormat - Describes the contents of this record.
- recordName - The name to assign to the record.
Record
public Record(RecordFormat recordFormat,
byte contents[]) throws UnsupportedEncodingException
- Constructs a Record object. It uses the specified RecordFormat and a byte array
with which to initialize the contents of the record.
- Parameters:
- recordFormat - Describes the contents of this record.
- contents - The contents to which to initialize the record.
Note: When using this object for the record level access classes, if
isVariableLength()
returns true for a field, the first two bytes of the data provided for
that field must contain the length of the valid data. However, the number of bytes
provided for
the data for the field must equal the maximum field length for the field.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
Record
public Record(RecordFormat recordFormat,
byte contents[],
String recordName) throws UnsupportedEncodingException
- Constructs a Record object. It uses the specified the RecordFormat, a byte array
from which to initialize the contents of the record and the name of the record.
- Parameters:
- recordFormat - Describes the contents of this record.
- contents - The contents to which to initialize the record.
Note: When using this object for the record level access classes, if isVariableLength()
returns true for a field, the first two bytes of the data provided for
that field must contain the length of the valid data. However, the number of bytes provided for
the data for the field must equal the maximum field length for the field.
- recordName - The name to assign to the record.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
Record
public Record(RecordFormat recordFormat,
byte contents[],
int offset) throws UnsupportedEncodingException
- Constructs a Record object. It uses the specified RecordFormat and a byte array
from which to initialize the contents of the record.
- Parameters:
- recordFormat - Describes the contents of this record. The recordFormat
must contain at least one field description.
- contents - The contents to which to initialize the record.
Note: When using this object for the record level access classes, if isVariableLength()
returns true for a field, the first two bytes of the data provided for
that field must contain the length of the valid data. However, the number of bytes provided for
the data for the field must equal the maximum field length for the field.
- offset - The offset in contents at which to start. The offset cannot
be less than zero.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
Record
public Record(RecordFormat recordFormat,
byte contents[],
int offset,
String recordName) throws UnsupportedEncodingException
- Constructs a Record object. It uses the specified RecordFormat, a byte array
from which to initialize the record's contents and the record's name.
- Parameters:
- recordFormat - Describes the contents of this record.
- contents - The contents to which to initialize the record.
Note: When using this object for the record level access classes, if isVariableLength()
returns true for a field, the first two bytes of the data provided for
that field must contain the length of the valid data. However, the number of bytes provided for
the data for the field must equal the maximum field length for the field.
- offset - The offset in contents at which to start. The offset cannot
be less than zero.
- recordName - The name to assign to the record.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
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
addRecordDescriptionListener
public synchronized void addRecordDescriptionListener(RecordDescriptionListener listener)
- Adds a listener to be notified when a RecordDescriptionEvent is fired.
- Parameters:
- listener - The RecordDescriptionListener.
- See Also:
- removeRecordDescriptionListener
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
getContents
public byte[] getContents() throws CharConversionException, UnsupportedEncodingException
- Returns the contents of this record as a byte array of AS400 data.
Each field's contents will be placed into the byte array
based on the field description for the
field that is provided by the record format specified on construction of this object.
The data type object for the field description will be used to do any necessary conversion
of the contents of the field to the byte array.
Note: If a field is a variable-length field, the first two bytes of data for the field
contain the length of the valid data for the field. However, the number of bytes provided for the
field is the maximum length of the field as specified by the FieldDescription object for the
field in the record format for this object.
The record format for the record must be set prior to invoking this method.
- Returns:
- The contents of this record.
- Throws: CharConversionException
- If an error occurs when converting
the contents of a field to AS400 data.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the contents of a field to AS400 data.
- See Also:
- Record, setRecordFormat
getContents
public void getContents(OutputStream out) throws IOException
- Writes the contents of this record to the specified output stream.
Each field's contents will be written to out
based on the field description for the
field that is provided by the record format specified on construction of this object.
The data type object for the field description will be used to do any necessary conversion
of the contents of the field.
Note: If a field is a variable-length field, the first two bytes of data for the field
contain the length of the valid data for the field. However, the number of bytes provided for the
field is the maximum length of the field as specified by the FieldDescription object for the
field in the record format for this object.
The record format for the record must be set prior to invoking this method.
- Parameters:
- out - The stream to which to write the contents of the record.
- Throws: IOException
- If an I/O error occurs while communicating with the AS/400.
- See Also:
- Record, setRecordFormat
getField
public Object getField(int index) throws UnsupportedEncodingException
- Returns the value of the field by index.
The record format for the record must be set prior to invoking this method.
- Parameters:
- index - The position of the field in the record. This value must
be between 0 and getNumberOfFields() - 1 inclusive.
- Returns:
- The contents of the requested field.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
- See Also:
- Record, setRecordFormat
getField
public Object getField(String name) throws UnsupportedEncodingException
- Returns the value of the field by name.
The record format for the record must be set prior to invoking this method.
- Parameters:
- name - The name of the field.
- Returns:
- The contents of the requested field.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
- See Also:
- Record, setRecordFormat
getFields
public Object[] getFields() throws UnsupportedEncodingException
- Returns the values of the fields in the record.
- Returns:
- The values of the fields in the record. An array of size zero is
returned if the record format has not been set.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
getKeyFields
public Object[] getKeyFields() throws UnsupportedEncodingException
- Returns the values of the key fields in the record.
- Returns:
- The values of the key fields in the record.
An array of length 0 is returned if the record format has not been set
or if no key fields exist.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
getNumberOfFields
public int getNumberOfFields()
- Returns the number of fields in this record.
- Returns:
- The number of fields in this record. Zero is returned if the record
format has not been set.
getNumberOfKeyFields
public int getNumberOfKeyFields()
- Returns the number of key fields in this record.
- Returns:
- The number of key fields in this record. Zero is returned if the record
format has not been set.
getRecordFormat
public RecordFormat getRecordFormat()
- Returns the record format for this record.
- Returns:
- The record format for this record. If the record format has
not been set, null is returned.
getRecordLength
public int getRecordLength()
- Returns the record length of this record.
- Returns:
- The record length of this record. Zero is returned if the record format
for this object has not been set.
getRecordName
public String getRecordName()
- Returns the record name for this record.
- Returns:
- The name of this record. If the name has not been set,
an empty string is returned.
getRecordNumber
public int getRecordNumber()
- Returns the record number of this record. This method only pertains to the
record level access classes.
- Returns:
- The record number of this record. Zero is returned if no record number has been set.
isNullField
public boolean isNullField(int index)
- Indicates if the field is null.
The record format for the record must be set prior to invoking this method.
- Parameters:
- index - The index of the field. The index must be between
0 and getNumberOfFields() - 1.
- Returns:
- true if the field is null; false otherwise.
- See Also:
- Record, setRecordFormat
isNullField
public boolean isNullField(String name)
- Indicates if the field is null.
The record format for the record must be set prior to invoking this method.
- Parameters:
- name - The name of the field.
- Returns:
- true if the field is null; false otherwise.
- See Also:
- Record, setRecordFormat
removePropertyChangeListener
public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
- Removes a listener from the change list.
If the listener is not on the list, do nothing.
- Parameters:
- listener - The PropertyChangeListener.
- See Also:
- addPropertyChangeListener
removeRecordDescriptionListener
public synchronized void removeRecordDescriptionListener(RecordDescriptionListener listener)
- Removes a listener from the record description listeners list.
If the listener is not on the list, do nothing.
- Parameters:
- listener - The RecordDescriptionListener.
- See Also:
- addRecordDescriptionListener
removeVetoableChangeListener
public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
- Removes a listener from the veto change listeners list.
If the listener is not on the list, do nothing.
- Parameters:
- listener - The VetoableChangeListener.
- See Also:
- addVetoableChangeListener
setContents
public void setContents(byte contents[]) throws UnsupportedEncodingException
- Sets the contents of this record from the specified byte array.
The contents of each field will be set from contents
based on the field description for the
field that is provided by the record format specified on construction of this object.
The data type object for the field description will be used to do any necessary conversion
of the data from the byte array.
Note: When using this object for the record level access classes, if isVariableLength()
returns true for a field, the first two bytes of the data provided for
that field must contain the length of the valid data. However, the number of bytes provided for
the data for the field must equal the maximum field length for the field.
The record format for the record must be set prior to invoking this method.
- Parameters:
- contents - The data with which to set the contents of this record.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
- See Also:
- Record, setRecordFormat
setContents
public void setContents(byte contents[],
int offset) throws UnsupportedEncodingException
- Sets the contents of this record from the specified byte array.
The contents of each field will be set from contents
based on the field description for the
field that is provided by the record format specified on construction of this object.
The data type object for the field description will be used to do any necessary conversion
of the data from the byte array.
Note: When using this object for the record level access classes, if isVariableLength()
returns true for a field, the first two bytes of the data provided for
that field must contain the length of the valid data. However, the number of bytes provided for
the data for the field must equal the maximum field length for the field.
The record format for the record must be set prior to invoking this method.
- Parameters:
- contents - The data with which to set the contents of this record.
- offset - The offset in contents at which to start.
- Throws: UnsupportedEncodingException
- If an error occurs when converting
the AS400 data to a Java Object.
- See Also:
- Record, setRecordFormat
setContents
public void setContents(InputStream in) throws IOException
- Sets the contents of this record from the specified input stream.
The contents of each field will be set from in based on the field description for the
field that is provided by the record format specified on construction of this object.
The data type object for the field description will be used to do any necessary conversion
of the data from the input stream.
Note: When using this object for the record level access classes, if isVariableLength()
returns true for a field, the first two bytes of the data provided for
that field must contain the length of the data.
The record format for the record must be set prior to invoking this method.
- Parameters:
- in - The stream from which to read the data.
- Throws: IOException
- If an I/O error occurs while communicating with the AS/400.
- See Also:
- Record, setRecordFormat
setField
public void setField(int index,
Object value)
- Sets the contents of the field at index to value.
The record format for the record must be set prior to invoking this method.
- Parameters:
- index - The position in this record of the field whose contents are to be set. The index must be between 0 and getNumberOfFields() - 1.
- value - The value to which to set the contents of the field. Specify null for
value to indicate that the field is null.
- See Also:
- Record, setRecordFormat
setField
public void setField(String name,
Object value)
- Sets the contents of the field with the specified name to value.
The record format for the record must be set prior to invoking this method.
- Parameters:
- name - The name of the field whose contents are to be set.
- value - The value to which to set the contents of the field. Specify null for
value to indicate that the field is null.
- See Also:
- Record, setRecordFormat
setRecordFormat
public void setRecordFormat(RecordFormat recordFormat) throws PropertyVetoException
- Sets the record format for this record.
- Parameters:
- recordFormat - The record format for this record.
- Throws: PropertyVetoException
- If a change is vetoed.
setRecordName
public void setRecordName(String name) throws PropertyVetoException
- Sets the name for this record.
- Parameters:
- name - The name for this record.
- Throws: PropertyVetoException
- If a change is vetoed.
setRecordNumber
public void setRecordNumber(int recordNumber) throws PropertyVetoException
- Sets the record number of this record. This method only pertains to the record
level access class SequentialFile when a write or update by record number
is being done.
- Parameters:
- recordNumber - The record number of this record. The
recordNumber must be greater than 0.
- Throws: PropertyVetoException
- If a change is vetoed.
toString
public String toString()
- Returns the contents of this record formatted as a String. If a field is null,
"null" is substituted for the contents of the field in the string representation
of this record.
- Returns:
- The contents of this record. The empty string is returned if the
record has not contents.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index