Interface RecordModel
- All Known Subinterfaces:
MutableRecordModel
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.
- Since:
- 6.0
- Author:
- DiffusionData Limited
-
Method Summary
Modifier and TypeMethodDescriptionasValue()Creates an immutableRecordV2object generated from the model.intfieldCount(String recordName, int recordIndex, String fieldName) Returns the actual number of occurrences of a named field within a specified record occurrences.Get a field value.Get a field value.intrecordCount(String recordName) Returns the actual number of occurrences of a named record.
-
Method Details
-
get
String get(String recordName, int recordIndex, String fieldName, int fieldIndex) throws SchemaViolationException, IndexOutOfBoundsException Get a field value.- Parameters:
recordName- the name of the recordrecordIndex- the index of the recordfieldName- the name of the fieldfieldIndex- the index of the field- Returns:
- the field value
- Throws:
SchemaViolationException- if the named record or field is not defined by the schemaIndexOutOfBoundsException- if either the record or field index is out of bounds
-
get
String get(String key) throws SchemaViolationException, IndexOutOfBoundsException, IllegalArgumentException, NumberFormatException Get a field value.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.
- Parameters:
key- the field key- Returns:
- the field value
- Throws:
SchemaViolationException- 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 number
-
recordCount
Returns the actual number of occurrences of a named record.If the record is not variable, this is the same as the defined number of occurrences in the schema.
- Parameters:
recordName- the record name- Returns:
- the actual number of occurrences of the record
- Throws:
SchemaViolationException- if the record is not defined in the schema
-
fieldCount
int fieldCount(String recordName, int recordIndex, String fieldName) throws SchemaViolationException, IndexOutOfBoundsException Returns the actual number of occurrences of a named field within a specified record occurrences.For all but variable fields this simply returns the schema defined number of occurrences of the field.
- Parameters:
recordName- the record namerecordIndex- the record indexfieldName- the field name- Returns:
- the actual number of occurrences of the field
- Throws:
SchemaViolationException- if the record or field name are not defined in the schemaIndexOutOfBoundsException- if the record index is out of bounds
-
asValue
RecordV2 asValue()Creates an immutableRecordV2object generated from the model.- Returns:
- new immutable
RecordV2object
-