com.fasterxml.jackson.dataformat.smile

## Class SmileFactory

- java.lang.Object
- - com.fasterxml.jackson.core.JsonFactory
  - - com.fasterxml.jackson.dataformat.smile.SmileFactory

- All Implemented Interfaces:
    com.fasterxml.jackson.core.Versioned, Serializable

      public class SmileFactory
      extends com.fasterxml.jackson.core.JsonFactory

  Factory used for constructing `SmileParser` and `SmileGenerator` instances; both of which handle Smile encoded data.

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

  Note on using non-byte-based sources/targets (char based, like `Reader` and `Writer`): these can not be used for Smile-format documents, and thus will either downgrade to textual JSON (when parsing), or throw exception (when trying to create generator).

  Author:
    Tatu Saloranta
  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 and Description
    --- | ---
    `protected boolean` | `_cfgDelegateToTextual` Whether non-supported methods (ones trying to output using char-based targets like `Writer`, for example) should be delegated to regular Jackson JSON processing (if set to true); or throw `UnsupportedOperationException` (if set to false)
    `protected int` | `_smileGeneratorFeatures`
    `protected int` | `_smileParserFeatures`
    `static String` | `FORMAT_NAME_SMILE` Name used to identify Smile format.

    - ### Fields inherited from class com.fasterxml.jackson.core.JsonFactory

      `_byteSymbolCanonicalizer, _characterEscapes, _factoryFeatures, _generatorFeatures, _inputDecorator, _objectCodec, _outputDecorator, _parserFeatures, _recyclerRef, _rootCharSymbols, _rootValueSeparator, DEFAULT_FACTORY_FEATURE_FLAGS, DEFAULT_GENERATOR_FEATURE_FLAGS, DEFAULT_PARSER_FEATURE_FLAGS, FORMAT_NAME_JSON`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SmileFactory()` Default constructor used to create factory instances.
    `SmileFactory(com.fasterxml.jackson.core.ObjectCodec oc)`
    `SmileFactory(SmileFactory src, com.fasterxml.jackson.core.ObjectCodec oc)` Note: REQUIRES 2.2.1 -- unfortunate intra-patch dep but seems preferable to just leaving bug be as is

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected SmileGenerator` | `_createGenerator(OutputStream out, com.fasterxml.jackson.core.io.IOContext ctxt)`
    `protected com.fasterxml.jackson.core.JsonGenerator` | `_createGenerator(Writer out, com.fasterxml.jackson.core.io.IOContext ctxt)`
    `protected SmileParser` | `_createParser(byte[] data, int offset, int len, com.fasterxml.jackson.core.io.IOContext ctxt)`
    `protected com.fasterxml.jackson.core.JsonParser` | `_createParser(char[] data, int offset, int len, com.fasterxml.jackson.core.io.IOContext ctxt, boolean recyclable)`
    `protected SmileParser` | `_createParser(InputStream in, com.fasterxml.jackson.core.io.IOContext ctxt)` Overridable factory method that actually instantiates desired parser.
    `protected com.fasterxml.jackson.core.JsonParser` | `_createParser(Reader r, com.fasterxml.jackson.core.io.IOContext ctxt)`
    `protected com.fasterxml.jackson.core.JsonGenerator` | `_createUTF8Generator(OutputStream out, com.fasterxml.jackson.core.io.IOContext ctxt)`
    `protected Writer` | `_createWriter(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()`
    `SmileFactory` | `configure(SmileGenerator.Feature f, boolean state)` Method for enabling or disabling specified generator feature (check `SmileGenerator.Feature` for list of features)
    `SmileFactory` | `configure(SmileParser.Feature f, boolean state)` Method for enabling or disabling specified parser feature (check `SmileParser.Feature` for list of features)
    `SmileFactory` | `copy()`
    `SmileGenerator` | `createGenerator(OutputStream out)` Method for constructing `JsonGenerator` for generating Smile-encoded output.
    `SmileGenerator` | `createGenerator(OutputStream out, com.fasterxml.jackson.core.JsonEncoding enc)` Method for constructing `JsonGenerator` for generating Smile-encoded output.
    `SmileParser` | `createParser(byte[] data)`
    `SmileParser` | `createParser(byte[] data, int offset, int len)`
    `SmileParser` | `createParser(File f)`
    `SmileParser` | `createParser(InputStream in)`
    `SmileParser` | `createParser(URL url)`
    `void` | `delegateToTextual(boolean state)`
    `SmileFactory` | `disable(SmileGenerator.Feature f)` Method for disabling specified generator feature (check `SmileGenerator.Feature` for list of features)
    `SmileFactory` | `disable(SmileParser.Feature f)` Method for disabling specified parser features (check `SmileParser.Feature` for list of features)
    `SmileFactory` | `enable(SmileGenerator.Feature f)` Method for enabling specified generator features (check `SmileGenerator.Feature` for list of features)
    `SmileFactory` | `enable(SmileParser.Feature f)` Method for enabling specified parser feature (check `SmileParser.Feature` for list of features)
    `String` | `getFormatName()`
    `Class<SmileParser.Feature>` | `getFormatReadFeatureType()`
    `Class<SmileGenerator.Feature>` | `getFormatWriteFeatureType()`
    `com.fasterxml.jackson.core.format.MatchStrength` | `hasFormat(com.fasterxml.jackson.core.format.InputAccessor acc)` Sub-classes need to override this method (as of 1.8)
    `boolean` | `isEnabled(SmileGenerator.Feature f)` Check whether specified generator feature is enabled.
    `boolean` | `isEnabled(SmileParser.Feature f)` Checked whether specified parser feature is enabled.
    `protected 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, _createContext, _createDataOutputWrapper, _createParser, _decorate, _decorate, _decorate, _decorate, _decorate, _getBufferRecycler, _optimizedStreamFromURL, canUseSchema, configure, configure, configure, createGenerator, createGenerator, createGenerator, createGenerator, createJsonGenerator, createJsonGenerator, createJsonGenerator, createJsonParser, createJsonParser, createJsonParser, createJsonParser, createJsonParser, createJsonParser, createJsonParser, createParser, createParser, createParser, createParser, createParser, disable, disable, disable, enable, enable, enable, getCharacterEscapes, getCodec, getInputDecorator, getOutputDecorator, getRootValueSeparator, hasJSONFormat, isEnabled, isEnabled, isEnabled, requiresCustomCodec, requiresPropertyOrdering, setCharacterEscapes, setCodec, setInputDecorator, setOutputDecorator, setRootValueSeparator`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### FORMAT_NAME_SMILE

          public static final String FORMAT_NAME_SMILE

      Name used to identify Smile format. (and returned by `getFormatName()`
      See Also:
        Constant Field Values

    - #### _cfgDelegateToTextual

          protected boolean _cfgDelegateToTextual

      Whether non-supported methods (ones trying to output using char-based targets like `Writer`, for example) should be delegated to regular Jackson JSON processing (if set to true); or throw `UnsupportedOperationException` (if set to false)

    - #### _smileParserFeatures

          protected int _smileParserFeatures

    - #### _smileGeneratorFeatures

          protected int _smileGeneratorFeatures

  - ### Constructor Detail

    - #### SmileFactory

          public SmileFactory()

      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.

    - #### SmileFactory

          public SmileFactory(com.fasterxml.jackson.core.ObjectCodec oc)

    - #### SmileFactory

          public SmileFactory(SmileFactory src,
                      com.fasterxml.jackson.core.ObjectCodec oc)

      Note: REQUIRES 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 SmileFactory copy()

      Overrides:
        `copy` in class `com.fasterxml.jackson.core.JsonFactory`

    - #### delegateToTextual

          public void delegateToTextual(boolean state)

    - #### 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

      Sub-classes need to override this method (as of 1.8)
      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<SmileParser.Feature> getFormatReadFeatureType()

      Overrides:
        `getFormatReadFeatureType` in class `com.fasterxml.jackson.core.JsonFactory`

    - #### getFormatWriteFeatureType

          public Class<SmileGenerator.Feature> getFormatWriteFeatureType()

      Overrides:
        `getFormatWriteFeatureType` in class `com.fasterxml.jackson.core.JsonFactory`

    - #### configure

          public final SmileFactory configure(SmileParser.Feature f,
                               boolean state)

      Method for enabling or disabling specified parser feature (check `SmileParser.Feature` for list of features)

    - #### enable

          public SmileFactory enable(SmileParser.Feature f)

      Method for enabling specified parser feature (check `SmileParser.Feature` for list of features)

    - #### disable

          public SmileFactory disable(SmileParser.Feature f)

      Method for disabling specified parser features (check `SmileParser.Feature` for list of features)

    - #### isEnabled

          public final boolean isEnabled(SmileParser.Feature f)

      Checked whether specified parser feature is enabled.

    - #### configure

          public final SmileFactory configure(SmileGenerator.Feature f,
                               boolean state)

      Method for enabling or disabling specified generator feature (check `SmileGenerator.Feature` for list of features)
      Since:
        1.2

    - #### enable

          public SmileFactory enable(SmileGenerator.Feature f)

      Method for enabling specified generator features (check `SmileGenerator.Feature` for list of features)

    - #### disable

          public SmileFactory disable(SmileGenerator.Feature f)

      Method for disabling specified generator feature (check `SmileGenerator.Feature` for list of features)

    - #### isEnabled

          public final boolean isEnabled(SmileGenerator.Feature f)

      Check whether specified generator feature is enabled.

    - #### createParser

          public SmileParser createParser(File f)
                                   throws IOException

      Overrides:
        `createParser` in class `com.fasterxml.jackson.core.JsonFactory`
      Throws:
        `IOException`

    - #### createParser

          public SmileParser createParser(URL url)
                                   throws IOException

      Overrides:
        `createParser` in class `com.fasterxml.jackson.core.JsonFactory`
      Throws:
        `IOException`

    - #### createParser

          public SmileParser createParser(InputStream in)
                                   throws IOException

      Overrides:
        `createParser` in class `com.fasterxml.jackson.core.JsonFactory`
      Throws:
        `IOException`

    - #### createParser

          public SmileParser createParser(byte[] data)
                                   throws IOException

      Overrides:
        `createParser` in class `com.fasterxml.jackson.core.JsonFactory`
      Throws:
        `IOException`

    - #### createParser

          public SmileParser createParser(byte[] data,
                                 int offset,
                                 int len)
                                   throws IOException

      Overrides:
        `createParser` in class `com.fasterxml.jackson.core.JsonFactory`
      Throws:
        `IOException`

    - #### createGenerator

          public SmileGenerator createGenerator(OutputStream out,
                                       com.fasterxml.jackson.core.JsonEncoding enc)
                                         throws IOException

      Method for constructing `JsonGenerator` for generating Smile-encoded output.

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

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

    - #### createGenerator

          public SmileGenerator createGenerator(OutputStream out)
                                         throws IOException

      Method for constructing `JsonGenerator` for generating Smile-encoded output.

      Since Smile 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`

    - #### _createParser

          protected SmileParser _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

      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 SmileParser _createParser(byte[] data,
                                  int offset,
                                  int len,
                                  com.fasterxml.jackson.core.io.IOContext ctxt)
                                       throws IOException

      Overrides:
        `_createParser` in class `com.fasterxml.jackson.core.JsonFactory`
      Throws:
        `IOException`

    - #### _createGenerator

          protected com.fasterxml.jackson.core.JsonGenerator _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 com.fasterxml.jackson.core.JsonGenerator _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`

    - #### _nonByteSource

          protected <T> T _nonByteSource()
                              throws IOException

      Throws:
        `IOException`

    - #### _nonByteTarget

          protected <T> T _nonByteTarget()
                              throws IOException

      Throws:
        `IOException`

    - #### _createGenerator

          protected SmileGenerator _createGenerator(OutputStream out,
                                        com.fasterxml.jackson.core.io.IOContext ctxt)
                                             throws IOException

      Throws:
        `IOException`

Copyright © 2016 FasterXML. All rights reserved.