Class TokenStreamFactory
- All Implemented Interfaces:
Versioned
,Serializable
- Direct Known Subclasses:
JsonFactory
- Since:
- 2.10
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
_checkRangeBoundsForByteArray
(byte[] data, int offset, int len) protected void
_checkRangeBoundsForCharArray
(char[] data, int offset, int len) protected OutputStream
protected InputStream
Helper methods used for constructing anInputStream
for parsers to use, when input is to be read from givenFile
.protected OutputStream
Helper methods used for constructing anOutputStream
for generator to use, when target is to be written into givenFile
.protected InputStream
Helper method used for constructing an optimal stream for parsers to use, when input is to be read from an URL.protected <T> T
_reportRangeError
(String msg) abstract boolean
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.abstract boolean
Introspection method that can be used to check whether this factory can create non-blocking parsers: parsers that do not use blocking I/O abstractions but instead use aNonBlockingInputFeeder
.abstract boolean
canUseSchema
(FormatSchema schema) Method that can be used to quickly check whether given schema is something that parsers and/or generators constructed by this factory could use.abstract JsonGenerator
abstract JsonGenerator
createGenerator
(DataOutput out, JsonEncoding enc) abstract JsonGenerator
createGenerator
(File f, JsonEncoding enc) abstract JsonGenerator
abstract JsonGenerator
createGenerator
(OutputStream out, JsonEncoding enc) abstract JsonGenerator
abstract JsonParser
Optional method for constructing parser for non-blocking parsing viaByteArrayFeeder
interface (accessed usingJsonParser.getNonBlockingInputFeeder()
from constructed instance).abstract JsonParser
Optional method for constructing parser for non-blocking parsing viaByteBufferFeeder
interface (accessed usingJsonParser.getNonBlockingInputFeeder()
from constructed instance).abstract JsonParser
createParser
(byte[] data) abstract JsonParser
createParser
(byte[] data, int offset, int len) abstract JsonParser
createParser
(char[] content) abstract JsonParser
createParser
(char[] content, int offset, int len) abstract JsonParser
abstract JsonParser
createParser
(File f) abstract JsonParser
abstract JsonParser
abstract JsonParser
createParser
(String content) abstract JsonParser
createParser
(URL url) abstract int
Method for getting bit set of allJsonFactory.Feature
s enabledabstract int
abstract String
Method that returns short textual id identifying format this factory supports.abstract int
abstract Class<? extends FormatFeature>
Method for accessing kind ofFormatFeature
that a parserJsonParser
produced by this factory would accept, if any;null
returned if none.abstract Class<? extends FormatFeature>
Method for accessing kind ofFormatFeature
that a parserJsonGenerator
produced by this factory would accept, if any;null
returned if none.abstract int
abstract int
abstract boolean
abstract boolean
abstract boolean
abstract boolean
abstract boolean
abstract boolean
Introspection method that higher-level functionality may call to see whether underlying data format requires a stable ordering of object properties or not.abstract StreamReadConstraints
Get the constraints to apply when performing streaming reads.abstract StreamWriteConstraints
Get the constraints to apply when performing streaming writes.
-
Constructor Details
-
TokenStreamFactory
public TokenStreamFactory()
-
-
Method Details
-
requiresPropertyOrdering
public abstract boolean requiresPropertyOrdering()Introspection method that higher-level functionality may call to see whether underlying data format requires a stable ordering of object properties or not. This is usually used for determining whether to force a stable ordering (like alphabetic ordering by name) if no ordering if explicitly specified.Default implementation returns
false
as JSON does NOT require stable ordering. Formats that require ordering include positional textual formats likeCSV
, and schema-based binary formats likeAvro
.- Returns:
- Whether format supported by this factory requires Object properties to be ordered.
-
canHandleBinaryNatively
public abstract boolean canHandleBinaryNatively()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
false
as JSON does not support native access: all binary content must use Base64 encoding. Most binary formats (like Smile and Avro) support native binary content.- Returns:
- Whether format supported by this factory supports native binary content
-
canParseAsync
public abstract boolean canParseAsync()Introspection method that can be used to check whether this factory can create non-blocking parsers: parsers that do not use blocking I/O abstractions but instead use aNonBlockingInputFeeder
.- Returns:
- Whether this factory supports non-blocking ("async") parsing or
not (and consequently whether
createNonBlockingXxx()
method(s) work)
-
getFormatReadFeatureType
Method for accessing kind ofFormatFeature
that a parserJsonParser
produced by this factory would accept, if any;null
returned if none.- Returns:
- Type of format-specific stream read features, if any;
null
if none - Since:
- 2.6
-
getFormatWriteFeatureType
Method for accessing kind ofFormatFeature
that a parserJsonGenerator
produced by this factory would accept, if any;null
returned if none.- Returns:
- Type of format-specific stream read features, if any;
null
if none - Since:
- 2.6
-
canUseSchema
Method that can be used to quickly check whether given schema is something that parsers and/or generators constructed by this factory could use. Note that this means possible use, at the level of data format (i.e. schema is for same data format as parsers and generators this factory constructs); individual schema instances may have further usage restrictions.- Parameters:
schema
- Schema instance to check- Returns:
- Whether parsers and generators constructed by this factory can use specified format schema instance
- Since:
- 2.1
-
getFormatName
Method that returns short textual id identifying format this factory supports.- Returns:
- Name of the format handled by parsers, generators this factory creates
-
isEnabled
-
isEnabled
-
isEnabled
-
isEnabled
-
isEnabled
-
getFactoryFeatures
public abstract int getFactoryFeatures()Method for getting bit set of allJsonFactory.Feature
s enabled- Returns:
- Bitset of enabled
JsonFactory.Feature
s. - Since:
- 2.16
-
getParserFeatures
public abstract int getParserFeatures() -
getGeneratorFeatures
public abstract int getGeneratorFeatures() -
getFormatParserFeatures
public abstract int getFormatParserFeatures() -
getFormatGeneratorFeatures
public abstract int getFormatGeneratorFeatures() -
streamReadConstraints
Get the constraints to apply when performing streaming reads.- Returns:
- Constraints to apply to reads done by
JsonParser
s constructed by this factory. - Since:
- 2.15
-
streamWriteConstraints
Get the constraints to apply when performing streaming writes.- Returns:
- Constraints to apply to reads done by
JsonGenerator
s constructed by this factory. - Since:
- 2.16
-
createParser
- Throws:
IOException
-
createParser
- Throws:
IOException
-
createParser
- Throws:
IOException
-
createParser
- Throws:
IOException
-
createParser
- Throws:
IOException
-
createParser
- Throws:
IOException
-
createParser
- Throws:
IOException
-
createParser
- Throws:
IOException
-
createParser
- Throws:
IOException
-
createParser
- Throws:
IOException
-
createNonBlockingByteArrayParser
Optional method for constructing parser for non-blocking parsing viaByteArrayFeeder
interface (accessed usingJsonParser.getNonBlockingInputFeeder()
from constructed instance).If this factory does not support non-blocking parsing (either at all, or from byte array), will throw
UnsupportedOperationException
.Note that JSON-backed factory only supports parsing of UTF-8 encoded JSON content (and US-ASCII since it is proper subset); other encodings are not supported at this point.
- Returns:
- Constructed parser
- Throws:
IOException
- If there are problems constructing parser- Since:
- 2.9
-
createNonBlockingByteBufferParser
Optional method for constructing parser for non-blocking parsing viaByteBufferFeeder
interface (accessed usingJsonParser.getNonBlockingInputFeeder()
from constructed instance).If this factory does not support non-blocking parsing (either at all, or from byte array), will throw
UnsupportedOperationException
.Note that JSON-backed factory only supports parsing of UTF-8 encoded JSON content (and US-ASCII since it is proper subset); other encodings are not supported at this point.
- Returns:
- Constructed parser
- Throws:
IOException
- If there are problems constructing parser- Since:
- 2.14
-
createGenerator
- Throws:
IOException
-
createGenerator
- Throws:
IOException
-
createGenerator
- Throws:
IOException
-
createGenerator
- Throws:
IOException
-
createGenerator
public abstract JsonGenerator createGenerator(OutputStream out, JsonEncoding enc) throws IOException - Throws:
IOException
-
createGenerator
- Throws:
IOException
-
_createDataOutputWrapper
-
_optimizedStreamFromURL
Helper method used for constructing an optimal stream for parsers to use, when input is to be read from an URL. This helps when reading file content via URL.- Parameters:
url
- Source to read content to parse from- Returns:
- InputStream constructed for given
URL
- Throws:
IOException
- If there is a problem accessing content from specifiedURL
-
_fileInputStream
Helper methods used for constructing anInputStream
for parsers to use, when input is to be read from givenFile
.- Parameters:
f
- File to open stream for- Returns:
InputStream
constructed- Throws:
IOException
- If there is a problem opening the stream- Since:
- 2.14
-
_fileOutputStream
Helper methods used for constructing anOutputStream
for generator to use, when target is to be written into givenFile
.- Parameters:
f
- File to open stream for- Returns:
OutputStream
constructed- Throws:
IOException
- If there is a problem opening the stream- Since:
- 2.14
-
_checkRangeBoundsForByteArray
protected void _checkRangeBoundsForByteArray(byte[] data, int offset, int len) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
_checkRangeBoundsForCharArray
- Throws:
IOException
-
_reportRangeError
- Throws:
IllegalArgumentException
-