public class HtmlSerializerSession extends XmlSerializerSession
HtmlSerializer
.
This class is NOT thread safe. It is typically discarded after one-time use although it can be reused within the same thread.
XmlSerializerSession.ContentResult
indent
Modifier | Constructor and Description |
---|---|
protected |
HtmlSerializerSession(HtmlSerializer ctx,
SerializerSessionArgs args)
Create a new session using properties specified in the context.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doSerialize(SerializerPipe out,
Object o)
Serializes a POJO to the specified output stream or writer.
|
String |
getAnchorText(BeanPropertyMeta pMeta,
Object o)
Returns the anchor text to use for the specified URL object.
|
protected HtmlBeanPropertyMeta |
getHtmlBeanPropertyMeta(BeanPropertyMeta bpm)
Returns the language-specific metadata on the specified bean property.
|
protected HtmlClassMeta |
getHtmlClassMeta(ClassMeta<?> cm)
Returns the language-specific metadata on the specified class.
|
protected HtmlWriter |
getHtmlWriter(SerializerPipe out)
Converts the specified output target object to an
HtmlWriter . |
protected String |
getLabelParameter()
Configuration property: Link label parameter name.
|
protected AnchorText |
getUriAnchorText()
Configuration property: Anchor text source.
|
protected boolean |
isAddBeanTypes()
Configuration property: Add
|
protected boolean |
isAddKeyValueTableHeaders()
Configuration property: Add key/value headers on bean/map tables.
|
protected boolean |
isDetectLabelParameters()
Configuration property: Look for link labels in URIs.
|
protected boolean |
isDetectLinksInStrings()
Configuration property: Look for URLs in
Strings . |
boolean |
isHtmlMode()
Returns
|
boolean |
isUri(ClassMeta<?> cm,
BeanPropertyMeta pMeta,
Object o)
Returns
|
protected XmlSerializerSession.ContentResult |
serializeAnything(XmlWriter out,
Object o,
ClassMeta<?> eType,
String name,
BeanPropertyMeta pMeta,
int xIndent,
boolean isRoot,
boolean nlIfElement)
Serialize the specified object to the specified writer.
|
protected XmlSerializerSession.ContentResult |
serializeAnything(XmlWriter out,
Object o,
ClassMeta<?> eType,
String elementName,
Namespace elementNamespace,
boolean addNamespaceUris,
XmlFormat format,
boolean isMixed,
boolean preserveWhitespace,
BeanPropertyMeta pMeta)
Workhorse method.
|
ObjectMap |
toMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
findNsfMappings, getDefaultNamespace, getNamespaces, getXmlBeanMeta, getXmlBeanPropertyMeta, getXmlClassMeta, getXmlWriter, getXsNamespace, isAddNamespaceUrisToRoot, isAutoDetectNamespaces, isEnableNamespaces
createPipe, getMaxIndent, getQuoteChar, isUseWhitespace, isWriterSerializer, serialize, serializeToString
canIgnoreValue, createBeanTypeNameProperty, createDefaultVarResolverSession, generalize, getBeanTypeName, getExpectedRootType, getJavaMethod, getListener, getListener, getResponseHeaders, getUriContext, getUriRelativity, getUriResolution, getUriResolver, getVarResolver, isAddRootType, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimNullProperties, isTrimStrings, onBeanGetterException, onError, push2, relativizeUri, resolve, resolveUri, serialize, sort, sort, swap, toList, toString, trim, varSessionObject
getInitialDepth, getLastLocation, getMaxDepth, getOptionalType, getOptionalValue, getStack, isDetectRecursions, isIgnoreRecursions, isOptional, pop, push, setCurrentClass, setCurrentProperty, willRecurse
_class, checkForWarnings, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionaryClasses, getBeanFieldVisibility, getBeanFilters, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getBpi, getBpro, getBpwo, getBpx, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getExamples, getImplClasses, getLocale, getMediaType, getNotBeanClasses, getNotBeanPackagesNames, getNotBeanPackagesPrefixes, getPojoSwaps, getPropertyNamer, getSchema, getStringBuilder, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isDebug, isFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnorePropertiesWithoutSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, object, returnStringBuilder, string, toArray, toBeanMap, toBeanMap
addToCache, addToCache, addWarning, getClassProperty, getFromCache, getInstanceArrayProperty, getInstanceProperty, getLogger, getProperties, getProperty, getProperty, getProperty, getPropertyKeys, getWarnings, hasProperty, hasWarnings, toString
protected HtmlSerializerSession(HtmlSerializer 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.protected final HtmlWriter getHtmlWriter(SerializerPipe out) throws IOException
HtmlWriter
.out
- The output target object.HtmlWriter
.IOException
- Thrown by underlying stream.public boolean isUri(ClassMeta<?> cm, BeanPropertyMeta pMeta, Object o)
cm
- The ClassMeta of the object being serialized.pMeta
- The property metadata of the bean property of the object.
Can be o
- The object.public String getAnchorText(BeanPropertyMeta pMeta, Object o)
pMeta
- The property metadata of the bean property of the object.
Can be o
- The URL object.public boolean isHtmlMode()
XmlSerializerSession
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.
isHtmlMode
in class XmlSerializerSession
protected void doSerialize(SerializerPipe out, Object o) throws IOException, SerializeException
SerializerSession
This method should NOT close the context object.
doSerialize
in class XmlSerializerSession
out
- Where to send the output from the serializer.o
- The object to serialize.IOException
- Thrown by underlying stream.SerializeException
- Problem occurred trying to serialize object.protected XmlSerializerSession.ContentResult serializeAnything(XmlWriter out, Object o, ClassMeta<?> eType, String elementName, Namespace elementNamespace, boolean addNamespaceUris, XmlFormat format, boolean isMixed, boolean preserveWhitespace, BeanPropertyMeta pMeta) throws IOException, SerializeException
XmlSerializerSession
serializeAnything
in class XmlSerializerSession
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.IOException
- Thrown by underlying stream.SerializeException
- General serialization error occurred.protected XmlSerializerSession.ContentResult serializeAnything(XmlWriter out, Object o, ClassMeta<?> eType, String name, BeanPropertyMeta pMeta, int xIndent, boolean isRoot, boolean nlIfElement) throws IOException, SerializeException
out
- The writer.o
- The object to serialize.eType
- The expected type of the object if this is a bean property.name
- The attribute name of this object if this object was a field in a JSON object (i.e. key of a
Map.Entry
or property name of a bean).pMeta
- The bean property being serialized, or xIndent
- The current indentation value.isRoot
- nlIfElement
- IOException
- Thrown by underlying stream.SerializeException
- Generic serialization error occurred.protected final boolean isAddBeanTypes()
isAddBeanTypes
in class XmlSerializerSession
HtmlSerializer.HTML_addBeanTypes
protected final boolean isAddKeyValueTableHeaders()
HtmlSerializer.HTML_addKeyValueTableHeaders
protected final boolean isDetectLabelParameters()
HtmlSerializer.HTML_detectLabelParameters
protected final boolean isDetectLinksInStrings()
Strings
.HtmlSerializer.HTML_detectLinksInStrings
protected final String getLabelParameter()
HtmlSerializer.HTML_detectLabelParameters
.HtmlSerializer.HTML_labelParameter
protected final AnchorText getUriAnchorText()
<a href ='...'
> text</a>
) in HTML, this setting defines what to set the inner text to.HtmlSerializer.HTML_uriAnchorText
protected HtmlClassMeta getHtmlClassMeta(ClassMeta<?> cm)
cm
- The class to return the metadata on.protected HtmlBeanPropertyMeta getHtmlBeanPropertyMeta(BeanPropertyMeta bpm)
bpm
- The bean property to return the metadata on.public ObjectMap toMap()
Session
toMap
in class XmlSerializerSession
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.