|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 IBM i system. It contains FieldDescription objects that describe the data returned from a system. The RecordFormat class is used to generate a Record object that can be used to access the data returned from the system as Java objects or as byte arrays of IBM i data. For instance, the entries on a 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 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(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(String name)
Adds a key field description to this record format. |
void |
addPropertyChangeListener(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(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(String name)
Returns the field description with the specified name. |
FieldDescription[] |
getFieldDescriptions()
Returns the field descriptions that make up this object. |
String[] |
getFieldNames()
Returns the names of the field descriptions that make up this record format. |
int |
getIndexOfFieldName(String name)
Returns the index of the field description named name. |
int |
getIndexOfKeyFieldName(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(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. |
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(String name)
Returns the index of the field description on which the field description with the specified name depends. |
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,
String recordName)
Returns a new record based on this record format, which contains data from the specified byte array. |
Record |
getNewRecord(byte[] contents,
String recordName)
Returns a new record based on this record format, which contains data from the specified byte array. |
Record |
getNewRecord(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(String name)
Returns the index of the field description on which the field description with the specified name depends. |
String |
getRecordFormatID()
Returns the record format ID. |
int |
getRecordFormatType()
Returns the record format type. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener from the change list. |
void |
removeRecordDescriptionListener(RecordDescriptionListener listener)
Removes a listener from the record description listeners list. |
void |
removeVetoableChangeListener(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(String dependentField,
String fieldDependedOn)
Sets the field on which a dependent field depends. |
void |
setName(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(String dependentField,
String fieldDependedOn)
Sets the field on which a dependent field depends. |
void |
setRecordFormatID(String id)
Sets the record format ID. |
void |
setRecordFormatType(int type)
Sets the record format type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FIXED_LAYOUT_LENGTH
public static final int VARIABLE_LAYOUT_LENGTH
Constructor Detail |
---|
public RecordFormat()
RecordFormat(java.lang.String)
public RecordFormat(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.Method Detail |
---|
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(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(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(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(String name)
name
- The name of the field description. The name is
case sensitive.public FieldDescription[] getFieldDescriptions()
public String[] getFieldNames()
public int getIndexOfFieldName(String name)
name
- The name of the field description. The name
is case sensitive.public int getIndexOfKeyFieldName(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(String name)
name
- The name of the key field description. The name is
case sensitive.public FieldDescription[] getKeyFieldDescriptions()
public 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(String name)
name
- The name of the field description. The name is
case sensitive.public String getName()
public Record getNewRecord()
public Record getNewRecord(String recordName)
recordName
- The name to assign to the Record object being returned.public Record getNewRecord(byte[] contents) throws UnsupportedEncodingException
contents
- The data with which to initialize the contents of the record.
The length of contents must be greater than zero.UnsupportedEncodingException
- If an error occurs during conversion.public Record getNewRecord(byte[] contents, String recordName) throws 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.UnsupportedEncodingException
- If an error occurs during conversion.public Record getNewRecord(byte[] contents, int offset) throws 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.UnsupportedEncodingException
- If an error occurs during conversion.public Record getNewRecord(byte[] contents, int offset, String recordName) throws 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.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(String name)
name
- The name of the field description. The name is
case sensitive.public String getRecordFormatID()
public int getRecordFormatType()
public void removePropertyChangeListener(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(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(String dependentField, 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(String name) throws PropertyVetoException
name
- The name of this record format.
The name is converted to uppercase by this method.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(String dependentField, 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(String id)
id
- The record format ID.public void setRecordFormatType(int type)
type
- The record format type.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |