public interface ContentFactory extends Record.Factory
Content
, Content Builders
and
Content Readers
.
An instance of this factory can be obtained using Diffusion.content()
, for example:
ContentFactory factory = Diffusion.content();
Modifier and Type | Method and Description |
---|---|
<B extends ContentBuilder<B>> |
newBuilder(Class<B> builderType)
Creates a new content builder.
|
Content |
newContent(byte[] bytes)
Convenience method to create simple byte content.
|
Content |
newContent(CharSequence value)
Convenience method to create simple character content.
|
<R extends ContentReader> |
newReader(Class<R> readerType,
Content content)
Creates a new content reader.
|
newDeltaRecordBuilder, newRecord, newRecord, newRecordBuilder, newRecordBuilder
<B extends ContentBuilder<B>> B newBuilder(Class<B> builderType) throws IllegalArgumentException
To create a content builder you need to specify the class (interface) of the builder subtype that you wish to use. For example:
RecordContentBuilder builder = factory.newBuilder(RecordContentBuilder.class);
B
- the builder typebuilderType
- the builder type. The class (interface) of the builder
to be created should be supplied.IllegalArgumentException
- if builderType
is null or is not
a supported builder type<R extends ContentReader> R newReader(Class<R> readerType, Content content) throws IllegalArgumentException
To create a content reader you need to specify the class (interface) of the reader subtype that you wish to use and the content you wish to read. For example:
RecordContentReader reader = factory.newReader(RecordContentReader.class, content);
The content should be formatted in the way expected by the reader (e.g.
should have been created using a corresponding builder).R
- the reader typereaderType
- the reader typecontent
- the content to readIllegalArgumentException
- if readerType
is null or not a
supported reader type or content
is nullContent newContent(byte[] bytes)
bytes
- the bytes that will make up the content. Null will be
represented as empty content.Content newContent(CharSequence value)
UTF-8 byte encoding is used to generate the byte content.
For example:
Content content = factory.newContent("This is the content");
value
- the content value. Null will be represented as empty contentCopyright © 2016 Push Technology Ltd. All Rights Reserved.