Class CBORFactory

java.lang.Object
com.fasterxml.jackson.core.TokenStreamFactory
com.fasterxml.jackson.core.JsonFactory
com.fasterxml.jackson.dataformat.cbor.CBORFactory
All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned, Serializable

public class CBORFactory extends com.fasterxml.jackson.core.JsonFactory
Factory used for constructing CBORParser and CBORGenerator instances; both of which handle CBOR encoded data.

Extends JsonFactory mostly so that users can actually use it in place of regular non-CBOR factory instances.

Note on using non-byte-based sources/targets (char based, like Reader and Writer): these can not be used for CBOR documents; attempt will throw exception.

See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • FORMAT_NAME

      public static final String FORMAT_NAME
      Name used to identify CBOR format. (and returned by getFormatName()
      See Also:
    • DEFAULT_CBOR_PARSER_FEATURE_FLAGS

      static final int DEFAULT_CBOR_PARSER_FEATURE_FLAGS
      Bitfield (set of flags) of all parser features that are enabled by default.
    • DEFAULT_CBOR_GENERATOR_FEATURE_FLAGS

      static final int DEFAULT_CBOR_GENERATOR_FEATURE_FLAGS
      Bitfield (set of flags) of all generator features that are enabled by default.
    • _formatParserFeatures

      protected int _formatParserFeatures
    • _formatGeneratorFeatures

      protected int _formatGeneratorFeatures
  • Constructor Details

    • CBORFactory

      public CBORFactory()
      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.
    • CBORFactory

      public CBORFactory(com.fasterxml.jackson.core.ObjectCodec oc)
    • CBORFactory

      public CBORFactory(CBORFactory src, com.fasterxml.jackson.core.ObjectCodec oc)
      Note: REQUIRES at least 2.2.1 -- unfortunate intra-patch dep but seems preferable to just leaving bug be as is
      Since:
      2.2.1
    • CBORFactory

      protected CBORFactory(CBORFactoryBuilder b)
      Constructors used by CBORFactoryBuilder for instantiation.
      Since:
      3.0
  • Method Details

    • rebuild

      public CBORFactoryBuilder rebuild()
      Overrides:
      rebuild in class com.fasterxml.jackson.core.JsonFactory
    • builder

      public static CBORFactoryBuilder builder()
      Main factory method to use for constructing CBORFactory instances with different configuration.
    • copy

      public CBORFactory copy()
      Overrides:
      copy in class com.fasterxml.jackson.core.JsonFactory
    • readResolve

      protected Object readResolve()
      Method that we need to override to actually make restoration go through constructors etc. Also: must be overridden by sub-classes as well.
      Overrides:
      readResolve in class com.fasterxml.jackson.core.JsonFactory
    • version

      public com.fasterxml.jackson.core.Version version()
      Specified by:
      version in interface com.fasterxml.jackson.core.Versioned
      Overrides:
      version in class com.fasterxml.jackson.core.JsonFactory
    • getFormatName

      public String getFormatName()
      Overrides:
      getFormatName in class com.fasterxml.jackson.core.JsonFactory
    • canUseCharArrays

      public boolean canUseCharArrays()
      Overrides:
      canUseCharArrays in class com.fasterxml.jackson.core.JsonFactory
    • hasFormat

      public com.fasterxml.jackson.core.format.MatchStrength hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc) throws IOException
      Overrides:
      hasFormat in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • canHandleBinaryNatively

      public boolean canHandleBinaryNatively()
      Overrides:
      canHandleBinaryNatively in class com.fasterxml.jackson.core.JsonFactory
    • getFormatReadFeatureType

      public Class<CBORParser.Feature> getFormatReadFeatureType()
      Overrides:
      getFormatReadFeatureType in class com.fasterxml.jackson.core.JsonFactory
    • getFormatWriteFeatureType

      public Class<CBORGenerator.Feature> getFormatWriteFeatureType()
      Overrides:
      getFormatWriteFeatureType in class com.fasterxml.jackson.core.JsonFactory
    • configure

      public final CBORFactory configure(CBORParser.Feature f, boolean state)
      Method for enabling or disabling specified parser feature (check CBORParser.Feature for list of features)
    • enable

      public CBORFactory enable(CBORParser.Feature f)
      Method for enabling specified parser feature (check CBORParser.Feature for list of features)
    • disable

      public CBORFactory disable(CBORParser.Feature f)
      Method for disabling specified parser features (check CBORParser.Feature for list of features)
    • isEnabled

      public final boolean isEnabled(CBORParser.Feature f)
      Checked whether specified parser feature is enabled.
    • getFormatParserFeatures

      public int getFormatParserFeatures()
      Overrides:
      getFormatParserFeatures in class com.fasterxml.jackson.core.JsonFactory
    • configure

      public final CBORFactory configure(CBORGenerator.Feature f, boolean state)
      Method for enabling or disabling specified generator feature (check CBORGenerator.Feature for list of features)
    • enable

      Method for enabling specified generator features (check CBORGenerator.Feature for list of features)
    • disable

      public CBORFactory disable(CBORGenerator.Feature f)
      Method for disabling specified generator feature (check CBORGenerator.Feature for list of features)
    • isEnabled

      public final boolean isEnabled(CBORGenerator.Feature f)
      Check whether specified generator feature is enabled.
    • getFormatGeneratorFeatures

      public int getFormatGeneratorFeatures()
      Overrides:
      getFormatGeneratorFeatures in class com.fasterxml.jackson.core.JsonFactory
    • createParser

      public CBORParser createParser(File f) throws IOException
      Overrides:
      createParser in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • createParser

      public CBORParser createParser(URL url) throws IOException
      Overrides:
      createParser in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • createParser

      public CBORParser createParser(InputStream in) throws IOException
      Overrides:
      createParser in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • createParser

      public CBORParser createParser(byte[] data) throws IOException
      Overrides:
      createParser in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • createParser

      public CBORParser createParser(byte[] data, int offset, int len) throws IOException
      Overrides:
      createParser in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • createGenerator

      public CBORGenerator createGenerator(OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc) throws IOException
      Method for constructing JsonGenerator for generating CBOR-encoded output.

      Since CBOR format always uses UTF-8 internally, enc argument is ignored.

      Overrides:
      createGenerator in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • createGenerator

      public CBORGenerator createGenerator(OutputStream out) throws IOException
      Method for constructing JsonGenerator for generating CBOR-encoded output.

      Since CBOR format always uses UTF-8 internally, no encoding need to be passed to this method.

      Overrides:
      createGenerator in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • _createContext

      protected com.fasterxml.jackson.core.io.IOContext _createContext(com.fasterxml.jackson.core.io.ContentReference contentRef, boolean resourceManaged)
      Overrides:
      _createContext in class com.fasterxml.jackson.core.JsonFactory
    • _createParser

      protected CBORParser _createParser(InputStream in, com.fasterxml.jackson.core.io.IOContext ctxt) throws IOException
      Overridable factory method that actually instantiates desired parser.
      Overrides:
      _createParser in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • _createParser

      protected com.fasterxml.jackson.core.JsonParser _createParser(Reader r, com.fasterxml.jackson.core.io.IOContext ctxt) throws IOException
      Overridable factory method that actually instantiates desired parser.
      Overrides:
      _createParser in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • _createParser

      protected com.fasterxml.jackson.core.JsonParser _createParser(char[] data, int offset, int len, com.fasterxml.jackson.core.io.IOContext ctxt, boolean recyclable) throws IOException
      Overrides:
      _createParser in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • _createParser

      protected CBORParser _createParser(byte[] data, int offset, int len, com.fasterxml.jackson.core.io.IOContext ctxt) throws IOException
      Overridable factory method that actually instantiates desired parser.
      Overrides:
      _createParser in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • _createGenerator

      protected CBORGenerator _createGenerator(Writer out, com.fasterxml.jackson.core.io.IOContext ctxt) throws IOException
      Overrides:
      _createGenerator in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • _createUTF8Generator

      protected CBORGenerator _createUTF8Generator(OutputStream out, com.fasterxml.jackson.core.io.IOContext ctxt) throws IOException
      Overrides:
      _createUTF8Generator in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • _createWriter

      protected Writer _createWriter(OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc, com.fasterxml.jackson.core.io.IOContext ctxt) throws IOException
      Overrides:
      _createWriter in class com.fasterxml.jackson.core.JsonFactory
      Throws:
      IOException
    • _createCBORGenerator

      private final CBORGenerator _createCBORGenerator(com.fasterxml.jackson.core.io.IOContext ctxt, int stdFeat, int formatFeat, com.fasterxml.jackson.core.ObjectCodec codec, OutputStream out) throws IOException
      Throws:
      IOException
    • _nonByteSource

      protected <T> T _nonByteSource()
    • _nonByteTarget

      protected <T> T _nonByteTarget()