Class CBORFactory

  • All Implemented Interfaces:
    com.fasterxml.jackson.core.Versioned, java.io.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:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.fasterxml.jackson.core.JsonFactory

        com.fasterxml.jackson.core.JsonFactory.Feature
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int _formatGeneratorFeatures  
      protected int _formatParserFeatures  
      (package private) static int DEFAULT_CBOR_GENERATOR_FEATURE_FLAGS
      Bitfield (set of flags) of all generator features that are enabled by default.
      (package private) static int DEFAULT_CBOR_PARSER_FEATURE_FLAGS
      Bitfield (set of flags) of all parser features that are enabled by default.
      static java.lang.String FORMAT_NAME
      Name used to identify CBOR format.
      private static long serialVersionUID  
      • Fields inherited from class com.fasterxml.jackson.core.JsonFactory

        _byteSymbolCanonicalizer, _characterEscapes, _factoryFeatures, _generatorFeatures, _inputDecorator, _maximumNonEscapedChar, _objectCodec, _outputDecorator, _parserFeatures, _quoteChar, _rootCharSymbols, _rootValueSeparator, DEFAULT_FACTORY_FEATURE_FLAGS, DEFAULT_GENERATOR_FEATURE_FLAGS, DEFAULT_PARSER_FEATURE_FLAGS, DEFAULT_QUOTE_CHAR, DEFAULT_ROOT_VALUE_SEPARATOR, FORMAT_NAME_JSON
    • Constructor Summary

      Constructors 
      Constructor Description
      CBORFactory()
      Default constructor used to create factory instances.
      CBORFactory​(com.fasterxml.jackson.core.ObjectCodec oc)  
      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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private CBORGenerator _createCBORGenerator​(com.fasterxml.jackson.core.io.IOContext ctxt, int stdFeat, int formatFeat, com.fasterxml.jackson.core.ObjectCodec codec, java.io.OutputStream out)  
      protected com.fasterxml.jackson.core.io.IOContext _createContext​(java.lang.Object srcRef, boolean resourceManaged)  
      protected CBORGenerator _createGenerator​(java.io.Writer out, com.fasterxml.jackson.core.io.IOContext ctxt)  
      protected CBORParser _createParser​(byte[] data, int offset, int len, com.fasterxml.jackson.core.io.IOContext ctxt)
      Overridable factory method that actually instantiates desired parser.
      protected com.fasterxml.jackson.core.JsonParser _createParser​(char[] data, int offset, int len, com.fasterxml.jackson.core.io.IOContext ctxt, boolean recyclable)  
      protected CBORParser _createParser​(java.io.InputStream in, com.fasterxml.jackson.core.io.IOContext ctxt)
      Overridable factory method that actually instantiates desired parser.
      protected com.fasterxml.jackson.core.JsonParser _createParser​(java.io.Reader r, com.fasterxml.jackson.core.io.IOContext ctxt)
      Overridable factory method that actually instantiates desired parser.
      protected CBORGenerator _createUTF8Generator​(java.io.OutputStream out, com.fasterxml.jackson.core.io.IOContext ctxt)  
      protected java.io.Writer _createWriter​(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc, com.fasterxml.jackson.core.io.IOContext ctxt)  
      protected <T> T _nonByteSource()  
      protected <T> T _nonByteTarget()  
      boolean canHandleBinaryNatively()  
      boolean canUseCharArrays()  
      CBORFactory configure​(CBORGenerator.Feature f, boolean state)
      Method for enabling or disabling specified generator feature (check CBORGenerator.Feature for list of features)
      CBORFactory configure​(CBORParser.Feature f, boolean state)
      Method for enabling or disabling specified parser feature (check CBORParser.Feature for list of features)
      CBORFactory copy()  
      CBORGenerator createGenerator​(java.io.OutputStream out)
      Method for constructing JsonGenerator for generating CBOR-encoded output.
      CBORGenerator createGenerator​(java.io.OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc)
      Method for constructing JsonGenerator for generating CBOR-encoded output.
      CBORParser createParser​(byte[] data)  
      CBORParser createParser​(byte[] data, int offset, int len)  
      CBORParser createParser​(java.io.File f)  
      CBORParser createParser​(java.io.InputStream in)  
      CBORParser createParser​(java.net.URL url)  
      CBORFactory disable​(CBORGenerator.Feature f)
      Method for disabling specified generator feature (check CBORGenerator.Feature for list of features)
      CBORFactory disable​(CBORParser.Feature f)
      Method for disabling specified parser features (check CBORParser.Feature for list of features)
      CBORFactory enable​(CBORGenerator.Feature f)
      Method for enabling specified generator features (check CBORGenerator.Feature for list of features)
      CBORFactory enable​(CBORParser.Feature f)
      Method for enabling specified parser feature (check CBORParser.Feature for list of features)
      java.lang.String getFormatName()  
      java.lang.Class<CBORParser.Feature> getFormatReadFeatureType()  
      java.lang.Class<CBORGenerator.Feature> getFormatWriteFeatureType()  
      com.fasterxml.jackson.core.format.MatchStrength hasFormat​(com.fasterxml.jackson.core.format.InputAccessor acc)  
      boolean isEnabled​(CBORGenerator.Feature f)
      Check whether specified generator feature is enabled.
      boolean isEnabled​(CBORParser.Feature f)
      Checked whether specified parser feature is enabled.
      protected java.lang.Object readResolve()
      Method that we need to override to actually make restoration go through constructors etc.
      com.fasterxml.jackson.core.Version version()  
      • Methods inherited from class com.fasterxml.jackson.core.JsonFactory

        _checkInvalidCopy, _createNonBlockingContext, _createParser, _decorate, _decorate, _decorate, _decorate, _decorate, _getBufferRecycler, builder, canParseAsync, canUseSchema, configure, configure, configure, createGenerator, createGenerator, createGenerator, createGenerator, createJsonGenerator, createJsonGenerator, createJsonGenerator, createJsonParser, createJsonParser, createJsonParser, createJsonParser, createJsonParser, createJsonParser, createJsonParser, createNonBlockingByteArrayParser, createParser, createParser, createParser, createParser, createParser, disable, disable, disable, enable, enable, enable, getCharacterEscapes, getCodec, getFormatGeneratorFeatures, getFormatParserFeatures, getGeneratorFeatures, getInputDecorator, getOutputDecorator, getParserFeatures, getRootValueSeparator, hasJSONFormat, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, rebuild, requiresCustomCodec, requiresPropertyOrdering, setCharacterEscapes, setCodec, setInputDecorator, setOutputDecorator, setRootValueSeparator
      • Methods inherited from class com.fasterxml.jackson.core.TokenStreamFactory

        _createDataOutputWrapper, _optimizedStreamFromURL
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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 Detail

      • 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
    • Method Detail

      • copy

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

        protected java.lang.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 java.lang.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 java.io.IOException
        Overrides:
        hasFormat in class com.fasterxml.jackson.core.JsonFactory
        Throws:
        java.io.IOException
      • canHandleBinaryNatively

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

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

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

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

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

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

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

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

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

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

        public CBORGenerator createGenerator​(java.io.OutputStream out,
                                             com.fasterxml.jackson.core.JsonEncoding enc)
                                      throws java.io.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:
        java.io.IOException
      • createGenerator

        public CBORGenerator createGenerator​(java.io.OutputStream out)
                                      throws java.io.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:
        java.io.IOException
      • _createContext

        protected com.fasterxml.jackson.core.io.IOContext _createContext​(java.lang.Object srcRef,
                                                                         boolean resourceManaged)
        Overrides:
        _createContext in class com.fasterxml.jackson.core.JsonFactory
      • _createParser

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

        protected com.fasterxml.jackson.core.JsonParser _createParser​(java.io.Reader r,
                                                                      com.fasterxml.jackson.core.io.IOContext ctxt)
                                                               throws java.io.IOException
        Overridable factory method that actually instantiates desired parser.
        Overrides:
        _createParser in class com.fasterxml.jackson.core.JsonFactory
        Throws:
        java.io.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 java.io.IOException
        Overrides:
        _createParser in class com.fasterxml.jackson.core.JsonFactory
        Throws:
        java.io.IOException
      • _createParser

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

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

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

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

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

        protected <T> T _nonByteSource()
      • _nonByteTarget

        protected <T> T _nonByteTarget()