public class XmlSerializerSession extends WriterSerializerSession
XmlSerializer
.
This class is NOT thread safe. It is typically discarded after one-time use although it can be reused within the same thread.
indent
Modifier | Constructor and Description |
---|---|
protected |
XmlSerializerSession(XmlSerializer ctx,
SerializerSessionArgs args)
Create a new session using properties specified in the context.
|
Modifier and Type | Method and Description |
---|---|
ObjectMap |
asMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
protected void |
doSerialize(SerializerPipe out,
Object o)
Serializes a POJO to the specified output stream or writer.
|
protected void |
findNsfMappings(Object o)
Recursively searches for the XML namespaces on the specified POJO and adds them to the serializer context object.
|
XmlWriter |
getXmlWriter(SerializerPipe out)
Converts the specified output target object to an
XmlWriter . |
protected boolean |
isAddBeanTypeProperties()
Returns the
XmlSerializer.XML_addBeanTypeProperties setting value for this session. |
protected boolean |
isHtmlMode()
Returns
|
protected XmlWriter |
serializeAnything(XmlWriter out,
Object o,
ClassMeta<?> eType,
String elementName,
Namespace elementNamespace,
boolean addNamespaceUris,
XmlFormat format,
boolean isMixed,
boolean preserveWhitespace,
BeanPropertyMeta pMeta)
Workhorse method.
|
isWriterSerializer, serialize
canIgnoreValue, createBeanTypeNameProperty, createPipe, generalize, getBeanTypeName, getExpectedRootType, getInitialDepth, getJavaMethod, getLastLocation, getListener, getListener, getMaxDepth, getMaxIndent, getQuoteChar, getResponseHeaders, getUriResolver, isDetectRecursions, isIgnoreRecursions, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimNulls, isTrimStrings, isUseWhitespace, onBeanGetterException, onError, pop, push, relativizeUri, resolveUri, serialize, setCurrentClass, setCurrentProperty, sort, sort, toList, toString, trim, willRecurse
_class, checkForWarnings, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, getArgsClassMeta, getBeanMeta, getBeanRegistry, getBeanTypePropertyName, getClassMeta, getClassMeta, getClassMetaForObject, getLocale, getMediaType, getStringBuilder, getTimeZone, isBean, isBean, isDebug, isIgnoreUnknownBeanProperties, newBean, newBean, newBeanMap, newBeanMap, newInstance, newInstance, newInstanceFromOuter, object, returnStringBuilder, string, toArray, toBeanMap, toBeanMap
addToCache, addToCache, addWarning, getClassProperty, getFromCache, getInstanceArrayProperty, getInstanceProperty, getLogger, getProperties, getProperty, getProperty, getProperty, getPropertyKeys, getWarnings, hasWarnings, toString
protected XmlSerializerSession(XmlSerializer ctx, SerializerSessionArgs args)
ctx
- The context creating this session object.
The context contains all the configuration settings for this object.args
- Runtime arguments.
These specify session-level information such as locale and URI context.
It also include session-level properties that override the properties defined on the bean and
serializer contexts.public ObjectMap asMap()
Session
asMap
in class SerializerSession
protected boolean isAddBeanTypeProperties()
XmlSerializer.XML_addBeanTypeProperties
setting value for this session.isAddBeanTypeProperties
in class SerializerSession
XmlSerializer.XML_addBeanTypeProperties
setting value for this session.protected boolean isHtmlMode()
The difference in behavior is how empty non-void elements are handled. The XML serializer will produce a collapsed tag, whereas the HTML serializer will produce a start and end tag.
public final XmlWriter getXmlWriter(SerializerPipe out) throws Exception
XmlWriter
.protected void doSerialize(SerializerPipe out, Object o) throws Exception
SerializerSession
This method should NOT close the context object.
doSerialize
in class SerializerSession
out
- Where to send the output from the serializer.o
- The object to serialize.Exception
- If thrown from underlying stream, or if the input contains a syntax error or is malformed.protected final void findNsfMappings(Object o) throws SerializeException
o
- The POJO to check.SerializeException
protected XmlWriter serializeAnything(XmlWriter out, Object o, ClassMeta<?> eType, String elementName, Namespace elementNamespace, boolean addNamespaceUris, XmlFormat format, boolean isMixed, boolean preserveWhitespace, BeanPropertyMeta pMeta) throws Exception
out
- The writer to send the output to.o
- The object to serialize.eType
- The expected type if this is a bean property value being serialized.elementName
- The root element name.elementNamespace
- The namespace of the element.addNamespaceUris
- Flag indicating that namespace URIs need to be added.format
- The format to serialize the output to.isMixed
- We're serializing mixed content, so don't use whitespace.preserveWhitespace
- XmlFormat.MIXED_PWS
or XmlFormat.TEXT_PWS
.pMeta
- The bean property metadata if this is a bean property being serialized.Exception
- If a problem occurred trying to convert the output.Copyright © 2018 Apache. All rights reserved.