java.lang.Object
tools.jackson.core.TokenStreamFactory
tools.jackson.core.base.DecorableTSFactory
tools.jackson.core.base.TextualTSFactory
tools.jackson.dataformat.xml.XmlFactory
- All Implemented Interfaces:
Serializable,tools.jackson.core.util.Snapshottable<tools.jackson.core.TokenStreamFactory>,tools.jackson.core.Versioned
Factory used for constructing
FromXmlParser and ToXmlGenerator
instances.
Implements TokenStreamFactory since interface for constructing XML backed
parsers and generators is quite similar to dealing with JSON.
- Author:
- Tatu Saloranta (tatu.saloranta@iki.fi)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.core.base.DecorableTSFactory
tools.jackson.core.base.DecorableTSFactory.DecorableTSFBuilder<F extends tools.jackson.core.TokenStreamFactory,T extends tools.jackson.core.TSFBuilder<F, T>> Nested classes/interfaces inherited from class tools.jackson.core.TokenStreamFactory
tools.jackson.core.TokenStreamFactory.Feature -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected Stringprotected Stringprotected final XmlNameProcessorprotected final XMLInputFactoryprotected final XMLOutputFactoryprotected static final intBitfield (set of flags) of all parser features that are enabled by default.protected static final intBitfield (set of flags) of all generator features that are enabled by default.static final StringName used to identify XML format (and returned bygetFormatName()Fields inherited from class tools.jackson.core.base.DecorableTSFactory
_generatorDecorators, _inputDecorator, _outputDecoratorFields inherited from class tools.jackson.core.TokenStreamFactory
_errorReportConfiguration, _factoryFeatures, _formatReadFeatures, _formatWriteFeatures, _recyclerPool, _streamReadConstraints, _streamReadFeatures, _streamWriteConstraints, _streamWriteFeatures, DEFAULT_FACTORY_FEATURE_FLAGS, DEFAULT_STREAM_READ_FEATURE_FLAGS, DEFAULT_STREAM_WRITE_FEATURE_FLAGS, EMPTY_WRITE_CONTEXT -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault constructor used to create factory instances.protectedXmlFactory(int xpFeatures, int xgFeatures, XMLInputFactory xmlIn, XMLOutputFactory xmlOut, XmlNameProcessor nameProcessor, String nameForTextElem) XmlFactory(XMLInputFactory xmlIn) XmlFactory(XMLInputFactory xmlIn, XMLOutputFactory xmlOut) protectedXmlFactory(XmlFactory src) Constructor used bycopy()protectedConstructor used byXmlFactoryBuilderfor instantiation.protectedXmlFactory(XmlFactory src, String nameForTextElement) -
Method Summary
Modifier and TypeMethodDescriptionprotected tools.jackson.core.JsonGenerator_createGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, Writer out) protected FromXmlParser_createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, byte[] data, int offset, int len) protected FromXmlParser_createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, char[] data, int offset, int len, boolean recycleBuffer) protected tools.jackson.core.JsonParser_createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ctxt, DataInput input) protected FromXmlParser_createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, InputStream in) protected FromXmlParser_createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, Reader r) protected tools.jackson.core.JsonGenerator_createUTF8Generator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, OutputStream out) protected XMLStreamWriterprotected XMLStreamWriterprotected FromXmlParser_fromXmlParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, XMLStreamReader sr) Overridable method to allow using custom FromXmlParser sub-classes.protected void_initFactories(XMLInputFactory xmlIn, XMLOutputFactory xmlOut) protected final XMLStreamReaderprotected final XMLStreamWriterprotected ToXmlGenerator_toXmlGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, XMLStreamWriter sw) Overridable method to allow using custom FromXmlParser sub-classes.static XmlFactoryBuilderbuilder()Main factory method to use for constructingXmlFactoryinstances with different configuration.static XmlFactoryBuilderThe builder returned uses default settings more closely matching the default configs used in Jackson 2.x versions.booleanbooleanSince 2.4, we do have actual capability for passing char arrays efficiently, but unfortunately have no working mechanism for recycling buffers.booleancanUseSchema(tools.jackson.core.FormatSchema schema) copy()Note: compared to base implementation byTokenStreamFactory, here the copy will actually share underlying XML input and output factories, as there is no way to make copies of those.createGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, XMLStreamWriter sw) Factory method that wraps givenXMLStreamWriter, usually to allow incremental serialization to compose large output by serializing a sequence of individual objects.tools.jackson.core.JsonParsercreateParser(tools.jackson.core.ObjectReadContext readCtxt, String content) Overridden just to prevent trying to optimize access via char array; while nice idea, problem is that we don't have proper hooks to ensure that temporary buffer gets recycled; so let's just use StringReader.createParser(tools.jackson.core.ObjectReadContext readCtxt, XMLStreamReader sr) Factory method that wraps givenXMLStreamReader, usually to allow partial data-binding.Method that returns short textual id identifying format this factory supports.intintprotected ObjectMethod that we need to override to actually make restoration go through constructors etc.rebuild()tools.jackson.core.TokenStreamFactorysnapshot()Instances are immutable so just return `this`tools.jackson.core.Versionversion()withNameForTextElement(String name) "Mutant factory" method used to allowXmlMapper.Builderto configure name used for text elements, instead of requiring defining it viaXmlFactoryBuilder.Methods inherited from class tools.jackson.core.base.TextualTSFactory
_createContentReference, _createContentReference, _createWriter, canHandleBinaryNatively, createGenerator, createGenerator, createGenerator, createGenerator, createParser, createParser, createParser, createParser, createParser, createParser, createParserMethods inherited from class tools.jackson.core.base.DecorableTSFactory
_copy, _decorate, _decorate, _decorate, _decorate, _decorate, _decorate, getGeneratorDecorators, getInputDecorator, getOutputDecoratorMethods inherited from class tools.jackson.core.TokenStreamFactory
_checkRangeBoundsForByteArray, _checkRangeBoundsForCharArray, _createContext, _createContext, _createDataOutputWrapper, _fileInputStream, _fileOutputStream, _getBufferRecycler, _getRecyclerPool, _optimizedStreamFromURL, _pathInputStream, _pathOutputStream, _reportRangeError, _unsupported, _unsupported, _wrapIOFailure, constructCINameMatcher, constructNameMatcher, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createNonBlockingByteArrayParser, createNonBlockingByteBufferParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, errorReportConfiguration, getFactoryFeatures, getStreamReadFeatures, getStreamWriteFeatures, isEnabled, isEnabled, isEnabled, requiresPropertyOrdering, streamReadConstraints, streamWriteConstraints
-
Field Details
-
FORMAT_NAME_XML
Name used to identify XML format (and returned bygetFormatName()- See Also:
-
DEFAULT_XML_READ_FEATURE_FLAGS
protected static final int DEFAULT_XML_READ_FEATURE_FLAGSBitfield (set of flags) of all parser features that are enabled by default. -
DEFAULT_XML_WRITE_FEATURE_FLAGS
protected static final int DEFAULT_XML_WRITE_FEATURE_FLAGSBitfield (set of flags) of all generator features that are enabled by default. -
_cfgNameForTextElement
-
_nameProcessor
-
_xmlInputFactory
-
_xmlOutputFactory
-
_jdkXmlInFactory
-
_jdkXmlOutFactory
-
-
Constructor Details
-
XmlFactory
public XmlFactory()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. -
XmlFactory
-
XmlFactory
-
XmlFactory
protected XmlFactory(int xpFeatures, int xgFeatures, XMLInputFactory xmlIn, XMLOutputFactory xmlOut, XmlNameProcessor nameProcessor, String nameForTextElem) -
XmlFactory
Constructor used byXmlFactoryBuilderfor instantiation. -
XmlFactory
Constructor used bycopy()- Parameters:
src- Factory to make copy of
-
XmlFactory
-
-
Method Details
-
_initFactories
-
rebuild
- Specified by:
rebuildin classtools.jackson.core.TokenStreamFactory
-
builder
Main factory method to use for constructingXmlFactoryinstances with different configuration. -
builderWithJackson2Defaults
The builder returned uses default settings more closely matching the default configs used in Jackson 2.x versions.This method is still a work in progress and may not yet fully replicate the default settings of Jackson 2.x.
-
copy
Note: compared to base implementation byTokenStreamFactory, here the copy will actually share underlying XML input and output factories, as there is no way to make copies of those.- Specified by:
copyin classtools.jackson.core.TokenStreamFactory
-
snapshot
public tools.jackson.core.TokenStreamFactory snapshot()Instances are immutable so just return `this`- Specified by:
snapshotin interfacetools.jackson.core.util.Snapshottable<tools.jackson.core.TokenStreamFactory>- Specified by:
snapshotin classtools.jackson.core.TokenStreamFactory
-
withNameForTextElement
"Mutant factory" method used to allowXmlMapper.Builderto configure name used for text elements, instead of requiring defining it viaXmlFactoryBuilder. -
readResolve
Method that we need to override to actually make restoration go through constructors etc. -
version
public tools.jackson.core.Version version()- Specified by:
versionin interfacetools.jackson.core.Versioned- Specified by:
versionin classtools.jackson.core.TokenStreamFactory
-
canParseAsync
public boolean canParseAsync()- Specified by:
canParseAsyncin classtools.jackson.core.TokenStreamFactory
-
canUseCharArrays
public boolean canUseCharArrays()Since 2.4, we do have actual capability for passing char arrays efficiently, but unfortunately have no working mechanism for recycling buffers. So we have to admit that can not make efficient use.- Overrides:
canUseCharArraysin classtools.jackson.core.base.TextualTSFactory
-
getFormatName
Method that returns short textual id identifying format this factory supports.Note: sub-classes should override this method; default implementation will return null for all sub-classes
- Specified by:
getFormatNamein classtools.jackson.core.TokenStreamFactory
-
canUseSchema
public boolean canUseSchema(tools.jackson.core.FormatSchema schema) - Specified by:
canUseSchemain classtools.jackson.core.TokenStreamFactory
-
getFormatReadFeatureType
- Overrides:
getFormatReadFeatureTypein classtools.jackson.core.TokenStreamFactory
-
getFormatWriteFeatureType
- Overrides:
getFormatWriteFeatureTypein classtools.jackson.core.TokenStreamFactory
-
getFormatReadFeatures
public int getFormatReadFeatures()- Overrides:
getFormatReadFeaturesin classtools.jackson.core.TokenStreamFactory
-
getFormatWriteFeatures
public int getFormatWriteFeatures()- Overrides:
getFormatWriteFeaturesin classtools.jackson.core.TokenStreamFactory
-
getXMLTextElementName
-
getXMLInputFactory
-
getXMLOutputFactory
-
createParser
public tools.jackson.core.JsonParser createParser(tools.jackson.core.ObjectReadContext readCtxt, String content) Overridden just to prevent trying to optimize access via char array; while nice idea, problem is that we don't have proper hooks to ensure that temporary buffer gets recycled; so let's just use StringReader.- Overrides:
createParserin classtools.jackson.core.base.TextualTSFactory
-
_createParser
protected tools.jackson.core.JsonParser _createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ctxt, DataInput input) - Specified by:
_createParserin classtools.jackson.core.base.TextualTSFactory
-
_createGenerator
protected tools.jackson.core.JsonGenerator _createGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, Writer out) - Specified by:
_createGeneratorin classtools.jackson.core.base.TextualTSFactory
-
_createUTF8Generator
protected tools.jackson.core.JsonGenerator _createUTF8Generator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, OutputStream out) - Specified by:
_createUTF8Generatorin classtools.jackson.core.base.TextualTSFactory
-
_toXmlGenerator
protected ToXmlGenerator _toXmlGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, XMLStreamWriter sw) Overridable method to allow using custom FromXmlParser sub-classes. -
createParser
public FromXmlParser createParser(tools.jackson.core.ObjectReadContext readCtxt, XMLStreamReader sr) throws IOException Factory method that wraps givenXMLStreamReader, usually to allow partial data-binding.- Throws:
IOException
-
createGenerator
public ToXmlGenerator createGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, XMLStreamWriter sw) throws IOException Factory method that wraps givenXMLStreamWriter, usually to allow incremental serialization to compose large output by serializing a sequence of individual objects.- Throws:
IOException
-
_createParser
protected FromXmlParser _createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, InputStream in) - Specified by:
_createParserin classtools.jackson.core.base.TextualTSFactory
-
_createParser
protected FromXmlParser _createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, Reader r) - Specified by:
_createParserin classtools.jackson.core.base.TextualTSFactory
-
_createParser
protected FromXmlParser _createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, char[] data, int offset, int len, boolean recycleBuffer) - Specified by:
_createParserin classtools.jackson.core.base.TextualTSFactory
-
_createParser
protected FromXmlParser _createParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, byte[] data, int offset, int len) - Specified by:
_createParserin classtools.jackson.core.base.TextualTSFactory
-
_fromXmlParser
protected FromXmlParser _fromXmlParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, XMLStreamReader sr) Overridable method to allow using custom FromXmlParser sub-classes. -
_createXmlWriter
-
_createXmlWriter
-
_initializeXmlWriter
-
_initializeXmlReader
-