CBORParser and CBORGenerator
instances; both of which handle
CBOR
encoded data.
Extends JsonFactory mostly so that users can actually use it in place
of regular non-CBOR factory instances.
Note on using non-byte-based sources/targets (char based, like
java. and java.): these can not be
used for CBOR documents; attempt will throw exception.
| Modifier and Type | Field and Description |
|---|---|
| protected int | |
| protected int | |
| pack-priv static final int | DEFAULT_CBOR_GENERATOR_FEATURE_FLAGS
Bitfield (set of flags) of all generator features that are enabled by default. |
| pack-priv static final int | DEFAULT_CBOR_PARSER_FEATURE_FLAGS
Bitfield (set of flags) of all parser features that are enabled by default. |
| public static final String | FORMAT_NAME
Name used to identify CBOR format. |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | CBORFactory(CBORFactory src, ObjectCodec oc)
Note REQUIRES at least 2.2.1 -- unfortunate intra-patch dep but seems preferable to just leaving bug be as is |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private final CBORGenerator | _createCBORGenerator(IOContext ctxt, int stdFeat, int formatFeat, ObjectCodec codec, OutputStream out)
|
| protected IOContext | _createContext(ContentReference
Source/target reference to use for diagnostics, exception messages contentRef, boolean Whether input/output buffer is managed by this factory or not resourceManaged)Overrides com. Overridable factory method that actually instantiates desired context object. |
| protected CBORGenerator | _createGenerator(Writer
Writer underlying writer to write generated content to out, IOContext I/O context to use ctxt)Overrides com. Overridable factory method that actually instantiates generator for
given |
| protected CBORParser | _createParser(InputStream
InputStream to use for reading content to parse in, IOContext I/O context to use for parsing ctxt)Overrides com. Overridable factory method that actually instantiates desired parser. |
| protected JsonParser | _createParser(Reader
Reader to use for reading content to parse r, IOContext I/O context to use for parsing ctxt)Overrides com. Overridable factory method that actually instantiates desired parser. |
| protected JsonParser | _createParser(char[]
Buffer that contains content to parse data, int Offset to the first character of data to parse offset, int Number of characters within buffer to parse len, IOContext I/O context to use for parsing ctxt, boolean Whether input buffer is recycled by the factory recyclable)Overrides com. Overridable factory method that actually instantiates parser
using given |
| protected CBORParser | _createParser(byte[]
Buffer that contains content to parse data, int Offset to the first character of data to parse offset, int Number of characters within buffer to parse len, IOContext I/O context to use for parsing ctxt)Overrides com. Overridable factory method that actually instantiates desired parser. |
| protected CBORGenerator | _createUTF8Generator(OutputStream
OutputStream underlying writer to write generated content to out, IOContext I/O context to use ctxt)Overrides com. Overridable factory method that actually instantiates generator for
given |
| protected Writer | _createWriter(OutputStream out, JsonEncoding enc, IOContext ctxt)
Overrides com.
|
| protected <T> T | |
| protected <T> T | |
| public static CBORFactoryBuilder | builder()
Hides com. Main factory method to use for constructing |
| public boolean | canHandleBinaryNatively()
Overrides com. Introspection method that higher-level functionality may call to see whether underlying data format can read and write binary data natively; that is, embeded it as-is without using encodings such as Base64. |
| public boolean | canUseCharArrays()
Overrides com. Introspection method that can be used by base factory to check
whether access using |
| public final CBORFactory | configure(CBORParser.
Method for enabling or disabling specified parser feature
(check |
| public final CBORFactory | configure(CBORGenerator.
Method for enabling or disabling specified generator feature
(check |
| public CBORFactory | copy()
Overrides com. Method for constructing a new |
| public CBORGenerator | createGenerator(OutputStream
OutputStream to use for writing JSON content out, JsonEncoding Character encoding to use enc)Overrides com. Method for constructing |
| public CBORGenerator | createGenerator(OutputStream out)
Overrides com. Method for constructing |
| public CBORParser | createParser(File
File that contains JSON content to parse f)Overrides com. Method for constructing JSON parser instance to parse contents of specified file. |
| public CBORParser | createParser(URL
URL pointing to resource that contains JSON content to parse url)Overrides com. Method for constructing JSON parser instance to parse contents of resource reference by given URL. |
| public CBORParser | createParser(InputStream
InputStream to use for reading JSON content to parse in)Overrides com. Method for constructing JSON parser instance to parse the contents accessed via specified input stream. |
| public CBORParser | createParser(byte[] data)
Overrides com. Method for constructing parser for parsing the contents of given byte array. |
| public CBORParser | createParser(byte[]
Buffer that contains data to parse data, int Offset of the first data byte within buffer offset, int Length of contents to parse within buffer len)Overrides com. Method for constructing parser for parsing the contents of given byte array. |
| public CBORFactory | disable(CBORParser.
Method for disabling specified parser features
(check |
| public CBORFactory | disable(CBORGenerator.
Method for disabling specified generator feature
(check |
| public CBORFactory | enable(CBORParser.
Method for enabling specified parser feature
(check |
| public CBORFactory | enable(CBORGenerator.
Method for enabling specified generator features
(check |
| public int | |
| public String | getFormatName()
Overrides com. Method that returns short textual id identifying format this factory supports. |
| public int | |
| public Class | getFormatReadFeatureType()
Overrides com. Method for accessing kind of |
| public Class | getFormatWriteFeatureType()
Overrides com. Method for accessing kind of |
| public MatchStrength | |
| public final boolean | |
| public final boolean | |
| protected Object | readResolve()
Overrides com. Method that we need to override to actually make restoration go through constructors etc. Also: must be overridden by sub-classes as well. |
| public CBORFactoryBuilder | rebuild()
Overrides com. Method that allows construction of differently configured factory, starting with settings of this factory. |
| public Version | version()
Overrides com. Implements com. Method called to detect version of the component that implements this interface;
returned version should never be null, but may return specific "not available"
instance (see |
| _formatGeneratorFeatures | back to summary |
|---|---|
| protected int _formatGeneratorFeatures | |
| _formatParserFeatures | back to summary |
|---|---|
| protected int _formatParserFeatures | |
| DEFAULT_CBOR_GENERATOR_FEATURE_FLAGS | back to summary |
|---|---|
| pack-priv static final int DEFAULT_CBOR_GENERATOR_FEATURE_FLAGS Bitfield (set of flags) of all generator features that are enabled by default. | |
| DEFAULT_CBOR_PARSER_FEATURE_FLAGS | back to summary |
|---|---|
| pack-priv static final int DEFAULT_CBOR_PARSER_FEATURE_FLAGS Bitfield (set of flags) of all parser features that are enabled by default. | |
| FORMAT_NAME | back to summary |
|---|---|
| public static final String FORMAT_NAME Name used to identify CBOR format.
(and returned by | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides com. | |
| CBORFactory | back to summary |
|---|---|
| public CBORFactory() Default constructor used to create factory instances. Creation of a factory instance is a light-weight operation, but it is still a good idea to reuse limited number of factory instances (and quite often just a single instance): factories are used as context for storing some reused processing objects (such as symbol tables parsers use) and this reuse only works within context of a single factory instance. | |
| CBORFactory | back to summary |
|---|---|
| public CBORFactory(ObjectCodec oc) | |
| CBORFactory | back to summary |
|---|---|
| public CBORFactory(CBORFactory src, ObjectCodec oc) Note REQUIRES at least 2.2.1 -- unfortunate intra-patch dep but seems preferable to just leaving bug be as is
| |
| CBORFactory | back to summary |
|---|---|
| protected CBORFactory(CBORFactoryBuilder b) Constructors used by
| |
| _createCBORGenerator | back to summary |
|---|---|
| private final CBORGenerator _createCBORGenerator(IOContext ctxt, int stdFeat, int formatFeat, ObjectCodec codec, OutputStream out) throws IOException | |
| _createContext | back to summary |
|---|---|
| protected IOContext _createContext(ContentReference contentRef, boolean resourceManaged) Overrides com. Doc from com. Overridable factory method that actually instantiates desired context object.
| |
| _createGenerator | back to summary |
|---|---|
| protected CBORGenerator _createGenerator(Writer out, IOContext ctxt) throws IOException Overrides com. Doc from com. Overridable factory method that actually instantiates generator for
given This method is specifically designed to remain compatible between minor versions so that sub-classes can count on it being called as expected. That is, it is part of official interface from sub-class perspective, although not a public method available to users of factory implementations.
| |
| _createParser | back to summary |
|---|---|
| protected CBORParser _createParser(InputStream in, IOContext ctxt) throws IOException Overrides com. Overridable factory method that actually instantiates desired parser.
| |
| _createParser | back to summary |
|---|---|
| protected JsonParser _createParser(Reader r, IOContext ctxt) throws IOException Overrides com. Overridable factory method that actually instantiates desired parser.
| |
| _createParser | back to summary |
|---|---|
| protected JsonParser _createParser(char[] data, int offset, int len, IOContext ctxt, boolean recyclable) throws IOException Overrides com. Doc from com. Overridable factory method that actually instantiates parser
using given
| |
| _createParser | back to summary |
|---|---|
| protected CBORParser _createParser(byte[] data, int offset, int len, IOContext ctxt) throws IOException Overrides com. Overridable factory method that actually instantiates desired parser.
| |
| _createUTF8Generator | back to summary |
|---|---|
| protected CBORGenerator _createUTF8Generator(OutputStream out, IOContext ctxt) throws IOException Overrides com. Doc from com. Overridable factory method that actually instantiates generator for
given This method is specifically designed to remain compatible between minor versions so that sub-classes can count on it being called as expected. That is, it is part of official interface from sub-class perspective, although not a public method available to users of factory implementations.
| |
| _createWriter | back to summary |
|---|---|
| protected Writer _createWriter(OutputStream out, JsonEncoding enc, IOContext ctxt) throws IOException Overrides com.
| |
| _nonByteSource | back to summary |
|---|---|
| protected <T> T _nonByteSource() | |
| _nonByteTarget | back to summary |
|---|---|
| protected <T> T _nonByteTarget() | |
| builder | back to summary |
|---|---|
| public static CBORFactoryBuilder builder() Hides com. Main factory method to use for constructing
| |
| canHandleBinaryNatively | back to summary |
|---|---|
| public boolean canHandleBinaryNatively() Overrides com. Doc from com. Introspection method that higher-level functionality may call to see whether underlying data format can read and write binary data natively; that is, embeded it as-is without using encodings such as Base64.
Default implementation returns
| |
| canUseCharArrays | back to summary |
|---|---|
| public boolean canUseCharArrays() Overrides com. Doc from com. Introspection method that can be used by base factory to check
whether access using
| |
| configure | back to summary |
|---|---|
| public final CBORFactory configure(CBORParser. Method for enabling or disabling specified parser feature
(check | |
| configure | back to summary |
|---|---|
| public final CBORFactory configure(CBORGenerator. Method for enabling or disabling specified generator feature
(check | |
| copy | back to summary |
|---|---|
| public CBORFactory copy() Overrides com. Doc from com. Method for constructing a new
| |
| createGenerator | back to summary |
|---|---|
| public CBORGenerator createGenerator(OutputStream out, JsonEncoding enc) throws IOException Overrides com. Method for constructing
Since CBOR format always uses UTF-8 internally,
| |
| createGenerator | back to summary |
|---|---|
| public CBORGenerator createGenerator(OutputStream out) throws IOException Overrides com. Method for constructing Since CBOR format always uses UTF-8 internally, no encoding need to be passed to this method.
| |
| createParser | back to summary |
|---|---|
| public CBORParser createParser(File f) throws IOException Overrides com. Doc from com. Method for constructing JSON parser instance to parse contents of specified file.
Encoding is auto-detected from contents according to JSON
specification recommended mechanism. Json specification
supports only UTF-8, UTF-16 and UTF-32 as valid encodings,
so auto-detection implemented only for this charsets.
For other charsets use Underlying input stream (needed for reading contents) will be owned (and managed, i.e. closed as need be) by the parser, since caller has no access to it.
| |
| createParser | back to summary |
|---|---|
| public CBORParser createParser(URL url) throws IOException Overrides com. Doc from com. Method for constructing JSON parser instance to parse contents of resource reference by given URL.
Encoding is auto-detected from contents according to JSON
specification recommended mechanism. Json specification
supports only UTF-8, UTF-16 and UTF-32 as valid encodings,
so auto-detection implemented only for this charsets.
For other charsets use Underlying input stream (needed for reading contents) will be owned (and managed, i.e. closed as need be) by the parser, since caller has no access to it. | |
| createParser | back to summary |
|---|---|
| public CBORParser createParser(InputStream in) throws IOException Overrides com. Doc from com. Method for constructing JSON parser instance to parse the contents accessed via specified input stream.
The input stream will not be owned by
the parser, it will still be managed (i.e. closed if
end-of-stream is reacher, or parser close method called)
if (and only if) Note no encoding argument is taken since it can always be
auto-detected as suggested by JSON RFC. Json specification
supports only UTF-8, UTF-16 and UTF-32 as valid encodings,
so auto-detection implemented only for this charsets.
For other charsets use
| |
| createParser | back to summary |
|---|---|
| public CBORParser createParser(byte[] data) throws IOException Overrides com. Doc from com. Method for constructing parser for parsing the contents of given byte array.
| |
| createParser | back to summary |
|---|---|
| public CBORParser createParser(byte[] data, int offset, int len) throws IOException Overrides com. Doc from com. Method for constructing parser for parsing the contents of given byte array.
| |
| disable | back to summary |
|---|---|
| public CBORFactory disable(CBORParser. Method for disabling specified parser features
(check | |
| disable | back to summary |
|---|---|
| public CBORFactory disable(CBORGenerator. Method for disabling specified generator feature
(check | |
| enable | back to summary |
|---|---|
| public CBORFactory enable(CBORParser. Method for enabling specified parser feature
(check | |
| enable | back to summary |
|---|---|
| public CBORFactory enable(CBORGenerator. Method for enabling specified generator features
(check | |
| getFormatGeneratorFeatures | back to summary |
|---|---|
| public int getFormatGeneratorFeatures() Overrides com.
| |
| getFormatName | back to summary |
|---|---|
| public String getFormatName() Overrides com. Doc from com. Method that returns short textual id identifying format this factory supports. Note sub-classes should override this method; default implementation will return null for all sub-classes | |
| getFormatParserFeatures | back to summary |
|---|---|
| public int getFormatParserFeatures() Overrides com.
| |
| getFormatReadFeatureType | back to summary |
|---|---|
| public Class Overrides com. Doc from com. Method for accessing kind of
| |
| getFormatWriteFeatureType | back to summary |
|---|---|
| public Class Overrides com. Doc from com. Method for accessing kind of
| |
| hasFormat | back to summary |
|---|---|
| public MatchStrength hasFormat(InputAccessor acc) throws IOException Overrides com.
| |
| isEnabled | back to summary |
|---|---|
| public final boolean isEnabled(CBORParser. Checked whether specified parser feature is enabled. | |
| isEnabled | back to summary |
|---|---|
| public final boolean isEnabled(CBORGenerator. Check whether specified generator feature is enabled. | |
| readResolve | back to summary |
|---|---|
| protected Object readResolve() Overrides com. Method that we need to override to actually make restoration go through constructors etc. Also: must be overridden by sub-classes as well.
| |
| rebuild | back to summary |
|---|---|
| public CBORFactoryBuilder rebuild() Overrides com. Doc from com. Method that allows construction of differently configured factory, starting with settings of this factory.
| |
| version | back to summary |
|---|---|
| public Version version() Overrides com. Implements com. Doc from com. Method called to detect version of the component that implements this interface;
returned version should never be null, but may return specific "not available"
instance (see | |