- All Implemented Interfaces:
Serializable,Snapshottable<TokenStreamFactory>,Versioned
- Direct Known Subclasses:
JsonFactory
TokenStreamFactory sub-class used as the base for
textual data formats.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.core.base.DecorableTSFactory
DecorableTSFactory.DecorableTSFBuilder<F extends TokenStreamFactory,T extends TSFBuilder<F, T>> Nested classes/interfaces inherited from class tools.jackson.core.TokenStreamFactory
TokenStreamFactory.Feature -
Field Summary
Fields inherited from class tools.jackson.core.base.DecorableTSFactory
_generatorDecorators, _inputDecorator, _outputDecoratorFields inherited from class tools.jackson.core.TokenStreamFactory
_errorReportConfiguration, _factoryFeatures, _formatReadFeatures, _formatWriteFeatures, _recyclerPool, _streamReadConstraints, _streamReadFeatures, _streamWriteConstraints, _streamWriteFeatures, DEFAULT_FACTORY_FEATURE_FLAGS, DEFAULT_STREAM_READ_FEATURE_FLAGS, DEFAULT_STREAM_WRITE_FEATURE_FLAGS, EMPTY_WRITE_CONTEXT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTextualTSFactory(DecorableTSFactory.DecorableTSFBuilder<?, ?> baseBuilder) Constructors used by builders for instantiation.protectedprotectedTextualTSFactory(StreamReadConstraints src, StreamWriteConstraints swc, ErrorReportConfiguration erc, int formatPF, int formatGF) -
Method Summary
Modifier and TypeMethodDescriptionprotected ContentReference_createContentReference(Object contentRef) Overridable factory method for constructingContentReferenceto pass to parser or generator being created; used in cases where no offset or length is applicable (either irrelevant, or full contents assumed).protected ContentReference_createContentReference(Object contentRef, int offset, int length) Overridable factory method for constructingContentReferenceto pass to parser or generator being created; used in cases where input comes in a static buffer with relevant offset and length.protected abstract JsonGenerator_createGenerator(ObjectWriteContext writeCtxt, IOContext ioCtxt, Writer out) Overridable factory method that actually instantiates generator for givenWriterand context object.protected abstract JsonParser_createParser(ObjectReadContext readCtxt, IOContext ctxt, byte[] data, int offset, int len) protected abstract JsonParser_createParser(ObjectReadContext readCtxt, IOContext ctxt, char[] data, int offset, int len, boolean recyclable) protected abstract JsonParser_createParser(ObjectReadContext readCtxt, IOContext ctxt, DataInput input) protected abstract JsonParser_createParser(ObjectReadContext readCtxt, IOContext ctxt, InputStream in) protected abstract JsonParser_createParser(ObjectReadContext readCtxt, IOContext ctxt, Reader r) protected abstract JsonGenerator_createUTF8Generator(ObjectWriteContext writeCtxt, IOContext ioCtxt, OutputStream out) Overridable factory method that actually instantiates generator for givenOutputStreamand context object, using UTF-8 encoding.protected Writer_createWriter(IOContext ioCtxt, OutputStream out, JsonEncoding enc) booleanIntrospection method that higher-level functionality may call to see whether underlying data format can read and write binary data natively; that is, embedded it as-is without using encodings such as Base64.booleanIntrospection method that can be used by base factory to check whether access usingchar[]is something that actual parser implementations can take advantage of, over having to useReader.createGenerator(ObjectWriteContext writeCtxt, File f, JsonEncoding enc) Method for constructing generator that writes contents to specified file, overwriting contents it might have (or creating it if such file does not yet exist).createGenerator(ObjectWriteContext writeCtxt, OutputStream out, JsonEncoding enc) Method for constructing generator that writes contents using specifiedOutputStreamwith specified textual encoding (if applicable).createGenerator(ObjectWriteContext writeCtxt, Writer w) Method for constructing generator that writes contents using specifiedWriter.createGenerator(ObjectWriteContext writeCtxt, Path p, JsonEncoding enc) Method for constructing generator that writes contents to specified path, overwriting contents it might have (or creating it if such path does not yet exist).createParser(ObjectReadContext readCtxt, byte[] data, int offset, int len) Method for constructing parser for parsing the contents of given byte array.createParser(ObjectReadContext readCtxt, char[] content, int offset, int len) Method for constructing parser for parsing contents of given char array.createParser(ObjectReadContext readCtxt, DataInput in) Optional method for constructing parser for reading contents from specifiedDataInputinstance.createParser(ObjectReadContext readCtxt, File f) Method for constructing parser instance to decode contents of specified file.createParser(ObjectReadContext readCtxt, InputStream in) Method for constructing JSON parser instance to parse the contents accessed via specified input stream.createParser(ObjectReadContext readCtxt, Reader r) Method for constructing parser for parsing the contents accessed via specified Reader.createParser(ObjectReadContext readCtxt, String content) Method for constructing parser for parsing contents of given String.createParser(ObjectReadContext readCtxt, Path p) Method for constructing parser instance to decode contents of specified path.Methods inherited from class tools.jackson.core.base.DecorableTSFactory
_copy, _decorate, _decorate, _decorate, _decorate, _decorate, _decorate, getGeneratorDecorators, getInputDecorator, getOutputDecoratorMethods inherited from class tools.jackson.core.TokenStreamFactory
_checkRangeBoundsForByteArray, _checkRangeBoundsForCharArray, _createContext, _createContext, _createDataOutputWrapper, _fileInputStream, _fileOutputStream, _getBufferRecycler, _getRecyclerPool, _optimizedStreamFromURL, _pathInputStream, _pathOutputStream, _reportRangeError, _unsupported, _unsupported, _wrapIOFailure, canParseAsync, canUseSchema, constructCINameMatcher, constructNameMatcher, copy, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createNonBlockingByteArrayParser, createNonBlockingByteBufferParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, errorReportConfiguration, getFactoryFeatures, getFormatName, getFormatReadFeatures, getFormatReadFeatureType, getFormatWriteFeatures, getFormatWriteFeatureType, getStreamReadFeatures, getStreamWriteFeatures, isEnabled, isEnabled, isEnabled, rebuild, requiresPropertyOrdering, snapshot, streamReadConstraints, streamWriteConstraints, version
-
Constructor Details
-
TextualTSFactory
protected TextualTSFactory(StreamReadConstraints src, StreamWriteConstraints swc, ErrorReportConfiguration erc, int formatPF, int formatGF) -
TextualTSFactory
Constructors used by builders for instantiation.- Parameters:
baseBuilder- Builder with configurations to use- Since:
- 3.0
-
TextualTSFactory
-
-
Method Details
-
canHandleBinaryNatively
public boolean canHandleBinaryNatively()Description copied from class:TokenStreamFactoryIntrospection method that higher-level functionality may call to see whether underlying data format can read and write binary data natively; that is, embedded it as-is without using encodings such as Base64.- Specified by:
canHandleBinaryNativelyin classTokenStreamFactory- Returns:
- Whether format supported by this factory supports native binary content
-
canUseCharArrays
public boolean canUseCharArrays()Introspection method that can be used by base factory to check whether access usingchar[]is something that actual parser implementations can take advantage of, over having to useReader. Sub-types are expected to override definition; default implementation (suitable for JSON) alleges that optimization are possible; and thereby is likely to try to accessStringcontent by first copying it into recyclable intermediate buffer.Default implementation simply returns
true- Returns:
- Whether efficient access is possible
-
createParser
Description copied from class:TokenStreamFactoryMethod for constructing parser instance to decode contents of specified file.Encoding is auto-detected from contents according to JSON specification recommended mechanism. Json specification supports only UTF-8, UTF-16 and UTF-32 as valid encodings, so auto-detection implemented only for this charsets. For other charsets use
TokenStreamFactory.createParser(java.io.Reader).Underlying input stream (needed for reading contents) will be owned (and managed, i.e. closed as need be) by the parser, since caller has no access to it.
- Specified by:
createParserin classTokenStreamFactory- Parameters:
readCtxt- Object read context to usef- File that contains content to parse- Returns:
- Parser constructed
- Throws:
JacksonException- If parser construction or initialization fails
-
createParser
Description copied from class:TokenStreamFactoryMethod for constructing parser instance to decode contents of specified path.Encoding is auto-detected from contents according to JSON specification recommended mechanism. Json specification supports only UTF-8, UTF-16 and UTF-32 as valid encodings, so auto-detection implemented only for this charsets. For other charsets use
TokenStreamFactory.createParser(java.io.Reader).Underlying input stream (needed for reading contents) will be owned (and managed, i.e. closed as need be) by the parser, since caller has no access to it.
- Specified by:
createParserin classTokenStreamFactory- Parameters:
readCtxt- Object read context to usep- Path that contains content to parse- Returns:
- Parser constructed
- Throws:
JacksonException- If parser construction or initialization fails
-
createParser
Description copied from class:TokenStreamFactoryMethod for constructing JSON parser instance to parse the contents accessed via specified input stream.The input stream will not be owned by the parser, it will still be managed (i.e. closed if end-of-stream is reacher, or parser close method called) if (and only if)
StreamReadFeature.AUTO_CLOSE_SOURCEis enabled.Note: no encoding argument is taken since it can always be auto-detected as suggested by JSON RFC. Json specification supports only UTF-8, UTF-16 and UTF-32 as valid encodings, so auto-detection implemented only for this charsets. For other charsets use
TokenStreamFactory.createParser(java.io.Reader).- Specified by:
createParserin classTokenStreamFactory- Parameters:
readCtxt- Object read context to usein- InputStream to use for reading content to parse- Returns:
- Parser constructed
- Throws:
JacksonException- If parser construction or initialization fails
-
createParser
Description copied from class:TokenStreamFactoryMethod for constructing parser for parsing the contents accessed via specified Reader.The read stream will not be owned by the parser, it will still be managed (i.e. closed if end-of-stream is reacher, or parser close method called) if (and only if)
StreamReadFeature.AUTO_CLOSE_SOURCEis enabled.- Specified by:
createParserin classTokenStreamFactory- Parameters:
readCtxt- Object read context to user- Reader to use for reading content to parse- Returns:
- Parser constructed
- Throws:
JacksonException- If parser construction or initialization fails
-
createParser
public JsonParser createParser(ObjectReadContext readCtxt, byte[] data, int offset, int len) throws JacksonException Description copied from class:TokenStreamFactoryMethod for constructing parser for parsing the contents of given byte array.- Specified by:
createParserin classTokenStreamFactory- Parameters:
readCtxt- Object read context to usedata- Buffer that contains data to parseoffset- Offset of the first data byte within bufferlen- Length of contents to parse within buffer- Returns:
- Parser constructed
- Throws:
JacksonException- If parser construction or initialization fails
-
createParser
Description copied from class:TokenStreamFactoryMethod for constructing parser for parsing contents of given String.- Specified by:
createParserin classTokenStreamFactory- Parameters:
readCtxt- Object read context to usecontent- Content to read- Returns:
- Parser constructed
- Throws:
JacksonException- If parser construction or initialization fails
-
createParser
public JsonParser createParser(ObjectReadContext readCtxt, char[] content, int offset, int len) throws JacksonException Description copied from class:TokenStreamFactoryMethod for constructing parser for parsing contents of given char array.- Specified by:
createParserin classTokenStreamFactory- Parameters:
readCtxt- Object read context to usecontent- Buffer that contains data to parseoffset- Offset of the first data byte within bufferlen- Length of contents to parse within buffer- Returns:
- Parser constructed
- Throws:
JacksonException- If parser construction or initialization fails
-
createParser
Description copied from class:TokenStreamFactoryOptional method for constructing parser for reading contents from specifiedDataInputinstance.If this factory does not support
DataInputas source, will throwUnsupportedOperationException- Specified by:
createParserin classTokenStreamFactory- Parameters:
readCtxt- Object read context to usein- InputStream to use for reading content to parse- Returns:
- Parser constructed
- Throws:
JacksonException- If parser construction or initialization fails
-
_createParser
protected abstract JsonParser _createParser(ObjectReadContext readCtxt, IOContext ctxt, InputStream in) throws JacksonException - Throws:
JacksonException
-
_createParser
protected abstract JsonParser _createParser(ObjectReadContext readCtxt, IOContext ctxt, Reader r) throws JacksonException - Throws:
JacksonException
-
_createParser
protected abstract JsonParser _createParser(ObjectReadContext readCtxt, IOContext ctxt, byte[] data, int offset, int len) throws JacksonException - Throws:
JacksonException
-
_createParser
protected abstract JsonParser _createParser(ObjectReadContext readCtxt, IOContext ctxt, char[] data, int offset, int len, boolean recyclable) throws JacksonException - Throws:
JacksonException
-
_createParser
protected abstract JsonParser _createParser(ObjectReadContext readCtxt, IOContext ctxt, DataInput input) throws JacksonException - Throws:
JacksonException
-
createGenerator
public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, OutputStream out, JsonEncoding enc) throws JacksonException Description copied from class:TokenStreamFactoryMethod for constructing generator that writes contents using specifiedOutputStreamwith specified textual encoding (if applicable).Underlying stream is NOT owned by the generator constructed, so that generator will NOT close the output stream when
JsonGenerator.close()is called (unless auto-closing feature,StreamWriteFeature.AUTO_CLOSE_TARGETis enabled). Using application needs to close it explicitly if this is the case.- Specified by:
createGeneratorin classTokenStreamFactory- Parameters:
writeCtxt- Object-binding context where applicable; used for providing contextual configurationout- OutputStream to use for writing contentenc- Character set encoding to use (usuallyJsonEncoding.UTF8)- Returns:
- Generator constructed
- Throws:
JacksonException- If generator construction or initialization fails
-
createGenerator
public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, Writer w) throws JacksonException Description copied from class:TokenStreamFactoryMethod for constructing generator that writes contents using specifiedWriter. Textual encoding used will be UTF-8, where applicable.Underlying stream is NOT owned by the generator constructed, so that generator will NOT close the Reader when
JsonGenerator.close()is called (unless auto-closing feature,StreamWriteFeature.AUTO_CLOSE_TARGETis enabled). Using application needs to close it explicitly.- Specified by:
createGeneratorin classTokenStreamFactory- Parameters:
writeCtxt- Object-binding context where applicable; used for providing contextual configurationw- Writer to use for writing content- Returns:
- Generator constructed
- Throws:
JacksonException- If generator construction or initialization fails
-
createGenerator
public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, File f, JsonEncoding enc) throws JacksonException Description copied from class:TokenStreamFactoryMethod for constructing generator that writes contents to specified file, overwriting contents it might have (or creating it if such file does not yet exist).Underlying stream is owned by the generator constructed, i.e. generator will handle closing of file when
JsonGenerator.close()is called.- Specified by:
createGeneratorin classTokenStreamFactory- Parameters:
writeCtxt- Object-binding context where applicable; used for providing contextual configurationf- File to write contents toenc- Character set encoding to use (usuallyJsonEncoding.UTF8)- Returns:
- Generator constructed
- Throws:
JacksonException- If generator construction or initialization fails
-
createGenerator
public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, Path p, JsonEncoding enc) throws JacksonException Description copied from class:TokenStreamFactoryMethod for constructing generator that writes contents to specified path, overwriting contents it might have (or creating it if such path does not yet exist).Underlying stream is owned by the generator constructed, i.e. generator will handle closing of path when
JsonGenerator.close()is called.- Specified by:
createGeneratorin classTokenStreamFactory- Parameters:
writeCtxt- Object-binding context where applicable; used for providing contextual configurationp- Path to write contents toenc- Character set encoding to use (usuallyJsonEncoding.UTF8)- Returns:
- Generator constructed
- Throws:
JacksonException- If generator construction or initialization fails
-
_createContentReference
Description copied from class:TokenStreamFactoryOverridable factory method for constructingContentReferenceto pass to parser or generator being created; used in cases where no offset or length is applicable (either irrelevant, or full contents assumed).- Specified by:
_createContentReferencein classTokenStreamFactory- Parameters:
contentRef- Underlying input source (parser) or target (generator)- Returns:
- InputSourceReference instance to use
-
_createContentReference
Description copied from class:TokenStreamFactoryOverridable factory method for constructingContentReferenceto pass to parser or generator being created; used in cases where input comes in a static buffer with relevant offset and length.- Specified by:
_createContentReferencein classTokenStreamFactory- Parameters:
contentRef- Underlying input source (parser) or target (generator)offset- Offset of content in buffer (rawSource)length- Length of content in buffer (rawSource)- Returns:
- InputSourceReference instance to use
-
_createGenerator
protected abstract JsonGenerator _createGenerator(ObjectWriteContext writeCtxt, IOContext ioCtxt, Writer out) throws JacksonException Overridable factory method that actually instantiates generator for givenWriterand context object.This method is specifically designed to remain compatible between minor versions so that sub-classes can count on it being called as expected. That is, it is part of official interface from sub-class perspective, although not a public method available to users of factory implementations.
- Parameters:
writeCtxt- Object write context for generator to useioCtxt- IOContext for generator to useout- Writer for generator to use- Returns:
- Generator constructed
- Throws:
JacksonException- If there is a problem constructing generator
-
_createUTF8Generator
protected abstract JsonGenerator _createUTF8Generator(ObjectWriteContext writeCtxt, IOContext ioCtxt, OutputStream out) throws JacksonException Overridable factory method that actually instantiates generator for givenOutputStreamand context object, using UTF-8 encoding.This method is specifically designed to remain compatible between minor versions so that sub-classes can count on it being called as expected. That is, it is part of official interface from sub-class perspective, although not a public method available to users of factory implementations.
- Parameters:
writeCtxt- Object write context for generator to useioCtxt- IOContext for generator to useout- OutputStream for generator to use- Returns:
- Generator constructed
- Throws:
JacksonException- If there is a problem constructing generator
-
_createWriter
protected Writer _createWriter(IOContext ioCtxt, OutputStream out, JsonEncoding enc) throws JacksonException - Throws:
JacksonException
-