Class TokenStreamFactory

java.lang.Object
tools.jackson.core.TokenStreamFactory
All Implemented Interfaces:
Serializable, Snapshottable<TokenStreamFactory>, Versioned
Direct Known Subclasses:
DecorableTSFactory

public abstract class TokenStreamFactory extends Object implements Versioned, Serializable, Snapshottable<TokenStreamFactory>
The main factory class of Jackson streaming package, used to configure and construct token reader (aka parser, JsonParser) and token writer (aka generator, JsonGenerator) instances.

Factory instances are thread-safe and reusable after configuration (if any). Typically applications and services use only a single globally shared factory instance, unless they need differently configured factories. Factory reuse is important if efficiency matters; most recycling of expensive construct is done on per-factory basis.

Creation of a factory instance is a light-weight operation.

Since:
3.0 (refactored out of JsonFactory)
See Also:
  • Field Details

    • EMPTY_WRITE_CONTEXT

      public static final ObjectWriteContext EMPTY_WRITE_CONTEXT
      Shareable stateles "empty" ObjectWriteContext Object, passed in cases where caller had not passed actual context - "null object" of sort.
    • DEFAULT_FACTORY_FEATURE_FLAGS

      protected static final int DEFAULT_FACTORY_FEATURE_FLAGS
      Bitfield (set of flags) of all factory features that are enabled by default.
    • DEFAULT_STREAM_READ_FEATURE_FLAGS

      protected static final int DEFAULT_STREAM_READ_FEATURE_FLAGS
      Bitfield (set of flags) of all parser features that are enabled by default.
    • DEFAULT_STREAM_WRITE_FEATURE_FLAGS

      protected static final int DEFAULT_STREAM_WRITE_FEATURE_FLAGS
      Bitfield (set of flags) of all generator features that are enabled by default.
    • _factoryFeatures

      protected final int _factoryFeatures
      Currently enabled TokenStreamFactory.Features features as a bitmask.
    • _streamReadFeatures

      protected final int _streamReadFeatures
      Currently enabled StreamReadFeatures as a bitmask.
    • _streamWriteFeatures

      protected final int _streamWriteFeatures
      Currently enabled StreamWriteFeatures as a bitmask.
    • _formatReadFeatures

      protected final int _formatReadFeatures
      Set of format-specific read features enabled, as bitmask.
    • _formatWriteFeatures

      protected final int _formatWriteFeatures
      Set of format-specific write features enabled, as bitmask.
    • _recyclerPool

      protected final RecyclerPool<BufferRecycler> _recyclerPool
    • _streamReadConstraints

      protected final StreamReadConstraints _streamReadConstraints
      Active StreamReadConstraints to use.
    • _streamWriteConstraints

      protected final StreamWriteConstraints _streamWriteConstraints
      Active StreamWriteConstraints to use.
    • _errorReportConfiguration

      protected final ErrorReportConfiguration _errorReportConfiguration
      Active ErrorReportConfiguration to use.
  • Constructor Details

    • TokenStreamFactory

      protected TokenStreamFactory(StreamReadConstraints src, StreamWriteConstraints swc, ErrorReportConfiguration erc, int formatReadFeatures, int formatWriteFeatures)
      Default constructor used to create factory instances. Creation of a factory instance is a light-weight operation, but it is still a good idea to reuse limited number of factory instances (and quite often just a single instance): factories are used as context for storing some reused processing objects (such as symbol tables parsers use) and this reuse only works within context of a single factory instance.
      Parameters:
      src - StreamReadConstraints to use with parsers factory creates
      swc - StreamWriteConstraints to use with generators factory creates
      erc - ErrorReportConfiguration to use with parsers factory creates
      formatReadFeatures - Bitmask of format-specific read features enabled
      formatWriteFeatures - Bitmask of format-specific write features enabled
    • TokenStreamFactory

      protected TokenStreamFactory(TSFBuilder<?,?> baseBuilder)
      Constructors used by TSFBuilder for instantiation. Base builder is passed as-is to try to make interface between base types and implementations less likely to change (given that sub-classing is a fragile way to do it): if and when new general-purpose properties are added, implementation classes do not have to use different constructors.
      Parameters:
      baseBuilder - Builder with configuration to use
      Since:
      3.0
    • TokenStreamFactory

      protected TokenStreamFactory(TokenStreamFactory src)
      Constructor used if a snapshot is created, or possibly for sub-classing or wrapping (delegating)
      Parameters:
      src - Source factory with configuration to copy
  • Method Details

    • copy

      public abstract TokenStreamFactory copy()
      Method similar to snapshot(), but one that forces creation of actual new copy that does NOT share any state, even non-visible to calling code, such as symbol table reuse.

      Implementation should be functionally equivalent to:

          factoryInstance.rebuild().build();
      
      Returns:
      Newly constructed stream factory instance of same type as this one, with identical configuration settings
    • snapshot

      public abstract TokenStreamFactory snapshot()
      Method for constructing a new TokenStreamFactory that has the same settings as this instance, but is otherwise independent (i.e. nothing is actually shared, symbol tables are separate).

      Although assumption is that all factories are immutable -- and that we could usually simply return `this` -- method is left unimplemented at this level to make implementors aware of requirement to consider immutability.

      Specified by:
      snapshot in interface Snapshottable<TokenStreamFactory>
      Returns:
      This factory instance to allow call chaining
      Since:
      3.0
    • rebuild

      public abstract TSFBuilder<?,?> rebuild()
      Method that can be used to create differently configured stream factories: it will create and return a Builder instance with exact settings of this stream factory.
      Returns:
      Builder instance initialized with configuration this stream factory has
      Since:
      3.0
    • requiresPropertyOrdering

      public 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.
      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, embedded it as-is without using encodings such as Base64.
      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 a NonBlockingInputFeeder.
      Returns:
      Whether this factory supports non-blocking ("async") parsing or not (and consequently whether createNonBlockingXxx() method(s) work)
    • getFormatReadFeatureType

      public 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:
      Type of format-specific stream read features, if any; null if none
    • getFormatWriteFeatureType

      public 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:
      Type of format-specific stream read features, if any; null if none
    • 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
    • getFormatName

      public abstract 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
    • version

      public abstract Version version()
      Description copied from interface: Versioned
      Method called to detect version of the component that implements this interface; returned version should never be null, but may return specific "not available" instance (see Version for details).
      Specified by:
      version in interface Versioned
      Returns:
      Version of the component
    • isEnabled

      public final boolean isEnabled(TokenStreamFactory.Feature f)
      Checked whether specified parser feature is enabled.
      Parameters:
      f - Feature to check
      Returns:
      True if feature is enabled; false otherwise
    • isEnabled

      public final boolean isEnabled(StreamReadFeature f)
      Checked whether specified parser feature is enabled.
      Parameters:
      f - Feature to check
      Returns:
      True if feature is enabled; false otherwise
    • isEnabled

      public final boolean isEnabled(StreamWriteFeature f)
      Checked whether specified parser feature is enabled.
      Parameters:
      f - Feature to check
      Returns:
      True if feature is enabled; false otherwise
    • getFactoryFeatures

      public final int getFactoryFeatures()
    • getStreamReadFeatures

      public final int getStreamReadFeatures()
    • getStreamWriteFeatures

      public final int getStreamWriteFeatures()
    • getFormatReadFeatures

      public int getFormatReadFeatures()
    • getFormatWriteFeatures

      public int getFormatWriteFeatures()
    • streamReadConstraints

      public StreamReadConstraints streamReadConstraints()
    • streamWriteConstraints

      public StreamWriteConstraints streamWriteConstraints()
    • errorReportConfiguration

      public ErrorReportConfiguration errorReportConfiguration()
    • constructNameMatcher

      public PropertyNameMatcher constructNameMatcher(List<Named> matches, boolean alreadyInterned)
      Factory method for constructing case-sensitive PropertyNameMatcher for given names. It will call String.intern() on names unless specified that this has already been done by caller.
      Parameters:
      matches - Names to match, including both primary names and possible aliases
      alreadyInterned - Whether name Strings are already String.intern()ed or not
      Returns:
      Case-sensitive PropertyNameMatcher instance to use
    • constructCINameMatcher

      public PropertyNameMatcher constructCINameMatcher(List<Named> matches, boolean alreadyInterned, Locale locale)
      Factory method for constructing case-insensitive PropertyNameMatcher for given names. It will call String.intern() on names unless specified that this has already been done by caller.
      Parameters:
      matches - Names to match, including both primary names and possible aliases
      alreadyInterned - Whether name Strings are already String.intern()ed or not
      locale - Locale to use for case-handling
      Returns:
      Case-insensitive PropertyNameMatcher instance to use
    • createParser

      public abstract JsonParser createParser(ObjectReadContext readCtxt, File f) throws JacksonException
      Method 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 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.

      Parameters:
      readCtxt - Object read context to use
      f - File that contains content to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      public abstract JsonParser createParser(ObjectReadContext readCtxt, Path p) throws JacksonException
      Method 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 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.

      Parameters:
      readCtxt - Object read context to use
      p - Path that contains content to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
      Since:
      3.0
    • createParser

      public abstract JsonParser createParser(ObjectReadContext readCtxt, InputStream in) throws JacksonException
      Method 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_SOURCE is 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 createParser(java.io.Reader).

      Parameters:
      readCtxt - Object read context to use
      in - InputStream to use for reading content to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      public abstract JsonParser createParser(ObjectReadContext readCtxt, Reader r) throws JacksonException
      Method 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_SOURCE is enabled.

      Parameters:
      readCtxt - Object read context to use
      r - 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) throws JacksonException
      Method for constructing parser for parsing the contents of given byte array.
      Parameters:
      readCtxt - Object read context to use
      data - Content to read
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      public abstract JsonParser createParser(ObjectReadContext readCtxt, byte[] content, int offset, int len) throws JacksonException
      Method for constructing parser for parsing the contents of given byte array.
      Parameters:
      readCtxt - Object read context to use
      content - Buffer that contains data to parse
      offset - Offset of the first data byte within buffer
      len - Length of contents to parse within buffer
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      public abstract JsonParser createParser(ObjectReadContext readCtxt, String content) throws JacksonException
      Method for constructing parser for parsing contents of given String.
      Parameters:
      readCtxt - Object read context to use
      content - Content to read
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      public JsonParser createParser(ObjectReadContext readCtxt, char[] content) throws JacksonException
      Method for constructing parser for parsing contents of given char array.
      Parameters:
      readCtxt - Object read context to use
      content - Content to read
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      public abstract JsonParser createParser(ObjectReadContext readCtxt, char[] content, int offset, int len) throws JacksonException
      Method for constructing parser for parsing contents of given char array.
      Parameters:
      readCtxt - Object read context to use
      content - Buffer that contains data to parse
      offset - Offset of the first data byte within buffer
      len - Length of contents to parse within buffer
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      @Deprecated public JsonParser createParser(File f) throws JacksonException
      Parameters:
      f - File that contains content to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      @Deprecated public JsonParser createParser(InputStream in) throws JacksonException
      Parameters:
      in - InputStream to use for reading content to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      @Deprecated public JsonParser createParser(Reader r) throws JacksonException
      Parameters:
      r - Reader to use for reading content to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      @Deprecated public JsonParser createParser(byte[] content) throws JacksonException
      Deprecated.
      Parameters:
      content - Buffer that contains content to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      @Deprecated public JsonParser createParser(byte[] content, int offset, int len) throws JacksonException
      Parameters:
      content - Buffer that contains content to parse
      offset - Offset of the first data byte within buffer
      len - Length of contents to parse within buffer
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      @Deprecated public JsonParser createParser(String content) throws JacksonException
      Deprecated.
      Parameters:
      content - Content to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      @Deprecated public JsonParser createParser(char[] content) throws JacksonException
      Deprecated.
      Parameters:
      content - Buffer that contains data to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      @Deprecated public JsonParser createParser(char[] content, int offset, int len) throws JacksonException
      Parameters:
      content - Buffer that contains data to parse
      offset - Offset of the first data byte within buffer
      len - Length of contents to parse within buffer
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createParser

      public abstract JsonParser createParser(ObjectReadContext readCtxt, DataInput in) throws JacksonException
      Optional method for constructing parser for reading contents from specified DataInput instance.

      If this factory does not support DataInput as source, will throw UnsupportedOperationException

      Parameters:
      readCtxt - Object read context to use
      in - InputStream to use for reading content to parse
      Returns:
      Parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createNonBlockingByteArrayParser

      public <P extends JsonParser & ByteArrayFeeder> P createNonBlockingByteArrayParser(ObjectReadContext readCtxt) throws JacksonException
      Optional method for constructing parser for non-blocking parsing via ByteArrayFeeder interface (accessed using JsonParser.nonBlockingInputFeeder() 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.

      Type Parameters:
      P - Nominal type of parser constructed and returned
      Parameters:
      readCtxt - Object read context to use
      Returns:
      Non-blocking parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createNonBlockingByteBufferParser

      public <P extends JsonParser & ByteArrayFeeder> P createNonBlockingByteBufferParser(ObjectReadContext readCtxt) throws JacksonException
      Optional method for constructing parser for non-blocking parsing via ByteBufferFeeder interface (accessed using JsonParser.nonBlockingInputFeeder() 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.

      Type Parameters:
      P - Nominal type of parser constructed and returned
      Parameters:
      readCtxt - Object read context to use
      Returns:
      Non-blocking parser constructed
      Throws:
      JacksonException - If parser construction or initialization fails
    • createGenerator

      public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, OutputStream out) throws JacksonException
      Method for constructing generator that writes contents using specified OutputStream. 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 output stream when JsonGenerator.close() is called (unless auto-closing feature, StreamWriteFeature.AUTO_CLOSE_TARGET is enabled). Using application needs to close it explicitly if this is the case.

      Parameters:
      writeCtxt - Object-binding context where applicable; used for providing contextual configuration
      out - OutputStream to use for writing content
      Returns:
      Generator constructed
      Throws:
      JacksonException - If generator construction or initialization fails
      Since:
      3.0
    • createGenerator

      public abstract JsonGenerator createGenerator(ObjectWriteContext writeCtxt, OutputStream out, JsonEncoding enc) throws JacksonException
      Method for constructing generator that writes contents using specified OutputStream with 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_TARGET is enabled). Using application needs to close it explicitly if this is the case.

      Parameters:
      writeCtxt - Object-binding context where applicable; used for providing contextual configuration
      out - OutputStream to use for writing content
      enc - Character set encoding to use (usually JsonEncoding.UTF8)
      Returns:
      Generator constructed
      Throws:
      JacksonException - If generator construction or initialization fails
      Since:
      3.0
    • createGenerator

      public abstract JsonGenerator createGenerator(ObjectWriteContext writeCtxt, Writer w) throws JacksonException
      Method for constructing generator that writes contents using specified Writer. 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_TARGET is enabled). Using application needs to close it explicitly.

      Parameters:
      writeCtxt - Object-binding context where applicable; used for providing contextual configuration
      w - Writer to use for writing content
      Returns:
      Generator constructed
      Throws:
      JacksonException - If generator construction or initialization fails
      Since:
      3.0
    • createGenerator

      public abstract JsonGenerator createGenerator(ObjectWriteContext writeCtxt, File f, JsonEncoding enc) throws JacksonException
      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).

      Underlying stream is owned by the generator constructed, i.e. generator will handle closing of file when JsonGenerator.close() is called.

      Parameters:
      writeCtxt - Object-binding context where applicable; used for providing contextual configuration
      f - File to write contents to
      enc - Character set encoding to use (usually JsonEncoding.UTF8)
      Returns:
      Generator constructed
      Throws:
      JacksonException - If generator construction or initialization fails
      Since:
      3.0
    • createGenerator

      public abstract JsonGenerator createGenerator(ObjectWriteContext writeCtxt, Path p, JsonEncoding enc) throws JacksonException
      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).

      Underlying stream is owned by the generator constructed, i.e. generator will handle closing of path when JsonGenerator.close() is called.

      Parameters:
      writeCtxt - Object-binding context where applicable; used for providing contextual configuration
      p - Path to write contents to
      enc - Character set encoding to use (usually JsonEncoding.UTF8)
      Returns:
      Generator constructed
      Throws:
      JacksonException - If generator construction or initialization fails
      Since:
      3.0
    • createGenerator

      public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, DataOutput out) throws JacksonException
      Method for constructing generator that writes content into specified DataOutput, using UTF-8 encoding (with formats where encoding is user-configurable).
      Parameters:
      writeCtxt - Object-binding context where applicable; used for providing contextual configuration
      out - DataOutput used as target of generation
      Returns:
      Generator constructed
      Throws:
      JacksonException - If generator construction or initialization fails
      Since:
      3.0
    • createGenerator

      @Deprecated public JsonGenerator createGenerator(OutputStream out, JsonEncoding enc) throws JacksonException
      Deprecated.
      Method for constructing JSON generator for writing content using specified output stream. Encoding to use must be specified, and needs to be one of available types (as per JSON specification).

      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_TARGET is enabled). Using application needs to close it explicitly if this is the case.

      Note: there are formats that use fixed encoding (like most binary data formats) and that ignore passed in encoding.

      Parameters:
      out - OutputStream to use for writing content
      enc - Character encoding to use
      Returns:
      Generator constructed
      Throws:
      JacksonException - If generator construction or initialization fails
    • createGenerator

      @Deprecated public JsonGenerator createGenerator(OutputStream out) throws JacksonException
      Deprecated.
      Convenience method for constructing generator that uses default encoding of the format (UTF-8 for JSON and most other data formats),
      Parameters:
      out - OutputStream to use for writing content
      Returns:
      Generator constructed
      Throws:
      JacksonException - If generator construction or initialization fails
    • createGenerator

      @Deprecated public JsonGenerator createGenerator(Writer w) throws JacksonException
      Deprecated.
      Method for constructing JSON generator for writing content using specified Writer.

      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_TARGET is enabled). Using application needs to close it explicitly.

      Parameters:
      w - Writer to use for writing content
      Returns:
      Generator constructed
      Throws:
      JacksonException - If generator construction or initialization fails
    • _getBufferRecycler

      public BufferRecycler _getBufferRecycler()
      Method used by factory to create buffer recycler instances for parsers and generators.

      Note: only public to give access for ObjectMapper

      Returns:
      BufferRecycler instance to use
    • _getRecyclerPool

      public RecyclerPool<BufferRecycler> _getRecyclerPool()
      Accessor for getting access to RecyclerPool for getting BufferRecycler instance to use.
      Returns:
      RecyclerPool configured for (and used by) this factory.
    • _createContext

      protected IOContext _createContext(ContentReference contentRef, boolean resourceManaged)
      Overridable factory method that actually instantiates desired context object.
      Parameters:
      contentRef - Source reference to use (relevant to TokenStreamLocation construction)
      resourceManaged - Whether input/output buffers used are managed by this factory
      Returns:
      Context constructed
    • _createContext

      protected IOContext _createContext(ContentReference contentRef, boolean resourceManaged, JsonEncoding enc)
      Overridable factory method that actually instantiates desired context object.
      Parameters:
      contentRef - Source reference to use (relevant to TokenStreamLocation construction)
      resourceManaged - Whether input/output buffers used are managed by this factory
      enc - Character encoding defined to be used/expected
      Returns:
      Context constructed
    • _createContentReference

      protected abstract ContentReference _createContentReference(Object contentRef)
      Overridable factory method for constructing ContentReference to pass to parser or generator being created; used in cases where no offset or length is applicable (either irrelevant, or full contents assumed).
      Parameters:
      contentRef - Underlying input source (parser) or target (generator)
      Returns:
      InputSourceReference instance to use
    • _createContentReference

      protected abstract ContentReference _createContentReference(Object contentRef, int offset, int length)
      Overridable factory method for constructing ContentReference to pass to parser or generator being created; used in cases where input comes in a static buffer with relevant offset and length.
      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
    • _createDataOutputWrapper

      protected OutputStream _createDataOutputWrapper(DataOutput out)
    • _optimizedStreamFromURL

      @Deprecated protected InputStream _optimizedStreamFromURL(URL url) throws JacksonException
      Deprecated.
      Since 3.0
      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:
      JacksonException - If there is a problem accessing content from specified URL
    • _fileInputStream

      protected InputStream _fileInputStream(File f) throws JacksonException
      Helper methods used for constructing an InputStream for parsers to use, when input is to be read from given File.
      Parameters:
      f - File to open stream for
      Returns:
      InputStream constructed
      Throws:
      JacksonException - If there is a problem opening the stream
    • _pathInputStream

      protected InputStream _pathInputStream(Path p) throws JacksonException
      Throws:
      JacksonException
    • _fileOutputStream

      protected OutputStream _fileOutputStream(File f) throws JacksonException
      Helper methods used for constructing an OutputStream for generator to use, when target is to be written into given File.
      Parameters:
      f - File to open stream for
      Returns:
      OutputStream constructed
      Throws:
      JacksonException - If there is a problem opening the stream
    • _pathOutputStream

      protected OutputStream _pathOutputStream(Path p) throws JacksonException
      Throws:
      JacksonException
    • _checkRangeBoundsForByteArray

      protected void _checkRangeBoundsForByteArray(byte[] data, int offset, int len) throws JacksonException
      Throws:
      JacksonException
    • _checkRangeBoundsForCharArray

      protected void _checkRangeBoundsForCharArray(char[] data, int offset, int len) throws JacksonException
      Throws:
      JacksonException
    • _reportRangeError

      protected <T> T _reportRangeError(String msg) throws JacksonException
      Throws:
      JacksonException
    • _wrapIOFailure

      protected JacksonException _wrapIOFailure(IOException e)
    • _unsupported

      protected <T> T _unsupported()
    • _unsupported

      protected <T> T _unsupported(String str, Object... args)