public interface RecordModel
RecordV2
data model.
A read only model can be created from any RecordV2
object
using the asModel
method. The model
then provides direct access to the fields within the data. Fields may be
accessed either by explicitly specifying the record and field occurrence or
by specifying a key of the form:
recordName(recordIndex).fieldName(fieldIndex)Indexes start from 0 and if omitted then 0 is assumed. The record name may also be omitted, in which case the first record definition. This form of addressing is useful when there is only one record definition.
So valid keys would be:
Address(4).AddressLine(3) |
The 4th AddressLine occurrence within the 5th
Address record |
Address.Name |
The first (or only) Name field within the first (or only)
Address record |
AddressLine(1) |
The 2nd AddressLine field within the first (or only) record
|
Name |
The first (or only) Name field within the first (or only)
record |
The recordCount(java.lang.String)
and fieldCount(java.lang.String, int, java.lang.String)
methods are useful for
determining the actual number of occurrences of variable multiplicity items.
Modifier and Type | Method and Description |
---|---|
RecordV2 |
asValue()
Creates an immutable
RecordV2 object generated from the
model. |
int |
fieldCount(String recordName,
int recordIndex,
String fieldName)
Returns the actual number of occurrences of a named field within a
specified record occurrences.
|
String |
get(String key)
Get a field value.
|
String |
get(String recordName,
int recordIndex,
String fieldName,
int fieldIndex)
Get a field value.
|
int |
recordCount(String recordName)
Returns the actual number of occurrences of a named record.
|
String get(String recordName, int recordIndex, String fieldName, int fieldIndex) throws SchemaViolationException, IndexOutOfBoundsException
recordName
- the name of the recordrecordIndex
- the index of the recordfieldName
- the name of the fieldfieldIndex
- the index of the fieldSchemaViolationException
- if the named record or field is not
defined by the schemaIndexOutOfBoundsException
- if either the record or field index is
out of boundsString get(String key) throws SchemaViolationException, IndexOutOfBoundsException, IllegalArgumentException, NumberFormatException
This allows an item to be addressed using a key of the form recordName(recordIndex).fieldName(fieldIndex). Indexes may be omitted in which case 0 is assumed. The record part may also be omitted in which case the first occurrence of the first record is assumed.
key
- the field keySchemaViolationException
- if the key does not address a valid
fieldIndexOutOfBoundsException
- if an index is out of boundsIllegalArgumentException
- if the key format is invalidNumberFormatException
- if an index is not a valid numberint recordCount(String recordName) throws SchemaViolationException
If the record is not variable, this is the same as the defined number of occurrences in the schema.
recordName
- the record nameSchemaViolationException
- if the record is not defined in the
schemaint fieldCount(String recordName, int recordIndex, String fieldName) throws SchemaViolationException, IndexOutOfBoundsException
For all but variable fields this simply returns the schema defined number of occurrences of the field.
recordName
- the record namerecordIndex
- the record indexfieldName
- the field nameSchemaViolationException
- if the record or field name are not
defined in the schemaIndexOutOfBoundsException
- if the record index is out of boundsCopyright © 2022 Push Technology Ltd. All Rights Reserved.