Top Description Fields Constructors Methods
com.fasterxml.jackson.dataformat.xml

public Class XmlFactory

extends JsonFactory
Class Inheritance
Imports
java.io.*, javax.xml.stream.*, org.codehaus.stax2.XMLInputFactory2, org.codehaus.stax2.io.Stax2ByteArraySource, .Stax2CharArraySource, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.format.InputAccessor, .MatchStrength, com.fasterxml.jackson.core.io.IOContext, com.fasterxml.jackson.core.util.VersionUtil, com.fasterxml.jackson.databind.util.ClassUtil, com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser, com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator, com.fasterxml.jackson.dataformat.xml.util.StaxUtil

Factory used for constructing FromXmlParser and ToXmlGenerator instances.

Implements JsonFactory since interface for constructing XML backed parsers and generators is quite similar to dealing with JSON.

Author
Tatu Saloranta ([email protected])

Field Summary

Modifier and TypeField and Description
protected String
protected transient String
_jdkXmlInFactory

Hiding place for JDK-serialization unthawed factories...

protected transient String
_jdkXmlOutFactory

Hiding place for JDK-serialization unthawed factories...

protected XmlNameProcessor
protected int
protected transient XMLInputFactory
protected transient XMLOutputFactory
protected int
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte
pack-priv static final int
DEFAULT_XML_GENERATOR_FEATURE_FLAGS

Bitfield (set of flags) of all generator features that are enabled by default.

pack-priv static final int
DEFAULT_XML_PARSER_FEATURE_FLAGS

Bitfield (set of flags) of all parser features that are enabled by default.

public static final String
FORMAT_NAME_XML

Name used to identify XML format (and returned by getFormatName()

private static final long
private static final byte
private static final byte
private static final byte
Inherited from com.fasterxml.jackson.core.JsonFactory:
_byteSymbolCanonicalizer_characterEscapes_errorReportConfiguration_factoryFeatures_generatorDecorators_generatorFeatures_inputDecorator_maximumNonEscapedChar_objectCodec_outputDecorator_parserFeatures_quoteChar_recyclerPool_rootCharSymbols_rootValueSeparator_streamReadConstraints_streamWriteConstraintsDEFAULT_FACTORY_FEATURE_FLAGSDEFAULT_GENERATOR_FEATURE_FLAGSDEFAULT_PARSER_FEATURE_FLAGSDEFAULT_QUOTE_CHARDEFAULT_ROOT_VALUE_SEPARATORFORMAT_NAME_JSON

Constructor Summary

AccessConstructor and Description
public
XmlFactory()

Default constructor used to create factory instances.

public
public
public
public
public
XmlFactory(ObjectCodec oc, int xpFeatures, int xgFeatures, XMLInputFactory xmlIn, XMLOutputFactory xmlOut, String nameForTextElem)

protected
XmlFactory(ObjectCodec oc, int xpFeatures, int xgFeatures, XMLInputFactory xmlIn, XMLOutputFactory xmlOut, String nameForTextElem, XmlNameProcessor nameProcessor)

protected
protected
XmlFactory(XmlFactoryBuilder b)

Constructors used by JsonFactoryBuilder for instantiation.

Method Summary

Modifier and TypeMethod and Description
protected JsonGenerator
_createGenerator(Writer
Writer underlying writer to write generated content to
out
,
IOContext
I/O context to use
ctxt
)

Overrides com.fasterxml.jackson.core.JsonFactory._createGenerator.

Overridable factory method that actually instantiates generator for given Writer and context object.

protected FromXmlParser
_createParser(InputStream
InputStream to use for reading content to parse
in
,
IOContext
I/O context to use for parsing
ctxt
)

Overrides com.fasterxml.jackson.core.JsonFactory._createParser.

Overridable factory method that actually instantiates desired parser given InputStream and context object.

protected FromXmlParser
_createParser(Reader
Reader to use for reading content to parse
r
,
IOContext
I/O context to use for parsing
ctxt
)

Overrides com.fasterxml.jackson.core.JsonFactory._createParser.

Overridable factory method that actually instantiates parser using given Reader object for reading content.

protected FromXmlParser
_createParser(char[]
Buffer that contains content to parse
data
,
int
Offset to the first character of data to parse
offset
,
int
Number of characters within buffer to parse
len
,
IOContext
I/O context to use for parsing
ctxt
,
boolean
Whether input buffer is recycled by the factory
recycleBuffer
)

Overrides com.fasterxml.jackson.core.JsonFactory._createParser.

Overridable factory method that actually instantiates parser using given char[] object for accessing content.

protected FromXmlParser
_createParser(byte[]
Buffer that contains content to parse
data
,
int
Offset to the first character of data to parse
offset
,
int
Number of characters within buffer to parse
len
,
IOContext
I/O context to use for parsing
ctxt
)

Overrides com.fasterxml.jackson.core.JsonFactory._createParser.

Overridable factory method that actually instantiates parser using given Reader object for reading content passed as raw byte array.

protected XMLStreamWriter
protected XMLStreamWriter
protected OutputStream
protected Writer
_decorate(IOContext ioCtxt, Writer out)

protected void
protected final XMLStreamReader
protected final XMLStreamWriter
public static XmlFactoryBuilder
builder()

Hides com.fasterxml.jackson.core.JsonFactory.builder.

Main factory method to use for constructing JsonFactory instances with different configuration: creates and returns a builder for collecting configuration settings; instance created by calling build() after all configuration set.

public boolean
canUseCharArrays()

Overrides com.fasterxml.jackson.core.JsonFactory.canUseCharArrays.

As of 2.4, we do have actual capability for passing char arrays efficiently, but unfortunately have no working mechanism for recycling buffers.

public final XmlFactory
configure(FromXmlParser.Feature f, boolean state)

Method for enabling or disabling specified XML parser feature.

public final XmlFactory
configure(ToXmlGenerator.Feature f, boolean state)

Method for enabling or disabling specified XML generator feature.

public XmlFactory
copy()

Overrides com.fasterxml.jackson.core.JsonFactory.copy.

Note

compared to base implementation by JsonFactory, here the copy will actually share underlying XML input and output factories, as there is no way to make copies of those.

public ToXmlGenerator
createGenerator(OutputStream out)

Overrides com.fasterxml.jackson.core.JsonFactory.createGenerator.

Convenience method for constructing generator that uses default encoding of the format (UTF-8 for JSON and most other data formats).

public ToXmlGenerator
createGenerator(OutputStream
OutputStream to use for writing JSON content
out
,
JsonEncoding
Character encoding to use
enc
)

Overrides com.fasterxml.jackson.core.JsonFactory.createGenerator.

Method for constructing JSON generator for writing JSON content using specified output stream.

public ToXmlGenerator
createGenerator(Writer
Writer to use for writing JSON content
out
)

Overrides com.fasterxml.jackson.core.JsonFactory.createGenerator.

Method for constructing JSON generator for writing JSON content using specified Writer.

public ToXmlGenerator
createGenerator(File
File to write contents to
f
,
JsonEncoding
Character encoding to use
enc
)

Overrides com.fasterxml.jackson.core.JsonFactory.createGenerator.

Method for constructing JSON generator for writing JSON content to specified file, overwriting contents it might have (or creating it if such file does not yet exist).

public ToXmlGenerator
createGenerator(XMLStreamWriter sw)

Factory method that wraps given XMLStreamWriter, usually to allow incremental serialization to compose large output by serializing a sequence of individual objects.

public JsonParser
createParser(String content)

Overrides com.fasterxml.jackson.core.JsonFactory.createParser.

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.

public FromXmlParser
createParser(XMLStreamReader sr)

Factory method that wraps given XMLStreamReader, usually to allow partial data-binding.

public XmlFactory
disable(FromXmlParser.Feature f)

Method for disabling specified XML parser feature.

public XmlFactory
disable(ToXmlGenerator.Feature f)

Method for disabling specified XML generator feature.

public XmlFactory
enable(FromXmlParser.Feature f)

Method for enabling specified XML parser feature.

public XmlFactory
enable(ToXmlGenerator.Feature f)

Method for enabling specified XML generator feature.

public int
public String
getFormatName()

Overrides com.fasterxml.jackson.core.JsonFactory.getFormatName.

Method that returns short textual id identifying format this factory supports.

public int
public Class<FromXmlParser.Feature>
getFormatReadFeatureType()

Overrides com.fasterxml.jackson.core.JsonFactory.getFormatReadFeatureType.

Method for accessing kind of FormatFeature that a parser JsonParser produced by this factory would accept, if any; null returned if none.

public Class<ToXmlGenerator.Feature>
getFormatWriteFeatureType()

Overrides com.fasterxml.jackson.core.JsonFactory.getFormatWriteFeatureType.

Method for accessing kind of FormatFeature that a parser JsonGenerator produced by this factory would accept, if any; null returned if none.

public XMLInputFactory
public XmlNameProcessor
public XMLOutputFactory
public String
public MatchStrength
public static MatchStrength
hasXMLFormat(InputAccessor acc)

Method that tries to figure out if content seems to be in some kind of XML format.

public final boolean
isEnabled(FromXmlParser.Feature f)

Checked whether specified XML parser feature is enabled.

public final boolean
isEnabled(ToXmlGenerator.Feature f)

Check whether specified XML generator feature is enabled.

private void
readObject(ObjectInputStream in)

In addition to default serialization, which mostly works, need to handle case of XML factories, hence override.

protected Object
readResolve()

Overrides com.fasterxml.jackson.core.JsonFactory.readResolve.

Method that we need to override to actually make restoration go through constructors etc.

public XmlFactoryBuilder
rebuild()

Overrides com.fasterxml.jackson.core.JsonFactory.rebuild.

Method that allows construction of differently configured factory, starting with settings of this factory.

public boolean

Returns:

True since XML format does require support from codec
requiresCustomCodec
()

Overrides com.fasterxml.jackson.core.JsonFactory.requiresCustomCodec.

XML format does require support from custom ObjectCodec (that is, XmlMapper), so need to return true here.

public void
setXMLInputFactory(XMLInputFactory f)
Deprecated Since 2.12 -- should be set as part of build process (either in builder, or constructor)

public void
public void
setXMLOutputFactory(XMLOutputFactory f)
Deprecated Since 2.12 -- should be set as part of build process (either in builder, or constructor)

public void
private static final int
skipSpace(InputAccessor acc, byte b)

private static final MatchStrength
tryMatch(InputAccessor acc, String matchStr, MatchStrength fullMatchStrength)

private static final boolean
public Version
version()

Overrides com.fasterxml.jackson.core.JsonFactory.version.

Implements com.fasterxml.jackson.core.Versioned.version.

Method called to detect version of the component that implements this interface; returned version should never be null, but may return specific "not available" instance (see Version for details).

private void
writeObject(ObjectOutputStream out)

In addition to default serialization, which mostly works, need to handle case of XML factories, hence override.

Inherited from com.fasterxml.jackson.core.JsonFactory:
_checkInvalidCopy_copy_createContentReference_createContentReference_createContext_createContext_createNonBlockingContext_createParser_createUTF8Generator_createWriter_decorate_decorate_decorate_decorate_decorate_decorate_getBufferRecycler_getRecyclerPoolcanHandleBinaryNativelycanParseAsynccanUseSchemaconfigureconfigureconfigurecreateGeneratorcreateGeneratorcreateJsonGeneratorcreateJsonGeneratorcreateJsonGeneratorcreateJsonParsercreateJsonParsercreateJsonParsercreateJsonParsercreateJsonParsercreateJsonParsercreateJsonParsercreateNonBlockingByteArrayParsercreateNonBlockingByteBufferParsercreateParsercreateParsercreateParsercreateParsercreateParsercreateParsercreateParsercreateParsercreateParserdisabledisabledisableenableenableenablegetCharacterEscapesgetCodecgetFactoryFeaturesgetGeneratorFeaturesgetInputDecoratorgetOutputDecoratorgetParserFeaturesgetRootValueSeparatorhasJSONFormatisEnabledisEnabledisEnabledisEnabledisEnabledrequiresPropertyOrderingsetCharacterEscapessetCodecsetErrorReportConfigurationsetInputDecoratorsetOutputDecoratorsetRecyclerPoolsetRootValueSeparatorsetStreamReadConstraintssetStreamWriteConstraintsstreamReadConstraintsstreamWriteConstraints