public class RecordFormat
extends java.lang.Object
implements java.io.Serializable
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 is also used to describe the record format of a record when using the LineDataRecordWriter class. The following record format attributes are required to be set.
The RecordFormat class allows the user to do the following:
RecordDescriptionEvent
AS400FileRecordDescription
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
FIXED_LAYOUT_LENGTH
This constant is only used for record level writing.
|
static int |
VARIABLE_LAYOUT_LENGTH
This constant is only used for record level writing.
|
Constructor and Description |
---|
RecordFormat()
Constructs a RecordFormat object.
|
RecordFormat(java.lang.String name)
Constructs a RecordFormat object.
|
Modifier and Type | Method and Description |
---|---|
void |
addFieldDescription(FieldDescription field)
Adds a field description to this record format.
|
void |
addKeyFieldDescription(int index)
Adds a key field description to this record format.
|
void |
addKeyFieldDescription(java.lang.String name)
Adds a key field description to this record format.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound
property is changed.
|
void |
addRecordDescriptionListener(RecordDescriptionListener listener)
Adds a listener to be notified when a RecordDescriptionEvent is fired.
|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained
property is changed.
|
char |
getDelimiter()
Returns the delimiter.
|
FieldDescription |
getFieldDescription(int index)
Returns the field description at the specified index.
|
FieldDescription |
getFieldDescription(java.lang.String name)
Returns the field description with the specified name.
|
FieldDescription[] |
getFieldDescriptions()
Returns the field descriptions that make up this object.
|
java.lang.String[] |
getFieldNames()
Returns the names of the field descriptions that make up this record format.
|
int |
getIndexOfFieldName(java.lang.String name)
Returns the index of the field description named name.
|
int |
getIndexOfKeyFieldName(java.lang.String name)
Returns the index of the field description of the key field named name.
|
FieldDescription |
getKeyFieldDescription(int index)
Returns the field description of the key field at the specified index.
|
FieldDescription |
getKeyFieldDescription(java.lang.String name)
Returns the field description of the key field with the specified name.
|
FieldDescription[] |
getKeyFieldDescriptions()
Returns the key field descriptions that make up this object.
|
java.lang.String[] |
getKeyFieldNames()
Returns the names of the field descriptions of the keys that make up this record format.
|
int |
getLengthDependency(int index)
Returns the index of the field description on which the field description at the specified
index depends.
|
int |
getLengthDependency(java.lang.String name)
Returns the index of the field description on which the field description with the specified
name depends.
|
java.lang.String |
getName()
Returns the name of this record format.
|
Record |
getNewRecord()
Returns a new record based on this record format, which contains default values for the
contents of the fields.
|
Record |
getNewRecord(byte[] contents)
Returns a new record based on this record format, which contains data from
the specified byte array.
|
Record |
getNewRecord(byte[] contents,
int offset)
Returns a new record based on this record format, which contains data from
the specified byte array.
|
Record |
getNewRecord(byte[] contents,
int offset,
java.lang.String recordName)
Returns a new record based on this record format, which contains data from
the specified byte array.
|
Record |
getNewRecord(byte[] contents,
java.lang.String recordName)
Returns a new record based on this record format, which contains data from
the specified byte array.
|
Record |
getNewRecord(java.lang.String recordName)
Returns a new record based on this record format, which contains default values for the
contents of the fields.
|
int |
getNumberOfFields()
Returns the number of field descriptions in this record format.
|
int |
getNumberOfKeyFields()
Returns the number of key field descriptions in this record format.
|
int |
getOffsetDependency(int index)
Returns the index of the field description on which the field description at the specified
index depends.
|
int |
getOffsetDependency(java.lang.String name)
Returns the index of the field description on which the field description with the specified
name depends.
|
java.lang.String |
getRecordFormatID()
Returns the record format ID.
|
int |
getRecordFormatType()
Returns the record format type.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener from the change list.
|
void |
removeRecordDescriptionListener(RecordDescriptionListener listener)
Removes a listener from the record description listeners list.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes a listener from the veto change listeners list.
|
void |
setDelimiter(char delimiter)
Sets the delimiter.
|
void |
setLengthDependency(int dependentField,
int fieldDependedOn)
Sets the field on which a dependent field depends.
|
void |
setLengthDependency(java.lang.String dependentField,
java.lang.String fieldDependedOn)
Sets the field on which a dependent field depends.
|
void |
setName(java.lang.String name)
Sets the name of this record format.
|
void |
setOffsetDependency(int dependentField,
int fieldDependedOn)
Sets the field on which a dependent field depends.
|
void |
setOffsetDependency(java.lang.String dependentField,
java.lang.String fieldDependedOn)
Sets the field on which a dependent field depends.
|
void |
setRecordFormatID(java.lang.String id)
Sets the record format ID.
|
void |
setRecordFormatType(int type)
Sets the record format type.
|
public static final int FIXED_LAYOUT_LENGTH
public static final int VARIABLE_LAYOUT_LENGTH
public RecordFormat()
RecordFormat(java.lang.String)
public RecordFormat(java.lang.String name)
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 file that is being described.public void addFieldDescription(FieldDescription field)
field
- The field description to be added.public void addKeyFieldDescription(int index)
index
- The index of a field description that was already
added to this object via addFieldDescription(). The index must
be in the range zero to getNumberOfFields() - 1.public void addKeyFieldDescription(java.lang.String name)
name
- The name of a field description that was already
added to this object via addFieldDescription(). The name is
case sensitive.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void addRecordDescriptionListener(RecordDescriptionListener listener)
listener
- The RecordDescriptionListener.removeRecordDescriptionListener(com.ibm.as400.access.RecordDescriptionListener)
public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The VetoableChangeListener.removeVetoableChangeListener(java.beans.VetoableChangeListener)
public char getDelimiter()
public FieldDescription getFieldDescription(int index)
index
- The index of the field description. The index must
be in the range zero to getNumberOfFields() - 1.public FieldDescription getFieldDescription(java.lang.String name)
name
- The name of the field description. The name is
case sensitive.public FieldDescription[] getFieldDescriptions()
public java.lang.String[] getFieldNames()
public int getIndexOfFieldName(java.lang.String name)
name
- The name of the field description. The name
is case sensitive.public int getIndexOfKeyFieldName(java.lang.String name)
name
- The name of the key field description. The name is
case sensitive.public FieldDescription getKeyFieldDescription(int index)
index
- The index of the key field description in the key field descriptions for this object.public FieldDescription getKeyFieldDescription(java.lang.String name)
name
- The name of the key field description. The name is
case sensitive.public FieldDescription[] getKeyFieldDescriptions()
public java.lang.String[] getKeyFieldNames()
public int getLengthDependency(int index)
index
- The index of the field description. The index must be in the range 0 to
getNumberOfFields() - 1.public int getLengthDependency(java.lang.String name)
name
- The name of the field description. The name is
case sensitive.public java.lang.String getName()
public Record getNewRecord()
public Record getNewRecord(java.lang.String recordName)
recordName
- The name to assign to the Record object being returned.public Record getNewRecord(byte[] contents) throws java.io.UnsupportedEncodingException
contents
- The data with which to initialize the contents of the record.
The length of contents must be greater than zero.java.io.UnsupportedEncodingException
- If an error occurs during conversion.public Record getNewRecord(byte[] contents, java.lang.String recordName) throws java.io.UnsupportedEncodingException
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.java.io.UnsupportedEncodingException
- If an error occurs during conversion.public Record getNewRecord(byte[] contents, int offset) throws java.io.UnsupportedEncodingException
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.java.io.UnsupportedEncodingException
- If an error occurs during conversion.public Record getNewRecord(byte[] contents, int offset, java.lang.String recordName) throws java.io.UnsupportedEncodingException
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.java.io.UnsupportedEncodingException
- If an error occurs during conversion.public int getNumberOfFields()
public int getNumberOfKeyFields()
public int getOffsetDependency(int index)
index
- The index of the field description. The index must be in the range 0 to
getNumberOfFields() - 1.public int getOffsetDependency(java.lang.String name)
name
- The name of the field description. The name is
case sensitive.public java.lang.String getRecordFormatID()
public int getRecordFormatType()
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void removeRecordDescriptionListener(RecordDescriptionListener listener)
listener
- The RecordDescriptionListener.addRecordDescriptionListener(com.ibm.as400.access.RecordDescriptionListener)
public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The VetoableChangeListener.addVetoableChangeListener(java.beans.VetoableChangeListener)
public void setDelimiter(char delimiter)
delimiter
- The delimiter.public void setLengthDependency(int dependentField, int fieldDependedOn)
dependentField
- The index of the dependent field. The
dependentField must be in the range 1 to getNumberOfFields() - 1.fieldDependedOn
- The index of a field on which this field depends. The fieldDependedOn must
be in the range 0 to dependentField.public void setLengthDependency(java.lang.String dependentField, java.lang.String fieldDependedOn)
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.public void setName(java.lang.String name) throws java.beans.PropertyVetoException
name
- The name of this record format.
The name is converted to uppercase by this method.java.beans.PropertyVetoException
- If a change is vetoed.public void setOffsetDependency(int dependentField, int fieldDependedOn)
dependentField
- The index of the dependent field. The
dependentField must be in the range 1 to getNumberOfFields() - 1.fieldDependedOn
- The index of a field on which this field depends. The fieldDependedOn must
be in the range 0 to dependentField.public void setOffsetDependency(java.lang.String dependentField, java.lang.String fieldDependedOn)
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.public void setRecordFormatID(java.lang.String id)
id
- The record format ID.public void setRecordFormatType(int type)
type
- The record format type.