com.fasterxml.jackson.core

## Class TokenStreamFactory

- java.lang.Object
- - com.fasterxml.jackson.core.TokenStreamFactory

All Implemented Interfaces:
  Versioned, Serializable

Direct Known Subclasses:
  JsonFactory

    public abstract class TokenStreamFactory
    extends Object
    implements Versioned, 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 and Description
`TokenStreamFactory()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected OutputStream` `_createDataOutputWrapper(DataOutput out)`
`protected InputStream` `_optimizedStreamFromURL(URL url)` Helper methods used for constructing an optimal stream for parsers to use, when input is to be read from an URL.
`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.
`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 `NonBlockingInputFeeder`.
`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` `createGenerator(DataOutput out)`
`abstract JsonGenerator` `createGenerator(DataOutput out, JsonEncoding enc)`
`abstract JsonGenerator` `createGenerator(File f, JsonEncoding enc)`
`abstract JsonGenerator` `createGenerator(OutputStream out)`
`abstract JsonGenerator` `createGenerator(OutputStream out, JsonEncoding enc)`
`abstract JsonGenerator` `createGenerator(Writer w)`
`abstract JsonParser` `createNonBlockingByteArrayParser()`
`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` `createParser(DataInput in)`
`abstract JsonParser` `createParser(File f)`
`abstract JsonParser` `createParser(InputStream in)`
`abstract JsonParser` `createParser(Reader r)`
`abstract JsonParser` `createParser(String content)`
`abstract JsonParser` `createParser(URL url)`
`abstract int` `getFormatGeneratorFeatures()`
`abstract String` `getFormatName()` Method that returns short textual id identifying format this factory supports.
`abstract int` `getFormatParserFeatures()`
`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.
`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.
`abstract int` `getGeneratorFeatures()`
`abstract int` `getParserFeatures()`
`abstract boolean` `isEnabled(JsonGenerator.Feature f)`
`abstract boolean` `isEnabled(JsonParser.Feature f)`
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface com.fasterxml.jackson.core.Versioned

`version`

### Constructor Detail

#### TokenStreamFactory

    public TokenStreamFactory()

### 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 `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`.

#### 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.

#### 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 a `NonBlockingInputFeeder`.

#### getFormatReadFeatureType

    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.

Since:
  2.6

#### getFormatWriteFeatureType

    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.

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.

Since:
  2.1

#### getFormatName

    public abstract String getFormatName()

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

#### isEnabled

    public abstract boolean isEnabled(JsonParser.Feature f)

#### isEnabled

    public abstract boolean isEnabled(JsonGenerator.Feature f)

#### getParserFeatures

    public abstract int getParserFeatures()

#### getGeneratorFeatures

    public abstract int getGeneratorFeatures()

#### getFormatParserFeatures

    public abstract int getFormatParserFeatures()

#### getFormatGeneratorFeatures

    public abstract int getFormatGeneratorFeatures()

#### createParser

    public abstract JsonParser createParser(byte[] data)
                                     throws IOException

Throws:
  `IOException`

#### createParser

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

Throws:
  `IOException`

#### createParser

    public abstract JsonParser createParser(char[] content)
                                     throws IOException

Throws:
  `IOException`

#### createParser

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

Throws:
  `IOException`

#### createParser

    public abstract JsonParser createParser(DataInput in)
                                     throws IOException

Throws:
  `IOException`

#### createParser

    public abstract JsonParser createParser(File f)
                                     throws IOException

Throws:
  `IOException`

#### createParser

    public abstract JsonParser createParser(InputStream in)
                                     throws IOException

Throws:
  `IOException`

#### createParser

    public abstract JsonParser createParser(Reader r)
                                     throws IOException

Throws:
  `IOException`

#### createParser

    public abstract JsonParser createParser(String content)
                                     throws IOException

Throws:
  `IOException`

#### createParser

    public abstract JsonParser createParser(URL url)
                                     throws IOException

Throws:
  `IOException`

#### createNonBlockingByteArrayParser

    public abstract JsonParser createNonBlockingByteArrayParser()
                                                         throws IOException

Throws:
  `IOException`

#### createGenerator

    public abstract JsonGenerator createGenerator(DataOutput out,
                                                  JsonEncoding enc)
                                           throws IOException

Throws:
  `IOException`

#### createGenerator

    public abstract JsonGenerator createGenerator(DataOutput out)
                                           throws IOException

Throws:
  `IOException`

#### createGenerator

    public abstract JsonGenerator createGenerator(File f,
                                                  JsonEncoding enc)
                                           throws IOException

Throws:
  `IOException`

#### createGenerator

    public abstract JsonGenerator createGenerator(OutputStream out)
                                           throws IOException

Throws:
  `IOException`

#### createGenerator

    public abstract JsonGenerator createGenerator(OutputStream out,
                                                  JsonEncoding enc)
                                           throws IOException

Throws:
  `IOException`

#### createGenerator

    public abstract JsonGenerator createGenerator(Writer w)
                                           throws IOException

Throws:
  `IOException`

#### _createDataOutputWrapper

    protected OutputStream _createDataOutputWrapper(DataOutput out)

#### _optimizedStreamFromURL

    protected InputStream _optimizedStreamFromURL(URL url)
                                           throws IOException

Helper methods 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.

Throws:
  `IOException`