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:

RecordFormat objects generate the following events: Examples


Constructor Index

 o 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.
 o RecordFormat(String)
Constructs a RecordFormat object.

Method Index

 o addFieldDescription(FieldDescription)
Adds a field description to this record format.
 o addKeyFieldDescription(int)
Adds a key field description to this record format.
 o addKeyFieldDescription(String)
Adds a key field description to this record format.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property is changed.
 o addRecordDescriptionListener(RecordDescriptionListener)
Adds a listener to be notified when a RecordDescriptionEvent is fired.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property is changed.
 o getFieldDescription(int)
Returns the field description at the specified index.
 o getFieldDescription(String)
Returns the field description with the specified name.
 o getFieldDescriptions()
Returns the field descriptions that make up this object.
 o getFieldNames()
Returns the names of the field descriptions that make up this record format.
 o getIndexOfFieldName(String)
Returns the index of the field description named name.
 o getIndexOfKeyFieldName(String)
Returns the index of the field description of the key field named name.
 o getKeyFieldDescription(int)
Returns the field description of the key field at the specified index.
 o getKeyFieldDescription(String)
Returns the field description of the key field with the specified name.
 o getKeyFieldDescriptions()
Returns the key field descriptions that make up this object.
 o getKeyFieldNames()
Returns the names of the field descriptions of the keys that make up this record format.
 o getLengthDependency(int)
Returns the index of the field description on which the field description at the specified index depends.
 o getLengthDependency(String)
Returns the index of the field description on which the field description with the specified name depends.
 o getName()
Returns the name of this record format.
 o getNewRecord()
Returns a new record based on this record format, which contains default values for the contents of the fields.
 o getNewRecord(byte[])
Returns a new record based on this record format, which contains data from the specified byte array.
 o getNewRecord(byte[], int)
Returns a new record based on this record format, which contains data from the specified byte array.
 o getNewRecord(byte[], int, String)
Returns a new record based on this record format, which contains data from the specified byte array.
 o getNewRecord(byte[], String)
Returns a new record based on this record format, which contains data from the specified byte array.
 o getNewRecord(String)
Returns a new record based on this record format, which contains default values for the contents of the fields.
 o getNumberOfFields()
Returns the number of field descriptions in this record format.
 o getNumberOfKeyFields()
Returns the number of key field descriptions in this record format.
 o getOffsetDependency(int)
Returns the index of the field description on which the field description at the specified index depends.
 o getOffsetDependency(String)
Returns the index of the field description on which the field description with the specified name depends.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a listener from the change list.
 o removeRecordDescriptionListener(RecordDescriptionListener)
Removes a listener from the record description listeners list.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a listener from the veto change listeners list.
 o setLengthDependency(int, int)
Sets the field on which a dependent field depends.
 o setLengthDependency(String, String)
Sets the field on which a dependent field depends.
 o setName(String)
Sets the name of this record format.
 o setOffsetDependency(int, int)
Sets the field on which a dependent field depends.
 o setOffsetDependency(String, String)
Sets the field on which a dependent field depends.

Constructors

 o 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
 o 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.

Methods

 o 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.
 o 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.
 o 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.
 o 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
 o 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
 o 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
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o getKeyFieldDescriptions
 public FieldDescription[] getKeyFieldDescriptions()
Returns the key field descriptions that make up this object.

Returns:
The key field descriptions.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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:
  1. Use the value specified for the DFT keyword on the field description object for a particular field.
  2. 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.
 o 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:
  1. Use the value specified for the DFT keyword on the field description object for a particular field.
  2. 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o getNumberOfFields
 public int getNumberOfFields()
Returns the number of field descriptions in this record format.

Returns:
The number of field descriptions in this record format.
 o 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.
 o 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.
 o 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.
 o 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
 o 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
 o 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
 o 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.
 o 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.
 o 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.
 o 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.
 o 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