com.ibm.jtopenlite.ddm
Class DDMField
- java.lang.Object
-
- com.ibm.jtopenlite.ddm.DDMField
-
public final class DDMField extends java.lang.Object
Represents an individual field of a record format.
-
-
Field Summary
Fields Modifier and Type Field and Description static char
TYPE_BINARY
static char
TYPE_BINARY_CHARACTER
static char
TYPE_CHARACTER
static char
TYPE_DATE
static char
TYPE_DBCS_EITHER
static char
TYPE_DBCS_GRAPHIC
static char
TYPE_DBCS_ONLY
static char
TYPE_DBCS_OPEN
static char
TYPE_DECIMAL_FLOAT
static char
TYPE_FLOAT
static char
TYPE_HEXADECIMAL
static char
TYPE_PACKED_DECIMAL
static char
TYPE_TIME
static char
TYPE_TIMESTAMP
static char
TYPE_ZONED_DECIMAL
-
Method Summary
Methods Modifier and Type Method and Description int
getAllocatedLength()
Returns the database allocated length (WHALLC) of this field.byte
getByte(byte[] recordData)
Converts the specified record data at this field's offset into a byte value, if possible.byte[]
getBytes(byte[] recordData)
Returns an array of bytes that is only this field's data, which is a subset of the specified record data.int
getCCSID()
Returns the CCSID (WHCCSID) of this field.boolean
getDate(byte[] recordData, java.util.Calendar cal)
Converts the specified record data at this field's offset into a date, time, or timestamp, if possible, and sets the appropriate fields in the provided Calendar object.java.lang.String
getDateTimeFormat()
Returns the date/time format (WHFMT) of this field.java.lang.String
getDateTimeSeparator()
Returns the date/time separator (WHSEP) of this field.int
getDecimalPositions()
Returns the number of decimal positions (WHFLDP) of this field.java.lang.String
getDefaultValue()
Returns the default value (WHDFT) of this field.double
getDouble(byte[] recordData)
Converts the specified record data at this field's offset into a double value, if possible.float
getFloat(byte[] recordData)
Converts the specified record data at this field's offset into a float value, if possible.int
getInt(byte[] recordData)
Converts the specified record data at this field's offset into an int value, if possible.int
getLength()
Returns the length (WHFLDB) of this field.long
getLong(byte[] recordData)
Converts the specified record data at this field's offset into a long value, if possible.java.lang.String
getName()
Returns the name (WHFLDE) of this field.int
getNumberOfDigits()
Returns the total number of digits (WHFLDO) of this field.int
getOffset()
Returns the offset in the record data where this field begins.short
getShort(byte[] recordData)
Converts the specified record data at this field's offset into a short value, if possible.java.lang.String
getString(byte[] recordData)
Converts the specified record data at this field's offset directly into a String value, if possible.java.lang.String
getText()
Returns the text description (WHFTXT) of this field.char
getType()
Returns the type (WHFLDT) of this field.boolean
isCacheStrings()
Indicates ifgetString()
will cache previously created String values for memory conservation.boolean
isNullAllowed()
Indicates if this field allows null values (WHNULL).boolean
isVariableLength()
Indicates if this field is variable length (WHVARL).DDMField
newCopy()
Returns a new copy of this field, which is useful if multiple threads need to operate on the same field without contention, as this class is not threadsafe.void
setByte(byte value, byte[] recordData)
Converts the specified byte value into record data for this field's type at this field's offset, if possible.void
setBytes(byte[] value, byte[] recordData)
Converts the specified byte array value into record data at this field's offset, if possible.void
setCacheStrings(boolean useCache)
Enables or disables string caching for this field.void
setDate(java.util.Calendar cal, byte[] recordData)
Converts the specified Calendar value into record data for this field's type at this field's offset, if possible.void
setDouble(double value, byte[] recordData)
Converts the specified double value into record data for this field's type at this field's offset, if possible.void
setFloat(float value, byte[] recordData)
Converts the specified float value into record data for this field's type at this field's offset, if possible.void
setInt(int value, byte[] recordData)
Converts the specified int value into record data for this field's type at this field's offset, if possible.void
setLong(long value, byte[] recordData)
Converts the specified long value into record data for this field's type at this field's offset, if possible.void
setShort(short value, byte[] recordData)
Converts the specified short value into record data for this field's type at this field's offset, if possible.void
setString(java.lang.String value, byte[] recordData)
Converts the specified String value into record data for this field's type at this field's offset, if possible.
-
-
-
Field Detail
-
TYPE_CHARACTER
public static final char TYPE_CHARACTER
- See Also:
- Constant Field Values
-
TYPE_DBCS_EITHER
public static final char TYPE_DBCS_EITHER
- See Also:
- Constant Field Values
-
TYPE_DBCS_GRAPHIC
public static final char TYPE_DBCS_GRAPHIC
- See Also:
- Constant Field Values
-
TYPE_DBCS_ONLY
public static final char TYPE_DBCS_ONLY
- See Also:
- Constant Field Values
-
TYPE_DBCS_OPEN
public static final char TYPE_DBCS_OPEN
- See Also:
- Constant Field Values
-
TYPE_BINARY
public static final char TYPE_BINARY
- See Also:
- Constant Field Values
-
TYPE_FLOAT
public static final char TYPE_FLOAT
- See Also:
- Constant Field Values
-
TYPE_DECIMAL_FLOAT
public static final char TYPE_DECIMAL_FLOAT
- See Also:
- Constant Field Values
-
TYPE_HEXADECIMAL
public static final char TYPE_HEXADECIMAL
- See Also:
- Constant Field Values
-
TYPE_BINARY_CHARACTER
public static final char TYPE_BINARY_CHARACTER
- See Also:
- Constant Field Values
-
TYPE_DATE
public static final char TYPE_DATE
- See Also:
- Constant Field Values
-
TYPE_PACKED_DECIMAL
public static final char TYPE_PACKED_DECIMAL
- See Also:
- Constant Field Values
-
TYPE_ZONED_DECIMAL
public static final char TYPE_ZONED_DECIMAL
- See Also:
- Constant Field Values
-
TYPE_TIME
public static final char TYPE_TIME
- See Also:
- Constant Field Values
-
TYPE_TIMESTAMP
public static final char TYPE_TIMESTAMP
- See Also:
- Constant Field Values
-
-
Method Detail
-
newCopy
public DDMField newCopy()
Returns a new copy of this field, which is useful if multiple threads need to operate on the same field without contention, as this class is not threadsafe.
-
getName
public java.lang.String getName()
Returns the name (WHFLDE) of this field.
-
getType
public char getType()
Returns the type (WHFLDT) of this field.
-
getLength
public int getLength()
Returns the length (WHFLDB) of this field.
-
getOffset
public int getOffset()
Returns the offset in the record data where this field begins.
-
getText
public java.lang.String getText()
Returns the text description (WHFTXT) of this field.
-
getCCSID
public int getCCSID()
Returns the CCSID (WHCCSID) of this field.
-
getDefaultValue
public java.lang.String getDefaultValue()
Returns the default value (WHDFT) of this field.
-
isVariableLength
public boolean isVariableLength()
Indicates if this field is variable length (WHVARL).
-
isNullAllowed
public boolean isNullAllowed()
Indicates if this field allows null values (WHNULL).
-
getAllocatedLength
public int getAllocatedLength()
Returns the database allocated length (WHALLC) of this field.
-
getNumberOfDigits
public int getNumberOfDigits()
Returns the total number of digits (WHFLDO) of this field.
-
getDecimalPositions
public int getDecimalPositions()
Returns the number of decimal positions (WHFLDP) of this field.
-
getDateTimeFormat
public java.lang.String getDateTimeFormat()
Returns the date/time format (WHFMT) of this field.
-
getDateTimeSeparator
public java.lang.String getDateTimeSeparator()
Returns the date/time separator (WHSEP) of this field.
-
isCacheStrings
public boolean isCacheStrings()
Indicates ifgetString()
will cache previously created String values for memory conservation. This can be extremely helpful for fields that contain a finite number of distinct values across all the records in the file.- See Also:
setCacheStrings(boolean)
-
setCacheStrings
public void setCacheStrings(boolean useCache)
Enables or disables string caching for this field. If enabled,getString()
will cache previously created String values for the purposes of conserving memory. This can be extremely helpful for fields that contain a finite number of distinct values across all the records in the file.
-
getLong
public long getLong(byte[] recordData) throws java.io.IOException
Converts the specified record data at this field's offset into a long value, if possible.- Throws:
java.io.IOException
-
getShort
public short getShort(byte[] recordData) throws java.io.IOException
Converts the specified record data at this field's offset into a short value, if possible.- Throws:
java.io.IOException
-
getInt
public int getInt(byte[] recordData) throws java.io.IOException
Converts the specified record data at this field's offset into an int value, if possible.- Throws:
java.io.IOException
-
getByte
public byte getByte(byte[] recordData) throws java.io.IOException
Converts the specified record data at this field's offset into a byte value, if possible.- Throws:
java.io.IOException
-
getBytes
public byte[] getBytes(byte[] recordData) throws java.io.IOException
Returns an array of bytes that is only this field's data, which is a subset of the specified record data.- Throws:
java.io.IOException
-
setBytes
public void setBytes(byte[] value, byte[] recordData) throws java.io.IOException
Converts the specified byte array value into record data at this field's offset, if possible.- Throws:
java.io.IOException
-
getFloat
public float getFloat(byte[] recordData) throws java.io.IOException
Converts the specified record data at this field's offset into a float value, if possible.- Throws:
java.io.IOException
-
getDouble
public double getDouble(byte[] recordData) throws java.io.IOException
Converts the specified record data at this field's offset into a double value, if possible.- Throws:
java.io.IOException
-
getString
public java.lang.String getString(byte[] recordData) throws java.io.IOException
Converts the specified record data at this field's offset directly into a String value, if possible.- Throws:
java.io.IOException
-
getDate
public boolean getDate(byte[] recordData, java.util.Calendar cal) throws java.io.IOException
Converts the specified record data at this field's offset into a date, time, or timestamp, if possible, and sets the appropriate fields in the provided Calendar object.- Returns:
- true if the field data was converted and set into the Calendar object; false otherwise.
- Throws:
java.io.IOException
-
setDate
public void setDate(java.util.Calendar cal, byte[] recordData) throws java.io.IOException
Converts the specified Calendar value into record data for this field's type at this field's offset, if possible.- Throws:
java.io.IOException
-
setString
public void setString(java.lang.String value, byte[] recordData) throws java.io.IOException
Converts the specified String value into record data for this field's type at this field's offset, if possible.- Throws:
java.io.IOException
-
setDouble
public void setDouble(double value, byte[] recordData) throws java.io.IOException
Converts the specified double value into record data for this field's type at this field's offset, if possible.- Throws:
java.io.IOException
-
setFloat
public void setFloat(float value, byte[] recordData) throws java.io.IOException
Converts the specified float value into record data for this field's type at this field's offset, if possible.- Throws:
java.io.IOException
-
setByte
public void setByte(byte value, byte[] recordData) throws java.io.IOException
Converts the specified byte value into record data for this field's type at this field's offset, if possible.- Throws:
java.io.IOException
-
setShort
public void setShort(short value, byte[] recordData) throws java.io.IOException
Converts the specified short value into record data for this field's type at this field's offset, if possible.- Throws:
java.io.IOException
-
setInt
public void setInt(int value, byte[] recordData) throws java.io.IOException
Converts the specified int value into record data for this field's type at this field's offset, if possible.- Throws:
java.io.IOException
-
setLong
public void setLong(long value, byte[] recordData) throws java.io.IOException
Converts the specified long value into record data for this field's type at this field's offset, if possible.- Throws:
java.io.IOException
-
-