Class BinaryTSFactory

All Implemented Interfaces:
Serializable, Snapshottable<TokenStreamFactory>, Versioned

public abstract class BinaryTSFactory extends DecorableTSFactory implements Serializable
Intermediate TokenStreamFactory sub-class used as the base for binary (non-textual) data formats.
See Also:
  • Constructor Details

  • Method Details

    • canHandleBinaryNatively

      public boolean canHandleBinaryNatively()
      Description copied from class: TokenStreamFactory
      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.
      Specified by:
      canHandleBinaryNatively in class TokenStreamFactory
      Returns:
      Whether format supported by this factory supports native binary content
    • createParser

      public JsonParser createParser(ObjectReadContext readCtxt, File f) throws JacksonException
      Description copied from class: TokenStreamFactory
      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 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:
      createParser in class TokenStreamFactory
      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 JsonParser createParser(ObjectReadContext readCtxt, Path p) throws JacksonException
      Description copied from class: TokenStreamFactory
      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 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:
      createParser in class TokenStreamFactory
      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
    • createParser

      public JsonParser createParser(ObjectReadContext readCtxt, InputStream in) throws JacksonException
      Description copied from class: TokenStreamFactory
      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 TokenStreamFactory.createParser(java.io.Reader).

      Specified by:
      createParser in class TokenStreamFactory
      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 JsonParser createParser(ObjectReadContext readCtxt, Reader r) throws JacksonException
      Description copied from class: TokenStreamFactory
      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.

      Specified by:
      createParser in class TokenStreamFactory
      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, int offset, int len) throws JacksonException
      Description copied from class: TokenStreamFactory
      Method for constructing parser for parsing the contents of given byte array.
      Specified by:
      createParser in class TokenStreamFactory
      Parameters:
      readCtxt - Object read context to use
      data - 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 JsonParser createParser(ObjectReadContext readCtxt, String content) throws JacksonException
      Description copied from class: TokenStreamFactory
      Method for constructing parser for parsing contents of given String.
      Specified by:
      createParser in class TokenStreamFactory
      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, int offset, int len) throws JacksonException
      Description copied from class: TokenStreamFactory
      Method for constructing parser for parsing contents of given char array.
      Specified by:
      createParser in class TokenStreamFactory
      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 JsonParser createParser(ObjectReadContext readCtxt, DataInput in) throws JacksonException
      Description copied from class: TokenStreamFactory
      Optional method for constructing parser for reading contents from specified DataInput instance.

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

      Specified by:
      createParser in class TokenStreamFactory
      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

      protected abstract JsonParser _createParser(ObjectReadContext readCtxt, IOContext ioCtxt, InputStream in) throws JacksonException
      Throws:
      JacksonException
    • _createParser

      protected abstract JsonParser _createParser(ObjectReadContext readCtxt, IOContext ioCtxt, byte[] data, int offset, int len) throws JacksonException
      Throws:
      JacksonException
    • _createParser

      protected abstract JsonParser _createParser(ObjectReadContext readCtxt, IOContext ioCtxt, DataInput input) throws JacksonException
      Throws:
      JacksonException
    • createGenerator

      public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, OutputStream out, JsonEncoding enc) throws JacksonException
      Description copied from class: TokenStreamFactory
      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.

      Specified by:
      createGenerator in class TokenStreamFactory
      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
    • createGenerator

      public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, Writer w) throws JacksonException
      Description copied from class: TokenStreamFactory
      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.

      Specified by:
      createGenerator in class TokenStreamFactory
      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
    • createGenerator

      public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, File f, JsonEncoding enc) throws JacksonException
      Description copied from class: TokenStreamFactory
      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.

      Specified by:
      createGenerator in class TokenStreamFactory
      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
    • createGenerator

      public JsonGenerator createGenerator(ObjectWriteContext writeCtxt, Path p, JsonEncoding enc) throws JacksonException
      Description copied from class: TokenStreamFactory
      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.

      Specified by:
      createGenerator in class TokenStreamFactory
      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
    • _createContentReference

      protected ContentReference _createContentReference(Object contentRef)
      Description copied from class: TokenStreamFactory
      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).
      Specified by:
      _createContentReference in class TokenStreamFactory
      Parameters:
      contentRef - Underlying input source (parser) or target (generator)
      Returns:
      InputSourceReference instance to use
    • _createContentReference

      protected ContentReference _createContentReference(Object contentRef, int offset, int length)
      Description copied from class: TokenStreamFactory
      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.
      Specified by:
      _createContentReference in class TokenStreamFactory
      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, OutputStream out) throws JacksonException
      Overridable factory method that actually instantiates generator for given OutputStream and 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 use
      ioCtxt - IOContext for generator to use
      out - Writer for generator to use
      Returns:
      Generator constructed
      Throws:
      JacksonException - If there is a problem constructing generator
    • _nonByteSource

      protected <T> T _nonByteSource() throws JacksonException
      Throws:
      JacksonException
    • _nonByteTarget

      protected <T> T _nonByteTarget() throws JacksonException
      Throws:
      JacksonException