Class TokenStreamFactory
- java.lang.Object
-
- com.fasterxml.jackson.core.TokenStreamFactory
-
- All Implemented Interfaces:
Versioned,java.io.Serializable
- Direct Known Subclasses:
JsonFactory
public abstract class TokenStreamFactory extends java.lang.Object implements Versioned, java.io.Serializable
Intermediate base class for actual format-specific factories for constructing parsers (reading) and generators (writing). Although full power will only be available with Jackson 3, skeletal implementation added in 2.10 to help conversion of code for 2.x to 3.x migration of projects depending on Jackson- Since:
- 2.10
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TokenStreamFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract booleancanHandleBinaryNatively()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 booleancanParseAsync()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 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 JsonGeneratorcreateGenerator(java.io.DataOutput out)abstract JsonGeneratorcreateGenerator(java.io.DataOutput out, JsonEncoding enc)abstract JsonGeneratorcreateGenerator(java.io.File f, JsonEncoding enc)abstract JsonGeneratorcreateGenerator(java.io.OutputStream out)abstract JsonGeneratorcreateGenerator(java.io.OutputStream out, JsonEncoding enc)abstract JsonGeneratorcreateGenerator(java.io.Writer w)abstract JsonParsercreateNonBlockingByteArrayParser()Optional method for constructing parser for non-blocking parsing viaByteArrayFeederinterface (accessed usingJsonParser.getNonBlockingInputFeeder()from constructed instance).abstract JsonParsercreateNonBlockingByteBufferParser()Optional 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 JsonParsercreateParser(java.io.DataInput in)abstract JsonParsercreateParser(java.io.File f)abstract JsonParsercreateParser(java.io.InputStream in)abstract JsonParsercreateParser(java.io.Reader r)abstract JsonParsercreateParser(java.lang.String content)abstract JsonParsercreateParser(java.net.URL url)abstract intgetFactoryFeatures()Method for getting bit set of allJsonFactory.Features enabledabstract intgetFormatGeneratorFeatures()abstract java.lang.StringgetFormatName()Method that returns short textual id identifying format this factory supports.abstract intgetFormatParserFeatures()abstract java.lang.Class<? extends FormatFeature>getFormatReadFeatureType()Method for accessing kind ofFormatFeaturethat a parserJsonParserproduced by this factory would accept, if any;nullreturned if none.abstract java.lang.Class<? extends FormatFeature>getFormatWriteFeatureType()Method for accessing kind ofFormatFeaturethat a parserJsonGeneratorproduced by this factory would accept, if any;nullreturned if none.abstract intgetGeneratorFeatures()abstract intgetParserFeatures()abstract booleanisEnabled(JsonFactory.Feature f)abstract booleanisEnabled(JsonGenerator.Feature f)abstract booleanisEnabled(JsonParser.Feature f)abstract booleanisEnabled(StreamReadFeature f)abstract booleanisEnabled(StreamWriteFeature f)abstract booleanrequiresPropertyOrdering()Introspection method that higher-level functionality may call to see whether underlying data format requires a stable ordering of object properties or not.abstract StreamReadConstraintsstreamReadConstraints()Get the constraints to apply when performing streaming reads.abstract StreamWriteConstraintsstreamWriteConstraints()Get the constraints to apply when performing streaming writes.
-
-
-
Method Detail
-
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
public abstract java.lang.Class<? extends FormatFeature> 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
public abstract java.lang.Class<? extends FormatFeature> 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
public 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. 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
public abstract java.lang.String 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
public abstract boolean isEnabled(JsonFactory.Feature f)
-
isEnabled
public abstract boolean isEnabled(StreamReadFeature f)
-
isEnabled
public abstract boolean isEnabled(StreamWriteFeature f)
-
isEnabled
public abstract boolean isEnabled(JsonParser.Feature f)
-
isEnabled
public abstract boolean isEnabled(JsonGenerator.Feature f)
-
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
public abstract StreamReadConstraints 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
public abstract StreamWriteConstraints 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
public abstract JsonParser createParser(byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
createParser
public abstract JsonParser createParser(byte[] data, int offset, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
createParser
public abstract JsonParser createParser(char[] content) throws java.io.IOException
- Throws:
java.io.IOException
-
createParser
public abstract JsonParser createParser(char[] content, int offset, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
createParser
public abstract JsonParser createParser(java.io.DataInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
createParser
public abstract JsonParser createParser(java.io.File f) throws java.io.IOException
- Throws:
java.io.IOException
-
createParser
public abstract JsonParser createParser(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
createParser
public abstract JsonParser createParser(java.io.Reader r) throws java.io.IOException
- Throws:
java.io.IOException
-
createParser
public abstract JsonParser createParser(java.lang.String content) throws java.io.IOException
- Throws:
java.io.IOException
-
createParser
public abstract JsonParser createParser(java.net.URL url) throws java.io.IOException
- Throws:
java.io.IOException
-
createNonBlockingByteArrayParser
public abstract JsonParser createNonBlockingByteArrayParser() throws java.io.IOException
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:
java.io.IOException- If there are problems constructing parser- Since:
- 2.9
-
createNonBlockingByteBufferParser
public abstract JsonParser createNonBlockingByteBufferParser() throws java.io.IOException
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:
java.io.IOException- If there are problems constructing parser- Since:
- 2.14
-
createGenerator
public abstract JsonGenerator createGenerator(java.io.DataOutput out, JsonEncoding enc) throws java.io.IOException
- Throws:
java.io.IOException
-
createGenerator
public abstract JsonGenerator createGenerator(java.io.DataOutput out) throws java.io.IOException
- Throws:
java.io.IOException
-
createGenerator
public abstract JsonGenerator createGenerator(java.io.File f, JsonEncoding enc) throws java.io.IOException
- Throws:
java.io.IOException
-
createGenerator
public abstract JsonGenerator createGenerator(java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
createGenerator
public abstract JsonGenerator createGenerator(java.io.OutputStream out, JsonEncoding enc) throws java.io.IOException
- Throws:
java.io.IOException
-
createGenerator
public abstract JsonGenerator createGenerator(java.io.Writer w) throws java.io.IOException
- Throws:
java.io.IOException
-
-