All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.as400.access.RecordFormat
java.lang.Object
|
+----com.ibm.as400.access.RecordFormat
- public class RecordFormat
- extends Object
- implements Serializable
The RecordFormat class represents the format of data returned from an AS/400 system.
It contains FieldDescription objects that describe the
data returned from an AS/400. The RecordFormat class is used to generate a Record
object that can be used to access the data returned from the AS/400 as Java objects or
as byte arrays of AS/400 data.
For instance, the entries on an AS/400 data queue
may have a specific format. This format could be represented by a
RecordFormat object. The RecordFormat object could be used to generate a Record
object containing the data read from the data queue. Based on the description of the
data contained in the RecordFormat object, the Record object could be used by the Java
program to handle the data as Java objects. As another example, a parameter for a program
may be
an array of bytes representing several different types of data. Such a parameter
could be described by a RecordFormat object.
The RecordFormat class is also used to describe the record format of a file when using
the record-level database access classes. The record format of the file must be set prior
to invoking the open() method on an AS400File object.
The RecordFormat class allows the user to do the following:
- Describe the data returned from an AS/400.
- Retrieve a Record object containing data that is described by the RecordFormat.
RecordFormat objects generate the following events:
Examples
-
RecordFormat()
- Constructs a RecordFormat object.
Note: When using this object with the record level access classes,
the version of the constructor that takes name must be used.
-
RecordFormat(String)
- Constructs a RecordFormat object.
-
addFieldDescription(FieldDescription)
- Adds a field description to this record format.
-
addKeyFieldDescription(int)
- Adds a key field description to this record format.
-
addKeyFieldDescription(String)
- Adds a key field description to this record format.
-
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.
-
getFieldDescription(int)
- Returns the field description at the specified index.
-
getFieldDescription(String)
- Returns the field description with the specified name.
-
getFieldDescriptions()
- Returns the field descriptions that make up this object.
-
getFieldNames()
- Returns the names of the field descriptions that make up this record format.
-
getIndexOfFieldName(String)
- Returns the index of the field description named name.
-
getIndexOfKeyFieldName(String)
- Returns the index of the field description of the key field named name.
-
getKeyFieldDescription(int)
- Returns the field description of the key field at the specified index.
-
getKeyFieldDescription(String)
- Returns the field description of the key field with the specified name.
-
getKeyFieldDescriptions()
- Returns the key field descriptions that make up this object.
-
getKeyFieldNames()
- Returns the names of the field descriptions of the keys that make up this record format.
-
getLengthDependency(int)
- Returns the index of the field description on which the field description at the specified
index depends.
-
getLengthDependency(String)
- Returns the index of the field description on which the field description with the specified
name depends.
-
getName()
- Returns the name of this record format.
-
getNewRecord()
- Returns a new record based on this record format, which contains default values for the
contents of the fields.
-
getNewRecord(byte[])
- Returns a new record based on this record format, which contains data from
the specified byte array.
-
getNewRecord(byte[], int)
- Returns a new record based on this record format, which contains data from
the specified byte array.
-
getNewRecord(byte[], int, String)
- Returns a new record based on this record format, which contains data from
the specified byte array.
-
getNewRecord(byte[], String)
- Returns a new record based on this record format, which contains data from
the specified byte array.
-
getNewRecord(String)
- Returns a new record based on this record format, which contains default values for the
contents of the fields.
-
getNumberOfFields()
- Returns the number of field descriptions in this record format.
-
getNumberOfKeyFields()
- Returns the number of key field descriptions in this record format.
-
getOffsetDependency(int)
- Returns the index of the field description on which the field description at the specified
index depends.
-
getOffsetDependency(String)
- Returns the index of the field description on which the field description with the specified
name depends.
-
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.
-
setLengthDependency(int, int)
- Sets the field on which a dependent field depends.
-
setLengthDependency(String, String)
- Sets the field on which a dependent field depends.
-
setName(String)
- Sets the name of this record format.
-
setOffsetDependency(int, int)
- Sets the field on which a dependent field depends.
-
setOffsetDependency(String, String)
- Sets the field on which a dependent field depends.
RecordFormat
public RecordFormat()
- Constructs a RecordFormat object.
Note: When using this object with the record level access classes,
the version of the constructor that takes name must be used.
- See Also:
- RecordFormat
RecordFormat
public RecordFormat(String name)
- Constructs a RecordFormat object. It uses the name specified.
Note: Use this version of the constructor when the object is
being used with the record level access classes.
- Parameters:
- name - The name of the record format. The name is converted
to uppercase by this method. When using this object with the record level
access classes, the name must be the name of the record format for
the AS/400 file that is being described.
addFieldDescription
public void addFieldDescription(FieldDescription field)
- Adds a field description to this record format. The field description
is added to the end of the field descriptions in this object.
- Parameters:
- field - The field description to be added.
addKeyFieldDescription
public void addKeyFieldDescription(int index)
- Adds a key field description to this record format.
The key field description is determined by the index of a field description
that was already added to this object. The key field description
is added to the end of the key field descriptions in this object.
The order in which the key field descriptions are added must match
the order of the key fields in the files for which this record format
is meant.
- Parameters:
- index - The index of a field description that was already
added to this object via addFieldDescription(). The index must
be between zero and getNumberOfFields() - 1.
addKeyFieldDescription
public void addKeyFieldDescription(String name)
- Adds a key field description to this record format.
The key field description is determined by the name of a field description
that was already added to this object. The key field description
is added to the end of the key field descriptions in this object.
The order in which the key field descriptions are added must match
the order of the key fields in the files for which this record format
is meant.
- Parameters:
- name - The name of a field description that was already
added to this object via addFieldDescription(). The name is
case sensitive.
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
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
getFieldDescription
public FieldDescription getFieldDescription(int index)
- Returns the field description at the specified index.
- Parameters:
- index - The index of the field description. The index must
be between zero and getNumberOfFields() - 1.
- Returns:
- The field description.
getFieldDescription
public FieldDescription getFieldDescription(String name)
- Returns the field description with the specified name.
- Parameters:
- name - The name of the field description. The name is
case sensitive.
- Returns:
- The field description.
getFieldDescriptions
public FieldDescription[] getFieldDescriptions()
- Returns the field descriptions that make up this object.
- Returns:
- The field descriptions. An array of size zero is returned if no
fields have been added to this object.
getFieldNames
public String[] getFieldNames()
- Returns the names of the field descriptions that make up this record format.
- Returns:
- The names of the field descriptions. An array of size zero is
returned if no fields have been added to this object.
getIndexOfFieldName
public int getIndexOfFieldName(String name)
- Returns the index of the field description named name.
- Parameters:
- name - The name of the field description. The name
is case sensitive.
- Returns:
- The index of the field description.
getIndexOfKeyFieldName
public int getIndexOfKeyFieldName(String name)
- Returns the index of the field description of the key field named name.
- Parameters:
- name - The name of the key field description. The name is
case sensitive.
- Returns:
- The index of the key field description. This is the index of the key field description
in the key field descriptions for this object. It is not the index of the field description in the
field descriptions for this object.
getKeyFieldDescription
public FieldDescription getKeyFieldDescription(int index)
- Returns the field description of the key field at the specified index.
- Parameters:
- index - The index of the key field description in the key field descriptions for this object.
- Returns:
- The key field description.
getKeyFieldDescription
public FieldDescription getKeyFieldDescription(String name)
- Returns the field description of the key field with the specified name.
- Parameters:
- name - The name of the key field description. The name is
case sensitive.
- Returns:
- The key field description.
getKeyFieldDescriptions
public FieldDescription[] getKeyFieldDescriptions()
- Returns the key field descriptions that make up this object.
- Returns:
- The key field descriptions.
getKeyFieldNames
public String[] getKeyFieldNames()
- Returns the names of the field descriptions of the keys that make up this record format.
- Returns:
- The names of the key field descriptions. If no key field descriptions exist,
an array of size 0 is returned.
getLengthDependency
public int getLengthDependency(int index)
- Returns the index of the field description on which the field description at the specified
index depends.
- Parameters:
- index - The index of the field description. The index must be between 0 and
getNumberOfFields() - 1.
- Returns:
- The index of the field description on which the field description at the specified
index depends.
If index is not the index of a dependent field, -1 is returned.
getLengthDependency
public int getLengthDependency(String name)
- Returns the index of the field description on which the field description with the specified
name depends.
- Parameters:
- name - The name of the field description. The name is
case sensitive.
- Returns:
- The index of the field description on which the field description with the specified
name depends.
If name is not the name of a dependent field, -1 is returned.
getName
public String getName()
- Returns the name of this record format.
- Returns:
- The name of this record format. If the name has not been
set, an empty string is returned.
getNewRecord
public Record getNewRecord()
- Returns a new record based on this record format, which contains default values for the
contents of the fields. The default values are determined as follows:
- Use the value specified for the DFT keyword on the field description 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 field description object for
a particular field.
- Returns:
- A record based on this record format. If no field descriptions have been
added to this object, null is returned.
getNewRecord
public Record getNewRecord(String recordName)
- Returns a new record based on this record format, which contains default values for the
contents of the fields. The default values are determined as follows:
- Use the value specified for the DFT keyword on the field description 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 field description object for
a particular field.
- Parameters:
- recordName - The name to assign to the Record object being returned.
- Returns:
- A record based on this record format.
If no field descriptions have been added to this object, null is returned.
getNewRecord
public Record getNewRecord(byte contents[]) throws UnsupportedEncodingException
- Returns a new record based on this record format, which contains data from
the specified byte array.
- Parameters:
- contents - The data with which to initialize the contents of the record.
The length of contents must be greater than zero.
- Returns:
- A record based on this record format.
If no field descriptions have been added to this object, null is returned.
- Throws: UnsupportedEncodingException
- If an error occurs during conversion.
getNewRecord
public Record getNewRecord(byte contents[],
String recordName) throws UnsupportedEncodingException
- Returns a new record based on this record format, which contains data from
the specified byte array.
- Parameters:
- contents - The data with which to initialize the contents of the record.
The length of contents must be greater than zero.
- recordName - The name to assign to the Record object being returned.
- Returns:
- A record based on this record format.
If no field descriptions have been added to this object, null is returned.
- Throws: UnsupportedEncodingException
- If an error occurs during conversion.
getNewRecord
public Record getNewRecord(byte contents[],
int offset) throws UnsupportedEncodingException
- Returns a new record based on this record format, which contains data from
the specified byte array.
- Parameters:
- contents - The data with which to initialize the contents of the record.
The length of contents must be greater than zero.
- offset - The offset in contents at which to start. The offset
cannot be less than zero.
- Returns:
- A record based on this record format.
If no field descriptions have been added to this object, null is returned.
- Throws: UnsupportedEncodingException
- If an error occurs during conversion.
getNewRecord
public Record getNewRecord(byte contents[],
int offset,
String recordName) throws UnsupportedEncodingException
- Returns a new record based on this record format, which contains data from
the specified byte array.
- Parameters:
- contents - The data with which to initialize the contents of the record.
The length of contents must be greater than zero.
- offset - The offset in contents at which to start. The offset
cannot be less than zero.
- recordName - The name to assign to the Record object being returned.
- Returns:
- A record based on this record format.
If no field descriptions have been added to this object, null is returned.
- Throws: UnsupportedEncodingException
- If an error occurs during conversion.
getNumberOfFields
public int getNumberOfFields()
- Returns the number of field descriptions in this record format.
- Returns:
- The number of field descriptions in this record format.
getNumberOfKeyFields
public int getNumberOfKeyFields()
- Returns the number of key field descriptions in this record format.
- Returns:
- The number of key field descriptions in this record format.
getOffsetDependency
public int getOffsetDependency(int index)
- Returns the index of the field description on which the field description at the specified
index depends.
- Parameters:
- index - The index of the field description. The index must be between 0 and
getNumberOfFields() - 1.
- Returns:
- The index of the field description on which the field description at the specified
index depends.
If index is not the index of a dependent field, -1 is returned.
getOffsetDependency
public int getOffsetDependency(String name)
- Returns the index of the field description on which the field description with the specified
name depends.
- Parameters:
- name - The name of the field description. The name is
case sensitive.
- Returns:
- The index of the field description on which the field description with the specified
name depends.
If name is not the name of a dependent field, -1 is returned.
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
setLengthDependency
public void setLengthDependency(int dependentField,
int fieldDependedOn)
- Sets the field on which a dependent field depends. Both fields must have been added already
to this RecordFormat. The fieldDependedOn must have been added prior to adding the
dependentField.
- Parameters:
- dependentField - The index of the dependent field. The
dependentField must be between 1 and getNumberOfFields() - 1.
- fieldDependedOn - The index of a field on which this field depends. The fieldDependedOn must
be between 0 and dependentField.
setLengthDependency
public void setLengthDependency(String dependentField,
String fieldDependedOn)
- Sets the field on which a dependent field depends. Both fields must have been added already
to this RecordFormat. The fieldDependedOn must have been added prior to adding the
dependentField. The names of the fields are
case sensitive.
- Parameters:
- dependentField - The name of the dependent field.
- fieldDependedOn - The name of a field on which this field depends. The index of
fieldDependedOn in this RecordFormat must be less than the index of dependentField.
setName
public void setName(String name) throws PropertyVetoException
- Sets the name of this record format.
- Parameters:
- name - The name of this record format.
The name is converted to uppercase by this method.
- Throws: PropertyVetoException
- If a change is vetoed.
setOffsetDependency
public void setOffsetDependency(int dependentField,
int fieldDependedOn)
- Sets the field on which a dependent field depends. Both fields must have been added already
to this RecordFormat. The fieldDependedOn must have been added prior to adding the
dependentField.
- Parameters:
- dependentField - The index of the dependent field. The
dependentField must be between 1 and getNumberOfFields() - 1.
- fieldDependedOn - The index of a field on which this field depends. The fieldDependedOn must
be between 0 and dependentField.
setOffsetDependency
public void setOffsetDependency(String dependentField,
String fieldDependedOn)
- Sets the field on which a dependent field depends. Both fields must have been added already
to this RecordFormat. The fieldDependedOn must have been added prior to adding the
dependentField. The names of the fields are
case sensitive.
- Parameters:
- dependentField - The name of the dependent field.
- fieldDependedOn - The name of a field on which this field depends. The index of
fieldDependedOn in this RecordFormat must be less than the index of dependentField.
All Packages Class Hierarchy This Package Previous Next Index