public interface Record extends Iterable<String>
Content
.
Content that has been written with record
delimiters
may be read as records or content that uses only
field delimiters
can be interpreted as a single
record, using a RecordContentReader
.
Record metadata
can be used for direct field access within a
record. Metadata used for records is constrained in the following ways:
1) A record can have one or more fields defined but can not have nested
records defined for it.
2) Only String data types are permitted for fields (MString
or
subtypes).
3) Repeating field definitions with fixed multiplicity are permitted anywhere
within the record but a repeating field definition with variable multiplicity
is only permitted if it is the last field within the record.
When metadata is in use, a Record
may be read using a
Record.StructuredReader
.
The fields within a free format record are simply positional with no concept of field name or repeating fields. A free format record can be thought of as having a single optional repeating field with no name.
Records may be built using a Record.Builder
or with metadata using a
Record.StructuredBuilder
. Such a record may then be written to content using
a RecordContentBuilder
.
Such a builder can be created using the record factory
which is provided via ContentFactory
, for example:
ContentFactory factory = Diffusion.content();
Record.Builder builder = factory.newRecordBuilder();
Record.StructuredBuilder mBuilder = factory.newRecordBuilder(recordMetadata);
Convenience methods also exist on the factory allowing records to be easily
created from arrays or collections of Strings, for example:
ContentFactory factory = Diffusion.content();
Record record = factory.newRecord("A", "B", "C");
Modifier and Type | Interface and Description |
---|---|
static interface |
Record.Builder
Record Builder.
|
static interface |
Record.Factory
Factory for records and record builders.
|
static interface |
Record.StructuredBuilder
Record builder that uses
Metadata . |
static interface |
Record.StructuredReader
A Structured reader allowing record content to be read using
Metadata . |
Modifier and Type | Field and Description |
---|---|
static byte |
EMPTY_FIELD
Byte value reserved for representing and empty field in record based
content.
|
static char |
EMPTY_FIELD_CHAR
Character representation of
EMPTY_FIELD . |
static String |
EMPTY_FIELD_STRING
String representation of
EMPTY_FIELD . |
static byte |
FIELD_DELIMITER
Byte value reserved for use as a field delimiter in record based content.
|
static char |
FIELD_DELIMITER_CHAR
Character representation of
FIELD_DELIMITER . |
static String |
FIELD_DELIMITER_STRING
String representation of
FIELD_DELIMITER . |
static byte |
FIELD_MU
Byte value reserved for representing a single empty field within record
content.
|
static byte |
LIST_DELIMITER
Byte value reserved for use as a list delimiter used for separating the
elements of a list in record based content.
|
static char |
LIST_DELIMITER_CHAR
Character representation of
LIST_DELIMITER . |
static String |
LIST_DELIMITER_STRING
String representation of
LIST_DELIMITER . |
static byte |
RECORD_DELIMITER
Byte value reserved for use as a record delimiter in record based
content.
|
static char |
RECORD_DELIMITER_CHAR
Character representation of
RECORD_DELIMITER . |
static String |
RECORD_DELIMITER_STRING
String representation of
RECORD_DELIMITER . |
static byte |
RECORD_MU
Byte value reserved for representing a single empty record within
content.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares the specified object with this record for equality.
|
List<String> |
fields()
Returns the values of all field occurrences within the record.
|
String |
get(int index)
Returns a specific field value within the record.
|
int |
hashCode() |
Record.StructuredReader |
newReader(MRecord metadata)
Returns a structured reader which may be used to read the record using
the supplied metadata.
|
Record.StructuredReader |
newReader(MRecord metadata,
String emptyFieldValue)
Returns a structured reader which may be used to read the record using
the supplied metadata.
|
int |
size()
Returns the size of the record in terms of the number of fields defined
within it.
|
String |
toString()
Returns a string representation of this Record.
|
static final byte RECORD_DELIMITER
static final char RECORD_DELIMITER_CHAR
RECORD_DELIMITER
.static final String RECORD_DELIMITER_STRING
RECORD_DELIMITER
. Useful for
String.split operations.static final byte FIELD_DELIMITER
static final char FIELD_DELIMITER_CHAR
FIELD_DELIMITER
.static final String FIELD_DELIMITER_STRING
FIELD_DELIMITER
. Useful for
String.split operations.static final byte EMPTY_FIELD
static final char EMPTY_FIELD_CHAR
EMPTY_FIELD
.static final String EMPTY_FIELD_STRING
EMPTY_FIELD
. Useful for String
comparisons.static final byte RECORD_MU
static final byte FIELD_MU
static final byte LIST_DELIMITER
static final char LIST_DELIMITER_CHAR
LIST_DELIMITER
.static final String LIST_DELIMITER_STRING
LIST_DELIMITER
. Useful for String.split
operations.String get(int index) throws IndexOutOfBoundsException
index
- the index of the field to return value for, starting at 0IndexOutOfBoundsException
- if index
is out of boundsList<String> fields()
int size()
Record.StructuredReader newReader(MRecord metadata) throws IllegalArgumentException
This will allow for empty field values of "" in the record. If any other
empty field value is expected, use newReader(MRecord, String)
instead.
metadata
- the metadataIllegalArgumentException
- if metadata
is null or invalidRecord.StructuredReader newReader(MRecord metadata, String emptyFieldValue) throws IllegalArgumentException
metadata
- the metadataemptyFieldValue
- specifies the string that is permitted as an empty
field value within the recordIllegalArgumentException
- if metadata
or
emptyFieldValue
is null or invalidboolean equals(Object obj)
Returns true if, and only if the specified object is also a
Record
, both records are the same size (have the same number of
fields occurrences), and all corresponding pairs of field values in the
two records are equal.
String toString()
The string representation consists of a list of the record's field values in the order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).
Copyright © 2016 Push Technology Ltd. All Rights Reserved.