Class TokenStreamFactory
- All Implemented Interfaces:
Versioned,Serializable
- Direct Known Subclasses:
JsonFactory
- Since:
- 2.10
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void_checkRangeBoundsForByteArray(byte[] data, int offset, int len) protected void_checkRangeBoundsForCharArray(char[] data, int offset, int len) protected OutputStreamprotected InputStreamHelper methods used for constructing anInputStreamfor parsers to use, when input is to be read from givenFile.protected OutputStreamHelper methods used for constructing anOutputStreamfor generator to use, when target is to be written into givenFile.protected InputStreamHelper 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 booleanIntrospection 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 booleanIntrospection 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 booleancanUseSchema(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 JsonGeneratorabstract JsonGeneratorcreateGenerator(DataOutput out, JsonEncoding enc) abstract JsonGeneratorcreateGenerator(File f, JsonEncoding enc) abstract JsonGeneratorabstract JsonGeneratorcreateGenerator(OutputStream out, JsonEncoding enc) abstract JsonGeneratorabstract JsonParserOptional method for constructing parser for non-blocking parsing viaByteArrayFeederinterface (accessed usingJsonParser.getNonBlockingInputFeeder()from constructed instance).abstract JsonParserOptional method for constructing parser for non-blocking parsing viaByteBufferFeederinterface (accessed usingJsonParser.getNonBlockingInputFeeder()from constructed instance).abstract JsonParsercreateParser(byte[] data) abstract JsonParsercreateParser(byte[] data, int offset, int len) abstract JsonParsercreateParser(char[] content) abstract JsonParsercreateParser(char[] content, int offset, int len) abstract JsonParserabstract JsonParsercreateParser(File f) abstract JsonParserabstract JsonParserabstract JsonParsercreateParser(String content) abstract JsonParsercreateParser(URL url) abstract intMethod for getting bit set of allJsonFactory.Features enabledabstract intabstract StringMethod that returns short textual id identifying format this factory supports.abstract intabstract Class<? extends FormatFeature>Method for accessing kind ofFormatFeaturethat a parserJsonParserproduced by this factory would accept, if any;nullreturned if none.abstract Class<? extends FormatFeature>Method for accessing kind ofFormatFeaturethat a parserJsonGeneratorproduced by this factory would accept, if any;nullreturned if none.abstract intabstract intabstract booleanabstract booleanabstract booleanabstract booleanabstract booleanabstract booleanIntrospection method that higher-level functionality may call to see whether underlying data format requires a stable ordering of object properties or not.abstract StreamReadConstraintsGet the constraints to apply when performing streaming reads.abstract StreamWriteConstraintsGet 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
falseas 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
falseas 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 ofFormatFeaturethat a parserJsonParserproduced by this factory would accept, if any;nullreturned if none.- Returns:
- Type of format-specific stream read features, if any;
nullif none - Since:
- 2.6
-
getFormatWriteFeatureType
Method for accessing kind ofFormatFeaturethat a parserJsonGeneratorproduced by this factory would accept, if any;nullreturned if none.- Returns:
- Type of format-specific stream read features, if any;
nullif 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.Features enabled- Returns:
- Bitset of enabled
JsonFactory.Features. - 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
JsonParsers 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
JsonGenerators 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 viaByteArrayFeederinterface (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 viaByteBufferFeederinterface (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 anInputStreamfor parsers to use, when input is to be read from givenFile.- Parameters:
f- File to open stream for- Returns:
InputStreamconstructed- Throws:
IOException- If there is a problem opening the stream- Since:
- 2.14
-
_fileOutputStream
Helper methods used for constructing anOutputStreamfor generator to use, when target is to be written into givenFile.- Parameters:
f- File to open stream for- Returns:
OutputStreamconstructed- 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
-