public interface RecordContentBuilder extends ContentBuilder<RecordContentBuilder>
Such a builder can be created using ContentFactory.newBuilder(Class)
,
for example:
ContentFactory factory = Diffusion.content();
RecordContentBuilder builder = factory.newBuilder(RecordContentBuilder.class);
Record format is defined as being character string fields separated using
special delimiter bytes which could not occur in a normal character string.
This builder will insert all types of delimiter automatically and so there is
no need to write any delimiters manually.
The builder allows data to be put into content relative to the start position
and then build
is finally used to build immutable content.
The builder may then be reset
and reused if required.
Note that record format has no concept of null and if null values are specified to any of the methods, they are written as empty fields.
The following description of record format is for information only:
Records are separated using Record.RECORD_DELIMITER
and fields within
records are separated using Record.FIELD_DELIMITER
.
A field may be empty (i.e a zero length string), as may a record (i.e. having no fields).
A record delimiter should not be used at the start of the first record or the end of the last record as these would imply an empty leading or trailing record respectively.
Also, a field delimiter should not be used before the first field within a record or after the last field within a record, as in both cases an empty field would be implied.
This presents certain problems of representation as it would not be possible
to distinguish between empty content and content containing a single empty
record. Equally, it would not be possible to distinguish between an empty
record and one containing a single empty field. To overcome this there are
two special delimiters, the Record.RECORD_MU
and the
Record.FIELD_MU
. The record mu can be used as the only byte within
content to represent a single empty record and the field mu can be used as
the only byte within a record to represent a record with a single empty
field.
Modifier and Type | Method and Description |
---|---|
void |
charset(Charset charset)
Deprecated.
This method is for backward compatibility with Classic API
clients only. Deprecated since 5.3.
|
RecordContentBuilder |
putFields(Collection<?> fields)
Puts fields into the content.
|
RecordContentBuilder |
putFields(String... fields)
Puts fields into the content.
|
RecordContentBuilder |
putRecord(Collection<?> fields)
Puts a single record comprising zero or more fields into the content.
|
RecordContentBuilder |
putRecord(String... fields)
Puts a single record comprising zero or more fields into the content.
|
RecordContentBuilder |
putRecords(Collection<Record> records)
Puts records into the content.
|
RecordContentBuilder |
putRecords(Record... records)
Puts records into the content.
|
build, encoding, reset
RecordContentBuilder putRecord(String... fields)
fields
- one or more string fields. Any null value will be written
as an empty fieldRecordContentBuilder putRecord(Collection<?> fields)
fields
- a collection of objects from which the String field values
will be obtained. Any null value is interpreted as an empty field.
If this is supplied as null, an empty record will be writtenRecordContentBuilder putRecords(Record... records)
records
- the records - zero or more can be specified. Null entries
are interpreted as empty recordsRecordContentBuilder putRecords(Collection<Record> records)
records
- a collection of records. If this is null, nothing will be
written. Null entries are interpreted as empty records.RecordContentBuilder putFields(String... fields)
If there are already records in the content, the fields will be added to the last record.
fields
- the list of fields. Null entries are interpreted as empty
fieldsRecordContentBuilder putFields(Collection<?> fields)
If there are already records in the content, the fields will be added to the last record.
fields
- the collection of field objects. The toString() method of
each object will be used to generate the string value of the
field. Null values are interpreted as empty fields.@Deprecated void charset(Charset charset) throws IllegalArgumentException
No metadata is included within the content to indicate the character set.
It is the caller's responsibility to ensure end points that receive the
content use the same character set to decode
it.
The default character set is UTF-8. This method is provided for backward compatibility with Classic API clients that use character sets other than UTF-8 and may be removed in a future version of the product.
charset
- the character setIllegalArgumentException
- if charset
is nullCopyright © 2016 Push Technology Ltd. All Rights Reserved.