public class SmileFactory extends JsonFactory
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).
| 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 java.lang.String |
FORMAT_NAME_SMILE
Name used to identify Smile format.
|
_characterEscapes, _generatorFeatures, _inputDecorator, _objectCodec, _outputDecorator, _parserFeatures, _recyclerRef, _rootByteSymbols, _rootCharSymbols, FORMAT_NAME_JSON| Constructor and Description |
|---|
SmileFactory()
Default constructor used to create factory instances.
|
SmileFactory(ObjectCodec oc) |
| Modifier and Type | Method and Description |
|---|---|
protected SmileGenerator |
_createJsonGenerator(java.io.OutputStream out,
IOContext ctxt) |
protected JsonGenerator |
_createJsonGenerator(java.io.Writer out,
IOContext ctxt)
Overridable factory method that actually instantiates desired
generator.
|
protected SmileParser |
_createJsonParser(byte[] data,
int offset,
int len,
IOContext ctxt)
Overridable factory method that actually instantiates desired
parser.
|
protected SmileParser |
_createJsonParser(java.io.InputStream in,
IOContext ctxt)
Overridable factory method that actually instantiates desired
parser.
|
protected JsonParser |
_createJsonParser(java.io.Reader r,
IOContext ctxt)
Overridable factory method that actually instantiates desired
parser.
|
protected java.io.Writer |
_createWriter(java.io.OutputStream out,
JsonEncoding enc,
IOContext ctxt) |
SmileFactory |
configure(SmileGenerator.Feature f,
boolean state)
Method for enabling or disabling specified generator feature
(check
JsonGenerator.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) |
SmileGenerator |
createJsonGenerator(java.io.OutputStream out)
Since Smile format always uses UTF-8 internally, no encoding need
to be passed to this method.
|
SmileGenerator |
createJsonGenerator(java.io.OutputStream out,
JsonEncoding enc)
note: co-variant return type
|
SmileParser |
createJsonParser(byte[] data)
Method for constructing parser for parsing
the contents of given byte array.
|
SmileParser |
createJsonParser(byte[] data,
int offset,
int len)
Method for constructing parser for parsing
the contents of given byte array.
|
SmileParser |
createJsonParser(java.io.File f)
Method for constructing JSON parser instance to parse
contents of specified file.
|
SmileParser |
createJsonParser(java.io.InputStream in)
Method for constructing JSON parser instance to parse
the contents accessed via specified input stream.
|
SmileParser |
createJsonParser(java.net.URL url)
Method for constructing JSON parser instance to parse
contents of resource reference by given URL.
|
void |
delegateToTextual(boolean state) |
SmileFactory |
disable(SmileGenerator.Feature f)
Method for disabling specified generator feature
(check
JsonGenerator.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
JsonGenerator.Feature for list of features) |
SmileFactory |
enable(SmileParser.Feature f)
Method for enabling specified parser feature
(check
SmileParser.Feature for list of features) |
java.lang.String |
getFormatName()
Method that returns short textual id identifying format
this factory supports.
|
MatchStrength |
hasFormat(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.
|
_createContext, _createUTF8JsonGenerator, _getBufferRecycler, _optimizedStreamFromURL, configure, configure, createJsonGenerator, createJsonGenerator, createJsonParser, createJsonParser, disable, disable, disableGeneratorFeature, disableParserFeature, enable, enable, enableGeneratorFeature, enableParserFeature, getCharacterEscapes, getCodec, getInputDecorator, getOutputDecorator, hasJSONFormat, isEnabled, isEnabled, isGeneratorFeatureEnabled, isParserFeatureEnabled, setCharacterEscapes, setCodec, setGeneratorFeature, setInputDecorator, setOutputDecorator, setParserFeature, versionpublic static final java.lang.String FORMAT_NAME_SMILE
getFormatName()protected boolean _cfgDelegateToTextual
Writer, for example)
should be delegated to regular Jackson JSON processing
(if set to true); or throw UnsupportedOperationException
(if set to false)protected int _smileParserFeatures
protected int _smileGeneratorFeatures
public SmileFactory()
public SmileFactory(ObjectCodec oc)
public void delegateToTextual(boolean state)
public java.lang.String getFormatName()
JsonFactoryNote: sub-classes should override this method; default implementation will return null for all sub-classes
getFormatName in class JsonFactorypublic MatchStrength hasFormat(InputAccessor acc) throws java.io.IOException
hasFormat in class JsonFactoryjava.io.IOExceptionpublic final SmileFactory configure(SmileParser.Feature f, boolean state)
SmileParser.Feature for list of features)public SmileFactory enable(SmileParser.Feature f)
SmileParser.Feature for list of features)public SmileFactory disable(SmileParser.Feature f)
SmileParser.Feature for list of features)public final boolean isEnabled(SmileParser.Feature f)
public final SmileFactory configure(SmileGenerator.Feature f, boolean state)
JsonGenerator.Feature for list of features)public SmileFactory enable(SmileGenerator.Feature f)
JsonGenerator.Feature for list of features)public SmileFactory disable(SmileGenerator.Feature f)
JsonGenerator.Feature for list of features)public final boolean isEnabled(SmileGenerator.Feature f)
public SmileParser createJsonParser(java.io.File f) throws java.io.IOException, JsonParseException
JsonFactoryUnderlying 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.
createJsonParser in class JsonFactoryf - File that contains JSON content to parsejava.io.IOExceptionJsonParseExceptionpublic SmileParser createJsonParser(java.net.URL url) throws java.io.IOException, JsonParseException
JsonFactoryUnderlying 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.
createJsonParser in class JsonFactoryurl - URL pointing to resource that contains JSON content to parsejava.io.IOExceptionJsonParseExceptionpublic SmileParser createJsonParser(java.io.InputStream in) throws java.io.IOException, JsonParseException
JsonFactory
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) JsonParser.Feature.AUTO_CLOSE_SOURCE
is enabled.
Note: no encoding argument is taken since it can always be auto-detected as suggested by Json RFC.
createJsonParser in class JsonFactoryin - InputStream to use for reading JSON content to parsejava.io.IOExceptionJsonParseExceptionpublic SmileParser createJsonParser(byte[] data) throws java.io.IOException, JsonParseException
JsonFactorycreateJsonParser in class JsonFactoryjava.io.IOExceptionJsonParseExceptionpublic SmileParser createJsonParser(byte[] data, int offset, int len) throws java.io.IOException, JsonParseException
JsonFactorycreateJsonParser in class JsonFactorydata - Buffer that contains data to parseoffset - Offset of the first data byte within bufferlen - Length of contents to parse within bufferjava.io.IOExceptionJsonParseExceptionpublic SmileGenerator createJsonGenerator(java.io.OutputStream out, JsonEncoding enc) throws java.io.IOException
note: co-variant return type
createJsonGenerator in class JsonFactoryout - OutputStream to use for writing JSON contentenc - Character encoding to usejava.io.IOExceptionpublic SmileGenerator createJsonGenerator(java.io.OutputStream out) throws java.io.IOException
createJsonGenerator in class JsonFactoryjava.io.IOExceptionprotected SmileParser _createJsonParser(java.io.InputStream in, IOContext ctxt) throws java.io.IOException, JsonParseException
_createJsonParser in class JsonFactoryjava.io.IOExceptionJsonParseExceptionprotected JsonParser _createJsonParser(java.io.Reader r, IOContext ctxt) throws java.io.IOException, JsonParseException
_createJsonParser in class JsonFactoryjava.io.IOExceptionJsonParseExceptionprotected SmileParser _createJsonParser(byte[] data, int offset, int len, IOContext ctxt) throws java.io.IOException, JsonParseException
_createJsonParser in class JsonFactoryjava.io.IOExceptionJsonParseExceptionprotected JsonGenerator _createJsonGenerator(java.io.Writer out, IOContext ctxt) throws java.io.IOException
_createJsonGenerator in class JsonFactoryjava.io.IOExceptionprotected java.io.Writer _createWriter(java.io.OutputStream out,
JsonEncoding enc,
IOContext ctxt)
throws java.io.IOException
_createWriter in class JsonFactoryjava.io.IOExceptionprotected SmileGenerator _createJsonGenerator(java.io.OutputStream out, IOContext ctxt) throws java.io.IOException
java.io.IOException