|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.candle.roma.kxm.KxmField
The KxmField class provides an interface to access a single field of a message: set and get a field value, get nested fields, and get field information. The KxmField object has two states: bound and unbound. It is bound when it refers to some message field and unbound otherwise. The KxmField.getField() method provided by the KxmMessage object is the primary method to get bound KxmField objects. Note that a KxmField object does not encapsulate the message field, but only provides access to it.
KxmMessage
,
KxmDate
,
KxmQName
,
KxmDuration
,
KxmException
,
KxmRange
Field Summary | |
static int |
DTYPE_DATE
Date field type. |
static int |
DTYPE_DATETIME
Date field type. |
static int |
DTYPE_GDAY
Date field type. |
static int |
DTYPE_GMONTH
Date field type. |
static int |
DTYPE_GMONTHDAY
Date field type. |
static int |
DTYPE_GYEAR
Date field type. |
static int |
DTYPE_GYEARMONTH
Date field type. |
static int |
DTYPE_NONE
Date field type. |
static int |
DTYPE_TIME
Date field type. |
static int |
EXACT
Field search option. |
static int |
FLAG_ARRAY
Field flag. |
static int |
FLAG_DEFAULT_VALUE
Field flag. |
static int |
FLAG_GROUP
Field flag. |
static int |
FLAG_ROOT
Field flag. |
static int |
FLAG_UNION
Field flag. |
static int |
FLAG_XMLATTR
Field flag. |
static int |
FLAG_XMLDOC
Field flag. |
static int |
FLAG_XMLELEM
Field flag. |
static int |
GET_SCHEMA_FIELDS
Field feature option. |
static int |
NTYPE_DECIMAL
Numeric field type. |
static int |
NTYPE_DOUBLE
Numeric field type. |
static int |
NTYPE_FLOAT
Numeric field type. |
static int |
NTYPE_INT16
Numeric field type. |
static int |
NTYPE_INT32
Numeric field type. |
static int |
NTYPE_INT64
Numeric field type. |
static int |
NTYPE_INT8
Numeric field type. |
static int |
NTYPE_INTEGER
Numeric field type. |
static int |
NTYPE_NONE
Numeric field type. |
static int |
NTYPE_UINT16
Numeric field type. |
static int |
NTYPE_UINT32
Numeric field type. |
static int |
NTYPE_UINT64
Numeric field type. |
static int |
NTYPE_UINT8
Numeric field type. |
static int |
SEARCH
Field search option. |
static int |
TYPE_BINARY
Field type. |
static int |
TYPE_BOOL
Field type. |
static int |
TYPE_DATE
Field type. |
static int |
TYPE_DURATION
Field type. |
static int |
TYPE_GROUP
Field type. |
static int |
TYPE_NUMBER
Field type. |
static int |
TYPE_QNAME
Field type. |
static int |
TYPE_STRING
Field type. |
static int |
TYPE_XMLATTR
Field type. |
static int |
TYPE_XMLELEM
Field type. |
static int |
UNIQUE
Field search option. |
Method Summary | |
KxmField |
applyFormat(int format)
Apply the specified format to the field. |
KxmField |
applyFormat(KxmFieldFormat format)
Apply the specified format to the field. |
KxmField |
at(int index)
Returns an array element at the specified index. |
void |
declareNs(java.lang.String fieldName,
java.lang.String prefix,
java.lang.String uri)
Declares an XML namespace on the specified field. |
KxmField |
findField(java.lang.String fieldName)
Returns the sub-field with the given name. |
KxmField |
findField(java.lang.String fieldName,
int options)
Returns the sub-field with the given name. |
int |
getArrayLen()
Returns the current number of elements in the array (a repeated group or a repeated XML element). |
KxmRange |
getArrayLenRange()
Returns minimum and maximum number of array elements. |
boolean |
getBool()
Returns a boolean value of the field. |
byte[] |
getByteArray()
Returns a binary stream value of the field. |
java.lang.String |
getCharacterData()
Returns character data of the XML field. |
KxmDate |
getDate()
Returns a date value of the field. |
int |
getDateType()
Returns a date field type. |
KxmField |
getDefault()
Returns a field object representing the default value of this field. |
double |
getDouble()
Returns a double value of the field. |
KxmDuration |
getDuration()
Returns a duration value of the field. |
KxmField |
getField(int index)
Returns an array element at the index. |
KxmField |
getField(int index,
int options)
Returns an array element at the index. |
KxmField |
getField(java.lang.String fieldName)
Returns a sub-field with the given name. |
KxmField |
getField(java.lang.String fieldName,
int options)
Returns a sub-field with the given name. |
int |
getFlags()
Returns field flags. |
long |
getHandle()
|
java.lang.String |
getLocalPart()
Returns a local part of the XML field name. |
long |
getLong()
Returns a long value of the field. |
java.lang.String |
getName()
Returns a name of the field. |
java.lang.String |
getNsPrefix()
Returns an XML namespace prefix of the field. |
java.lang.String |
getNsUri()
Returns an XML namespace URI of the field. |
int |
getNumericType()
Returns a numeric field type. |
int |
getNumOfFields()
Returns the number of fields in a group or summary number of immediate XML sub-elements and attributes for the current field. Note: several XML fields with the same name are considered as a single array field. |
int |
getNumOfFields(int options)
The same as above, but this method allows to specify the feature options. |
java.lang.Object |
getObject()
Returns a value of the field as the Object. |
KxmField |
getParent()
Returns a parent field. |
KxmQName |
getQName()
Returns a qualified name value of the field. |
java.lang.String |
getString()
Returns a string representation of the field value. |
int |
getType()
Returns a field type. |
KxmRange |
getValueLenRange()
Returns minimum and maximum length of a string or a binary value of the field. |
boolean |
isArray()
Returns true if the field is an array. |
boolean |
isDefaultValue()
Returns true if the field is a default value. |
boolean |
isEmpty()
Returns true if the field has no value or the field is not present in a message. |
boolean |
isGroup()
Returns true if the field can have sub-fields (the fields which have the FLAG_GROUP or the FLAG_XMLELEM flag set). |
boolean |
isInvalid()
Returns true if this KxmField object is not bound to any field. |
boolean |
isNil()
Returns true if the XML field is nil. |
boolean |
isRoot()
Returns true if the field is the root field of a message. |
static void |
loadMessageApi()
|
void |
set(byte[] data)
Sets a binary data to the field. |
void |
set(double d)
Sets a double value to the field. |
void |
set(KxmDate date)
Sets a date/time value to the field. |
void |
set(KxmDuration dur)
Sets a duration value to the field. |
void |
set(KxmField field)
Sets the field with a content of another field. |
void |
set(KxmQName qname)
Sets a qualified name value to the field. |
void |
set(long l)
Sets a long value to the field. |
void |
set(java.lang.Object a)
Sets an Object to the field. |
void |
set(java.lang.String str)
Sets a string value to the field. |
void |
setArrayLen(int l)
Sets the new length for the array. |
void |
setBool(boolean bool)
Sets a boolean value to the field. |
void |
setCharacterData(java.lang.String data)
Sets character data of the XML field. |
void |
setEmpty()
Removes content of the field. |
void |
setNil()
Marks the XML field as nil. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int TYPE_STRING
getType()
public static final int TYPE_NUMBER
getType()
public static final int TYPE_BINARY
getType()
public static final int TYPE_XMLELEM
getType()
public static final int TYPE_XMLATTR
getType()
public static final int TYPE_DATE
getType()
public static final int TYPE_GROUP
getType()
public static final int TYPE_BOOL
getType()
public static final int TYPE_QNAME
getType()
public static final int TYPE_DURATION
getType()
public static final int NTYPE_NONE
getNumericType()
public static final int NTYPE_UINT8
getNumericType()
public static final int NTYPE_INT8
getNumericType()
public static final int NTYPE_UINT16
getNumericType()
public static final int NTYPE_INT16
getNumericType()
public static final int NTYPE_UINT32
getNumericType()
public static final int NTYPE_INT32
getNumericType()
public static final int NTYPE_DECIMAL
getNumericType()
public static final int NTYPE_INTEGER
getNumericType()
public static final int NTYPE_DOUBLE
getNumericType()
public static final int NTYPE_UINT64
getNumericType()
public static final int NTYPE_INT64
getNumericType()
public static final int NTYPE_FLOAT
getNumericType()
public static final int EXACT
getField(String fieldName,int opt)
public static final int SEARCH
getField(String fieldName,int opt)
public static final int UNIQUE
getField(String fieldName,int opt)
public static final int DTYPE_NONE
getDateType()
public static final int DTYPE_DATE
getDateType()
public static final int DTYPE_TIME
getDateType()
public static final int DTYPE_DATETIME
getDateType()
public static final int DTYPE_GYEAR
getDateType()
public static final int DTYPE_GYEARMONTH
getDateType()
public static final int DTYPE_GMONTHDAY
getDateType()
public static final int DTYPE_GDAY
getDateType()
public static final int DTYPE_GMONTH
getDateType()
public static final int GET_SCHEMA_FIELDS
getNumOfFields(int options)
See getField(int index, int options)
public static final int FLAG_ROOT
getFlags()
public static final int FLAG_ARRAY
getFlags()
public static final int FLAG_GROUP
getFlags()
public static final int FLAG_DEFAULT_VALUE
getFlags()
public static final int FLAG_UNION
getFlags()
public static final int FLAG_XMLELEM
getFlags()
public static final int FLAG_XMLATTR
getFlags()
public static final int FLAG_XMLDOC
getFlags()
Method Detail |
public java.lang.String getName() throws KxmException
KxmException
- will be thrown on an error.public int getType() throws KxmException
KxmField.TYPE_STRING
KxmField.TYPE_BINARY
KxmField.TYPE_NUMBER
KxmField.TYPE_DATE
KxmField.TYPE_GROUP
KxmField.TYPE_XMLELEM
KxmField.TYPE_XMLATTR
KxmField.TYPE_BOOL
KxmField.TYPE_QNAME
KxmField.TYPE_DURATION
KxmException
- will be thrown on an error.public int getNumericType() throws KxmException
KxmField.NTYPE_NONE
- field is not a numberKxmField.NTYPE_DECIMAL
KxmField.NTYPE_DOUBLE
KxmField.NTYPE_FLOAT
KxmField.NTYPE_INTEGER
KxmField.NTYPE_INT8
KxmField.NTYPE_UINT8
KxmField.NTYPE_INT16
KxmField.NTYPE_UINT16
KxmField.NTYPE_INT32
KxmField.NTYPE_UINT32
KxmField.NTYPE_INT64
KxmField.NTYPE_UINT64
KxmException
- will be thrown on an error.public int getDateType() throws KxmException
KxmField.DTYPE_NONE
- the field is not a date.KxmField.DTYPE_TIME
- the field contains time information only.KxmField.DTYPE_DATE
- the field contains date information only.KxmField.DTYPE_DATETIME
- the field contains date and time information.KxmField.DTYPE_GYEAR
- the field contains year only.KxmField.DTYPE_GYEARMONTH
- the field contains year and month only.KxmField.DTYPE_GMONTHDAY
- the field contains month and day only.KxmField.DTYPE_GDAY
- the field contains day only.KxmField.DTYPE_GMONTH
- the field contains month only.KxmException
- will be thrown on an error.public KxmRange getValueLenRange() throws KxmException
KxmException
- will be thrown on an error.public KxmRange getArrayLenRange() throws KxmException
KxmException
- will be thrown on an error.public boolean isArray() throws KxmException
KxmException
- will be thrown on an error.public boolean isRoot() throws KxmException
KxmException
- will be thrown on an error.public boolean isGroup() throws KxmException
KxmException
- will be thrown on an error.public boolean isInvalid()
isEmpty()
method.public boolean isEmpty() throws KxmException
KxmException
- will be thrown on an error.public boolean isDefaultValue() throws KxmException
KxmException
- will be thrown on an error.public void setEmpty() throws KxmException
KxmException
- will be thrown on an error.public int getNumOfFields() throws KxmException
KxmException
- will be thrown on an error.public int getNumOfFields(int options) throws KxmException
options
- Feature options. It can be a combination of the
following constants:KxmField.GET_SCHEMA_FIELDS
- Count all fields
according to the DTD or the XML Schema definition, even if they are
not present in the message.
KxmException
- will be thrown on an error.public KxmField getField(java.lang.String fieldName) throws KxmException
fieldName
- Name of the field.KxmException
- will be thrown on an error.public KxmField getField(java.lang.String fieldName, int options) throws KxmException
fieldName
- Name of the field.opt
- Search options. It should be one of the following constants: KxmField.EXACT
- Return the immediate sub-field
(Based on the fact that the field name does not started from '*.').
KxmField.SEARCH
- Return the immediate sub-field.
If the field is not found, then find the sub-field at any nesting level.
KxmField.UNIQUE
- Search the sub-field with a
given name at any nesting level, check that it is unique -
only a single sub-field matches the specified name.
.(dot)
- Separates nested fields, the same as in a C structure. *(asterisk)
- Indicates zero or more intermediate fields.'(single quote)
- Can be used to protect dots to be interpreted as field
separators. The full field name to be protected should be surrounded by single quotes.
@
- Indicates an XML attribute. This should be the first character
of the field name.
doc()
- may be optionally enclosed in signle or double quotes.
A.B
- Field B located immediately under field A.A.*.B
- Field B located somewhere under field A. *.B
- Some field B. A.'My.Field'.C
- Field C located under "My.Field",
which is located under A. @B
- XML attribute B. A.@B
- XML attribute B of A element. A[@ID=1000].B
- The first element B under the first
element A with attribute ID equal to 1000. A.*
- Asterisk cannot be last. A..B
- Dot cannot be repeated. A.**.B
- Asterisk cannot be repeated. A*.B
- There should be a dot before the B. A'B.C'
- There should be a dot after A and before the opening quote.A.'B.C
- Unclosed quote. @A.@B
- XML attribute cannot have sub-attributes or sub-elements. A[ID=1000]
- Filter should be over an attribute value. KxmField.EXACT
option to
ensure that the API creates the specified XML element or attribute
exactly, and doesn't search for an already existing element or
attribute and resets it's value.msg.getField( "B" ).set(20);
msg.getField( "B", KxmField.EXACT ).set( 20 );
Result:KxmException
- will be thrown on an error.public KxmField getField(int index) throws KxmException
index
- A zero-based index of an array element.
The array grows if the specified index is higher
than the current upper bound of the array.KxmException
- will be thrown on an error.public KxmField getField(int index, int options) throws KxmException
index
- A zero-based index of an array element.
The array grows if the specified index is higher
than the current upper bound of the array.options
- Feature options. It can be a combination of the
following constants:KxmField.GET_SCHEMA_FIELDS
- Return the field
according to the DTD or the XML Schema definition, even if
the field is not present in the message.
KxmException
- will be thrown on an error.public KxmField findField(java.lang.String fieldName) throws KxmException
isInvalid()
method
returns true).
This function is the same as getField(String fieldName)
but does not throw exceptions. getField(String fieldName)
for details
on search logic and field name syntax.fieldName
- Name of the field.KxmException
- will be thrown on an error.public KxmField findField(java.lang.String fieldName, int options) throws KxmException
isInvalid()
method returns true).
This function is the same as getField(String fieldName)
but does not throw exceptions. getField(String fieldName)
for details
on search logic and field name syntax.fieldName
- Name of the field.options
- Search options getField(String fieldName, int options)
.KxmException
- will be thrown on an error.public KxmField getParent() throws KxmException
KxmException
- will be thrown on an error.public KxmField getDefault() throws KxmException
KxmException
- will be thrown on an error.public void set(java.lang.String str) throws KxmException
TYPE_BINARY
then the string should contain a
sequence of hexadecimal numbers, where each number representing a
value of single byte.TYPE_NUMBER
then the string
should contain a decimal or scientific (exponent) number.TYPE_DATE
then the string
should contain a date, time or both.KxmException
- will be thrown on an error.public void set(long l) throws KxmException
Field Data | Result |
string XML element XML attribute |
Decimal representation of the number. |
decimal | Passed value. |
int8 uint8 int16 uint16 int32 uint32 uint64 |
Passed value if it fits the type, error otherwise. |
integer int64 |
Passed value |
KxmException
- will be thrown on an error.public void set(double d) throws KxmException
Field Data | Result |
string XML element XML attribute |
Decimal representation of passed value, exponent representation is used if double is too big or too small. |
decimal | representation of passed value. If the value is too big to be present in non-exponent form, an error is returned. |
any other | Returns an Error. |
KxmException
- will be thrown on an error.public void set(KxmDate date) throws KxmException
KxmException
- will be thrown on an error.public void set(byte[] data) throws KxmException
TYPE_STRING
, TYPE_XMLELEM
or TYPE_XMLATTR
then the method represents the binary
array as a sequence of hexadecimal numbers, where each number
represents a value of a single byte.KxmException
- will be thrown on an error.public void set(KxmField field) throws KxmException
field
- A source field.KxmException
- will be thrown on an error.public void set(KxmQName qname) throws KxmException
KxmException
- will be thrown on an error.public void set(KxmDuration dur) throws KxmException
KxmException
- will be thrown on an error.public void setBool(boolean bool) throws KxmException
KxmException
- will be thrown on an error.public void set(java.lang.Object a) throws KxmException
Long
Integer
Double
Float
BigInteger
BigDecimal
String
byte[]
Boolean
AbstractList
KxmField
KxmDate
KxmQName
KxmDuration
KxmException
- will be thrown on an error.public java.lang.String getString() throws KxmException
KxmException
- will be thrown on an error.public long getLong() throws KxmException
Field Data | Result |
Int8 uint8 int16 uint16 int32 |
Value of field. |
Uint32 int64 uint64 integer |
The function returns the value of a field if it is equal to or smaller than LONG_MAX. Otherwise, it returns an error. |
String XML element XML attribute |
The function tries to convert the string to an integer. Leading and trailing spaces are ignored. If the string does not contain a valid integer, or there are extra non-space symbols, or the integer is too big to fit into a long, an error is returned. |
Decimal |
Returns an error. |
KxmException
- will be thrown on an error.public double getDouble() throws KxmException
Field Data | Result |
String XML element XML attribute |
The function tries to convert the string to a double. Leading and trailing spaces are ignored. Decimal and exponent forms are recognized. If the string does not contain a valid decimal number, or there are extra non-space symbols, an error is returned. |
Decimal | Converts decimal number to a double. The conversion may reduce the accuracy as a result of the decimal-to-IEEE double conversion. |
String XML element XML attribute |
The function tries to convert the string to an integer. Leading and trailing spaces are ignored. If the string does not contain a valid integer, or there are extra non-space symbols, or the integer is too big to fit into a long, an error is returned. |
Any other | Returns an error. |
KxmException
- will be thrown on an error.public boolean getBool() throws KxmException
KxmException
- will be thrown on an error.public KxmQName getQName() throws KxmException
KxmException
- will be thrown on an error.public KxmDuration getDuration() throws KxmException
KxmException
- will be thrown on an error.public KxmDate getDate() throws KxmException
KxmException
- will be thrown on an error.public byte[] getByteArray() throws KxmException
KxmException
- will be thrown on an error.public java.lang.Object getObject() throws KxmException
Definition | JAVA type of return Object |
String |
String |
Number: Decimal | BigDecimal |
Number: Integer | BigInteger |
Number: int8 uint8 int16 uint16 int32 uint32 uint64 |
Long |
Number: Double | Double |
Number: Float | Float |
Binary | byte[] |
XML Element | String |
XML Attribute | String |
boolean | Boolean |
Group | KxmException will be thrown |
Date | KxmDate |
XML Qualified Name | KxmQName |
XML Duration | KxmDuration |
Raw Array | Vector |
KxmException
- will be thrown on an error.public int getArrayLen() throws KxmException
KxmException
- will be thrown on an error.public void setArrayLen(int l) throws KxmException
l
- new size of the arrayKxmException
- will be thrown on an error.public KxmField at(int index) throws KxmException
index
- Array element index.KxmException
- will be thrown on an error.public KxmField applyFormat(int format) throws KxmException
format
- New format. Possible values are:
KxmFieldFormat.NONE
- no conversion.
KxmFieldFormat.BINARY_BASE64
- convert the field to
the binary field having Base64 (RFC2045) text representation of
data.
KxmFieldFormat.BINARY_HEX
- convert the field to
the binary field having hexadecimal text representation of data
(two hexadecimal characters per byte).
KxmException
- will be thrown on an error.public KxmField applyFormat(KxmFieldFormat format) throws KxmException
format
- Format to apply.KxmException
- will be thrown on an error.public java.lang.String getNsPrefix() throws KxmException
KxmException
- will be thrown on an error.public java.lang.String getNsUri() throws KxmException
KxmException
- will be thrown on an error.public java.lang.String getLocalPart() throws KxmException
getName()
method does.KxmException
- will be thrown on an error.public void declareNs(java.lang.String fieldName, java.lang.String prefix, java.lang.String uri) throws KxmException
fieldName
- Name of the target field.prefix
- XML namespace prefix.uri
- XML namespace URI.KxmException
- will be thrown on an error.public int getFlags() throws KxmException
KxmField.FLAG_ROOT
- the field is the root of a message.KxmField.FLAG_ARRAY
- the field is an array.KxmField.FLAG_GROUP
- the field is a group.KxmField.FLAG_DEFAULT_VALUE
- the field is a default value.KxmField.FLAG_UNION
- the field is an XML union.KxmField.FLAG_XMLELEM
- the field is an XML element.KxmField.FLAG_XMLATTR
- the field is an XML attribute.KxmField.FLAG_XMLDOC
- the field is entire XML document.public void setNil() throws KxmException
KxmException
- will be thrown on an error.public boolean isNil() throws KxmException
KxmException
- will be thrown on an error.public void setCharacterData(java.lang.String data) throws KxmException
data
- XML character data.KxmException
- will be thrown on an error.public java.lang.String getCharacterData() throws KxmException
KxmException
- will be thrown on an error.public java.lang.String toString()
toString
in class java.lang.Object
public long getHandle()
public static void loadMessageApi()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |