public abstract class LayoutField extends Object implements Serializable
Defines the properties of a data item whose value can be stored in a
Message. A LayoutField has a type, a name, a length, a
numeric scale and a default value. The values of these properties have
restrictions depending on the type of the field. For example, if the type of
a field is TEXT then its scale value must be defined as 0 (zero).
The following table shows the defined LayoutField types and their
property restrictions:
| Description | Type | Length or Occurrences | Numeric Scale | Default Value |
| Alpha numeric string | ALPHA |
Must be greater than 0 | Must be 0 | Empty string |
| Date | DATE |
Either 4, 6 or 8 | Must be 0 | 01-01-0001 |
| List array | LIST |
Must be greater than 0 | Must be 0 | Empty string |
| End of list array | LISTEND |
N/A (set to 0) | N/A (set to 0) | N/A (set to null) |
| Unsigned decimal | NUMERIC |
Must be greater than 0 | Greater or equal to 0 | 0 |
| Chilean RUT | RUT |
Must be greater than 1 | Must be 1 | 0-0 |
| Signed decimal | SIGNED |
Must be greater than 0 | Greater or equal to 0 | 0 |
| Text string | TEXT |
Must be greater than 0 | Must be 0 | Empty string |
A LayoutField of type LIST represents a list of fields
with multiple occurrences (an array). The number of occurrences of the fields
contained in the list is given by the length of the LIST. Each field
in this list is accessed using it's name and an index number
where (0 <= index < occurrences). The LISTEND type is used
to complete (or terminate) the definition of a LayoutField of type
LIST; it does not represent an actual field.
Layout,
Message,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
ALPHA
Alphanumeric layout field (A).
|
static int |
DATE
Date layout field (D).
|
static int |
LIST
List layout field (LB).
|
static int |
LISTEND
End-of-list pseudo layout field (LE).
|
static int |
NUMERIC
Unsigned number layout field (N).
|
static int |
RUT
RUT layout field (R).
|
static int |
SIGNED
Signed number layout field (S).
|
static int |
TEXT
Text layout field (X).
|
| Modifier and Type | Method and Description |
|---|---|
char |
getChar(Message message,
int index)
Returns the first character of the value of the
index occurence
of this field stored in message. |
String |
getData(Message message,
int index)
Returns the internal character sequence of the
index occurence of
this field in message. |
Date |
getDate(Message message,
int index)
Returns the date value of the
index occurence of this field
stored in message. |
String |
getDefault()
Returns the default value of this
LayoutField. |
String |
getDefinedDefault()
Returns the defined default value of this
LayoutField. |
double |
getDouble(Message message,
int index)
Returns the double value of the
index occurence of this field
stored in message. |
int |
getInteger(Message message,
int index)
Returns the integer value of the
index occurence of this field
stored in message. |
int |
getLength()
Returns the length of this
LayoutField. |
String |
getName()
Returns the name of this
LayoutField. |
BigDecimal |
getNumber(Message message,
int index)
Returns the decimal value of the
index occurence of this field
stored in message. |
int |
getOccurs()
Returns the number of occurrences of this
LayoutField. |
int |
getOffset(int index)
Returns the offset position of the
index occurence of this field
in the Message or it's parent list. |
LayoutField |
getParent()
Returns the list field that contains this
LayoutField. |
int |
getScale()
Returns the numeric scale of this
LayoutField. |
String |
getString(Message message,
int index)
Returns the string value of the
index occurence of this field
stored in message. |
abstract int |
getType()
Returns the type code of this
LayoutField. |
boolean |
isNull(Message message,
int index)
Returns
true is the data of the index occurence of this
field stored in message is NULL. |
void |
setChar(Message message,
int index,
char value)
Updates the character value of the
index occurence of this field
stored in message. |
void |
setData(Message message,
int index,
String data)
Updates the internal character sequence of the
index occurence of
this field in message. |
void |
setDate(Message message,
int index,
Date date)
Updates the date value of the
index occurence of this field
stored in message. |
void |
setDefault(Message message,
int index)
Updates the value of the
index occurence of this field in message to its default value. |
void |
setDouble(Message message,
int index,
double value)
Updates the double value of the
index occurence of this field
stored in message. |
void |
setInteger(Message message,
int index,
int value)
Updates the integer value of the
index occurence of this field
stored in message. |
void |
setNull(Message message,
int index)
Updates the data value of the
index occurence of this field with
the NULL value. |
void |
setNumber(Message message,
int index,
BigDecimal value)
Updates the decimal value of the
index occurence of this field
stored in message. |
void |
setString(Message message,
int index,
String value)
Updates the string value of the
index occurence of this field
stored in message. |
public static final int ALPHA
public static final int DATE
public static final int LIST
public static final int LISTEND
public static final int NUMERIC
public static final int RUT
public static final int SIGNED
public static final int TEXT
public abstract int getType()
LayoutField.public String getName()
LayoutField.public int getLength()
LayoutField.public int getScale()
LayoutField.public int getOccurs()
LayoutField.public String getDefinedDefault()
LayoutField. If the
LayoutField does not have a defined default value, it returns
null.null if the field
does not have a defined default value.getDefault()public String getDefault()
LayoutField. If the LayoutField does not have a defined default value, it returns the
default value associatted with its type. This method
never returns the null value.type.getDefinedDefault(),
getType()public void setDefault(Message message, int index)
index occurence of this field in message to its default value. If the field's default value is invalid,
then the type's default value is used.message - the message that will be updated.index - the occurence index of the field.IndexOutOfBoundsException - if index is out of bounds.getDefault()public LayoutField getParent()
LayoutField. If this
field does not belong to a list, it returns null. Fields of type
LIST always return null because list fields cannot be
defined (contained) within other lists.null.public int getOffset(int index)
index occurence of this field
in the Message or it's parent list.index - the occurence index of the field.IndexOutOfBoundsException - if index is out of bounds.public String getData(Message message, int index)
index occurence of
this field in message. The internal character sequence starts at
the offset position returned by the getOffset(int) method, and it's
length is given by the getLength() method. The trailing space
characters of the returned sequence are removed (right trimmed).message - the Message that will be read.index - the occurence index of the field.IndexOutOfBoundsException - if index is out of bounds.setData(Message, int, String),
getOffset(int),
getLength()public void setData(Message message, int index, String data)
index occurence of
this field in message. The character sequence starts at the
offset position returned by the getOffset(int) method, and it's
length is given by the getLength() method. If the value of data is too short, it is extended with space characters. If the value of
data is too long, it is truncated. If data is null the sequence is filled with NO-DATA (0x1a).message - the message that will be updated.index - the occurence index of the field.data - the new data of this field.IndexOutOfBoundsException - if index is out of bounds.IllegalArgumentException - if strict and data is too long.getData(Message, int),
getOffset(int),
getLength()public boolean isNull(Message message, int index)
true is the data of the index occurence of this
field stored in message is NULL. A field is NULL if
the first character of the sequence stored in Message is NO-DATA (0x1a).message - the message that will be read.index - the occurence index of the field.true if the data of the field is NULL.IndexOutOfBoundsException - if index is out of bounds.setNullpublic void setNull(Message message, int index)
index occurence of this field with
the NULL value. A field is NULL if the first character of
the sequence stored in Message is NO-DATA (0x1a).message - the message that will be read.index - the occurence index of the field.IndexOutOfBoundsException - if index is out of bounds.isNullpublic String getString(Message message, int index) throws IndexOutOfBoundsException
index occurence of this field
stored in message. If the value of the field is NULL (see
isNull for details) it returns null.message - the message that will be read.index - the occurence index of the field.null.IndexOutOfBoundsException - if index is out of bounds.setString(Message, int, String),
isNull(Message, int)public void setString(Message message, int index, String value) throws IndexOutOfBoundsException
index occurence of this field
stored in message. The value string is interpreted and
converted based on the field's type. The resulting value is then stored
as a sequence of characters in the message. If value is
null then the field's data is set to NULL (see isNull for details) .message - the message that will be updated.index - the occurence index of the field.value - the string representation of the field value.IndexOutOfBoundsException - if index is out of bounds.getString(Message, int),
isNull(Message, int)public char getChar(Message message, int index)
index occurence
of this field stored in message. If the value of the field is
NULL it returns ' ' (space) (see isNull for
details).message - the message that will be read.index - the occurence index of the field.IndexOutOfBoundsException - if index is out of bounds.setChar(Message, int, char),
isNull(Message, int)public void setChar(Message message, int index, char value)
index occurence of this field
stored in message. This is an utility method that calls the
setString method with a string
containing just the supplied character value.message - the message that will be updated.index - the occurence index of the field.value - the new character value of the field.IndexOutOfBoundsException - if index is out of bounds.getChar(Message, int),
isNull(Message, int)public BigDecimal getNumber(Message message, int index)
index occurence of this field
stored in message. This method can only be applied to fields of
type NUMERIC or SIGNED. If the value of the field is
NULL (see isNull for details) it returns null.message - the message that will be read.index - the occurence index of the field.IndexOutOfBoundsException - if index is out of bounds.UnsupportedOperationException - if the field's type is not
NUMERIC or SIGNED.setNumber(Message, int, BigDecimal),
isNull(Message, int)public void setNumber(Message message, int index, BigDecimal value)
index occurence of this field
stored in message. This method can only be applied to fields of
type NUMERIC and SIGNED. If decimal is null then the field's data is set to NULL (see isNull for details).message - the message that will be updated.index - the occurence index of the field.value - decimal value of the field.IndexOutOfBoundsException - if index is out of bounds.UnsupportedOperationException - if the field's type is not
NUMERIC or SIGNED.getNumber(Message, int),
isNull(Message, int)public double getDouble(Message message, int index)
index occurence of this field
stored in message. If the value of the field is NULL (see isNull for details) it returns 0. This is an
utility method that converts the number returned by the getNumber method to a double.message - the message that will be read.index - the occurence index of the field.0.IndexOutOfBoundsException - if index is out of bounds.UnsupportedOperationException - if the field's type is not
NUMERIC or SIGNED.setDouble(Message, int, double),
isNull(Message, int)public void setDouble(Message message, int index, double value)
index occurence of this field
stored in message. This is an utility method that calls the
setNumber method with value converted to a decimal.message - the message that will be updated.index - the occurence index of the field.value - the new double value of the field.IndexOutOfBoundsException - if index is out of bounds.UnsupportedOperationException - if the field's type is not
NUMERIC or SIGNED.getDouble(Message, int)public int getInteger(Message message, int index)
index occurence of this field
stored in message. If the value of the field is NULL (see isNull for details) it returns 0. This is an
utility method that converts the number returned by the getNumber method to an integer.message - the message that will be read.index - the occurence index of the field.0.IndexOutOfBoundsException - if index is out of bounds.UnsupportedOperationException - if the field's type is not
NUMERIC or SIGNED.setInteger(Message, int, int),
isNull(Message, int)public void setInteger(Message message, int index, int value)
index occurence of this field
stored in message. This is an utility method that calls the
setNumber method with value converted to a decimal.message - the message that will be updated.index - the occurence index of the field.value - the new integer value of the field.IndexOutOfBoundsException - if index is out of bounds.UnsupportedOperationException - if the field's type is not
NUMERIC or SIGNED.getInteger(Message, int)public Date getDate(Message message, int index)
index occurence of this field
stored in message. This method can only be applied to fields of
type DATE. If the value of the field is NULL (see isNull for details) it returns null.message - the message that will be read.index - the occurence index of the field.IndexOutOfBoundsException - if index is out of bounds.UnsupportedOperationException - if the field's type is not
DATE.setDate(Message, int, Date),
isNull(Message, int)public void setDate(Message message, int index, Date date)
index occurence of this field
stored in message. This method can only be applied to fields of
type DATE. If date is null then the field's data
is set to NULL (see isNull for details).message - the message that will be updated.index - the occurence index of the field.date - date value of the field.IndexOutOfBoundsException - if index is out of bounds.UnsupportedOperationException - if the field's type is not
DATE.getDate(Message, int),
isNull(Message, int)Copyright © OBCOM INGENIERIA S.A. (Chile). All Rights Reserved.