Top Description Fields Constructors Methods
com.fasterxml.jackson.core

public abstract Class TokenStreamFactory

extends Object
implements Versioned, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, com.fasterxml.jackson.core.Versioned
Known Direct Subclasses
com.fasterxml.jackson.core.JsonFactory
Imports
java.io.*, java.net.URL, com.fasterxml.jackson.core.io.DataOutputAsStream

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

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
_checkRangeBoundsForByteArray(byte[] data, int offset, int len)

protected void
_checkRangeBoundsForCharArray(char[] data, int offset, int len)

protected OutputStream
protected InputStream

Returns:

InputStream constructed
_fileInputStream
(File
File to open stream for
f
)

Helper methods used for constructing an InputStream for parsers to use, when input is to be read from given File.

protected OutputStream

Returns:

OutputStream constructed
_fileOutputStream
(File
File to open stream for
f
)

Helper methods used for constructing an OutputStream for generator to use, when target is to be written into given File.

protected InputStream

Returns:

InputStream constructed for given URL
_optimizedStreamFromURL
(URL
Source to read content to parse from
url
)

Helper method used for constructing an optimal stream for parsers to use, when input is to be read from an URL.

protected <T> T
public abstract boolean

Returns:

Whether format supported by this factory supports native binary content
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.

public abstract boolean

Returns:

Whether this factory supports non-blocking ("async") parsing or not (and consequently whether createNonBlockingXxx() method(s) work)
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 a com.fasterxml.jackson.core.async.NonBlockingInputFeeder.

public abstract boolean

Returns:

Whether parsers and generators constructed by this factory can use specified format schema instance
canUseSchema
(FormatSchema
Schema instance to check
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.

public abstract JsonGenerator
public abstract JsonGenerator
public abstract JsonGenerator
public abstract JsonGenerator
public abstract JsonGenerator
public abstract JsonGenerator
public abstract JsonParser

Returns:

Constructed parser
createNonBlockingByteArrayParser
()

Optional method for constructing parser for non-blocking parsing via com.fasterxml.jackson.core.async.ByteArrayFeeder interface (accessed using JsonParser#getNonBlockingInputFeeder() from constructed instance).

public abstract JsonParser

Returns:

Constructed parser
createNonBlockingByteBufferParser
()

Optional method for constructing parser for non-blocking parsing via com.fasterxml.jackson.core.async.ByteBufferFeeder interface (accessed using JsonParser#getNonBlockingInputFeeder() from constructed instance).

public abstract JsonParser
createParser(byte[] data)

public abstract JsonParser
createParser(byte[] data, int offset, int len)

public abstract JsonParser
createParser(char[] content)

public abstract JsonParser
createParser(char[] content, int offset, int len)

public abstract JsonParser
public abstract JsonParser
public abstract JsonParser
public abstract JsonParser
public abstract JsonParser
public abstract JsonParser
public abstract int

Returns:

Bitset of enabled JsonFactory.Features.
getFactoryFeatures
()

Method for getting bit set of all JsonFactory.Features enabled

public abstract int
public abstract String

Returns:

Name of the format handled by parsers, generators this factory creates
getFormatName
()

Method that returns short textual id identifying format this factory supports.

public abstract int
public abstract Class<? extends FormatFeature>

Returns:

Type of format-specific stream read features, if any; null if none
getFormatReadFeatureType
()

Method for accessing kind of FormatFeature that a parser JsonParser produced by this factory would accept, if any; null returned if none.

public abstract Class<? extends FormatFeature>

Returns:

Type of format-specific stream read features, if any; null if none
getFormatWriteFeatureType
()

Method for accessing kind of FormatFeature that a parser JsonGenerator produced by this factory would accept, if any; null returned if none.

public abstract int
public abstract int
public abstract boolean
public abstract boolean
public abstract boolean
public abstract boolean
public abstract boolean
public abstract boolean

Returns:

Whether format supported by this factory requires Object properties to be ordered.
requiresPropertyOrdering
()

Introspection method that higher-level functionality may call to see whether underlying data format requires a stable ordering of object properties or not.

public abstract StreamReadConstraints

Returns:

Constraints to apply to reads done by JsonParsers constructed by this factory.
streamReadConstraints
()

Get the constraints to apply when performing streaming reads.

public abstract StreamWriteConstraints

Returns:

Constraints to apply to reads done by JsonGenerators constructed by this factory.
streamWriteConstraints
()

Get the constraints to apply when performing streaming writes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

TokenStreamFactoryback to summary
public TokenStreamFactory()

Method Detail

_checkRangeBoundsForByteArrayback to summary
protected void _checkRangeBoundsForByteArray(byte[] data, int offset, int len) throws IllegalArgumentException
_checkRangeBoundsForCharArrayback to summary
protected void _checkRangeBoundsForCharArray(char[] data, int offset, int len) throws IOException
_createDataOutputWrapperback to summary
protected OutputStream _createDataOutputWrapper(DataOutput out)
_fileInputStreamback to summary
protected InputStream _fileInputStream(File f) throws IOException

Helper methods used for constructing an InputStream for parsers to use, when input is to be read from given File.

Parameters
f:File

File to open stream for

Returns:InputStream

InputStream constructed

Exceptions
IOException:
If there is a problem opening the stream
Since
2.14
_fileOutputStreamback to summary
protected OutputStream _fileOutputStream(File f) throws IOException

Helper methods used for constructing an OutputStream for generator to use, when target is to be written into given File.

Parameters
f:File

File to open stream for

Returns:OutputStream

OutputStream constructed

Exceptions
IOException:
If there is a problem opening the stream
Since
2.14
_optimizedStreamFromURLback to summary
protected InputStream _optimizedStreamFromURL(URL url) throws IOException

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:URL

Source to read content to parse from

Returns:InputStream

InputStream constructed for given URL

Exceptions
IOException:
If there is a problem accessing content from specified URL
_reportRangeErrorback to summary
protected <T> T _reportRangeError(String msg) throws IllegalArgumentException
canHandleBinaryNativelyback to summary
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:boolean

Whether format supported by this factory supports native binary content

canParseAsyncback to summary
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 a com.fasterxml.jackson.core.async.NonBlockingInputFeeder.

Returns:boolean

Whether this factory supports non-blocking ("async") parsing or not (and consequently whether createNonBlockingXxx() method(s) work)

canUseSchemaback to summary
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:FormatSchema

Schema instance to check

Returns:boolean

Whether parsers and generators constructed by this factory can use specified format schema instance

Since
2.1
createGeneratorback to summary
public abstract JsonGenerator createGenerator(DataOutput out, JsonEncoding enc) throws IOException
createGeneratorback to summary
public abstract JsonGenerator createGenerator(DataOutput out) throws IOException
createGeneratorback to summary
public abstract JsonGenerator createGenerator(File f, JsonEncoding enc) throws IOException
createGeneratorback to summary
public abstract JsonGenerator createGenerator(OutputStream out) throws IOException
createGeneratorback to summary
public abstract JsonGenerator createGenerator(OutputStream out, JsonEncoding enc) throws IOException
createGeneratorback to summary
public abstract JsonGenerator createGenerator(Writer w) throws IOException
createNonBlockingByteArrayParserback to summary
public abstract JsonParser createNonBlockingByteArrayParser() throws IOException

Optional method for constructing parser for non-blocking parsing via com.fasterxml.jackson.core.async.ByteArrayFeeder interface (accessed using JsonParser#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:JsonParser

Constructed parser

Exceptions
IOException:
If there are problems constructing parser
Since
2.9
createNonBlockingByteBufferParserback to summary
public abstract JsonParser createNonBlockingByteBufferParser() throws IOException

Optional method for constructing parser for non-blocking parsing via com.fasterxml.jackson.core.async.ByteBufferFeeder interface (accessed using JsonParser#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:JsonParser

Constructed parser

Exceptions
IOException:
If there are problems constructing parser
Since
2.14
createParserback to summary
public abstract JsonParser createParser(byte[] data) throws IOException
createParserback to summary
public abstract JsonParser createParser(byte[] data, int offset, int len) throws IOException
createParserback to summary
public abstract JsonParser createParser(char[] content) throws IOException
createParserback to summary
public abstract JsonParser createParser(char[] content, int offset, int len) throws IOException
createParserback to summary
public abstract JsonParser createParser(DataInput in) throws IOException
createParserback to summary
public abstract JsonParser createParser(File f) throws IOException
createParserback to summary
public abstract JsonParser createParser(InputStream in) throws IOException
createParserback to summary
public abstract JsonParser createParser(Reader r) throws IOException
createParserback to summary
public abstract JsonParser createParser(String content) throws IOException
createParserback to summary
public abstract JsonParser createParser(URL url) throws IOException
getFactoryFeaturesback to summary
public abstract int getFactoryFeatures()

Method for getting bit set of all JsonFactory.Features enabled

Returns:int

Bitset of enabled JsonFactory.Features.

Since
2.16
getFormatGeneratorFeaturesback to summary
public abstract int getFormatGeneratorFeatures()
getFormatNameback to summary
public abstract String getFormatName()

Method that returns short textual id identifying format this factory supports.

Returns:String

Name of the format handled by parsers, generators this factory creates

getFormatParserFeaturesback to summary
public abstract int getFormatParserFeatures()
getFormatReadFeatureTypeback to summary
public abstract Class<? extends FormatFeature> getFormatReadFeatureType()

Method for accessing kind of FormatFeature that a parser JsonParser produced by this factory would accept, if any; null returned if none.

Returns:Class<? extends FormatFeature>

Type of format-specific stream read features, if any; null if none

Since
2.6
getFormatWriteFeatureTypeback to summary
public abstract Class<? extends FormatFeature> getFormatWriteFeatureType()

Method for accessing kind of FormatFeature that a parser JsonGenerator produced by this factory would accept, if any; null returned if none.

Returns:Class<? extends FormatFeature>

Type of format-specific stream read features, if any; null if none

Since
2.6
getGeneratorFeaturesback to summary
public abstract int getGeneratorFeatures()
getParserFeaturesback to summary
public abstract int getParserFeatures()
isEnabledback to summary
public abstract boolean isEnabled(JsonFactory.Feature f)
isEnabledback to summary
public abstract boolean isEnabled(StreamReadFeature f)
isEnabledback to summary
public abstract boolean isEnabled(StreamWriteFeature f)
isEnabledback to summary
public abstract boolean isEnabled(JsonParser.Feature f)
isEnabledback to summary
public abstract boolean isEnabled(JsonGenerator.Feature f)
requiresPropertyOrderingback to summary
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 like CSV, and schema-based binary formats like Avro.

Returns:boolean

Whether format supported by this factory requires Object properties to be ordered.

streamReadConstraintsback to summary
public abstract StreamReadConstraints streamReadConstraints()

Get the constraints to apply when performing streaming reads.

Returns:StreamReadConstraints

Constraints to apply to reads done by JsonParsers constructed by this factory.

Since
2.15
streamWriteConstraintsback to summary
public abstract StreamWriteConstraints streamWriteConstraints()

Get the constraints to apply when performing streaming writes.

Returns:StreamWriteConstraints

Constraints to apply to reads done by JsonGenerators constructed by this factory.

Since
2.16