Package org.apache.juneau.marshall.html
Class HtmlSerializerSession
java.lang.Object
org.apache.juneau.marshall.ContextSession
org.apache.juneau.marshall.MarshallingSession
org.apache.juneau.marshall.MarshallingTraverseSession
org.apache.juneau.marshall.serializer.SerializerSession
org.apache.juneau.marshall.serializer.WriterSerializerSession
org.apache.juneau.marshall.xml.XmlSerializerSession
org.apache.juneau.marshall.html.HtmlSerializerSession
- All Implemented Interfaces:
BeanSession,ConverterSession,RecordWritable
- Direct Known Subclasses:
HtmlSchemaSerializerSession,HtmlStrippedDocSerializerSession
Session object that lives for the duration of a single use of
HtmlSerializer.
Notes:
- This class is not thread safe and is typically discarded after one use.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class.static final classConcrete default builder leaf for the non-subclassedcreate()path (CRTP terminal).Nested classes/interfaces inherited from class org.apache.juneau.marshall.xml.XmlSerializerSession
XmlSerializerSession.ContentResult -
Field Summary
Fields inherited from class org.apache.juneau.marshall.MarshallingTraverseSession
indentFields inherited from class org.apache.juneau.marshall.MarshallingSession
NAME_PROPERTY_NAME -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHtmlSerializerSession(HtmlSerializerSession.Builder<?> builder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic HtmlSerializerSession.Builder<?>create(HtmlSerializer ctx) Creates a new builder for this object.protected voiddoWrite(SerializerPipe out, Object o) Serializes a POJO to the specified pipe.getAnchorText(BeanPropertyMeta pMeta, Object o) Returns the anchor text to use for the specified URL object.protected HtmlBeanPropertyMetaReturns the language-specific metadata on the specified bean property.protected HtmlClassMetagetHtmlClassMeta(ClassMeta<?> cm) Returns the language-specific metadata on the specified class.protected final HtmlWriter<?>Converts the specified output target object to anHtmlWriter.protected final StringLink label parameter name.protected final AnchorTextAnchor text source.final booleanAdd"_type" properties when needed.protected final booleanAdd key/value headers on bean/map tables.protected final booleanLook for link labels in URIs.protected final booleanLook for URLs inStrings.booleanReturnstrue if we're serializing HTML.booleanisUri(ClassMeta<?> cm, BeanPropertyMeta pMeta, Object o) Returnstrue if the specified object is a URL.protected XmlSerializerSession.ContentResultwriteAnything(XmlWriter<?> out, Object o, ClassMeta<?> eType, String keyName, String elementName, Namespace elementNamespace, boolean addNamespaceUris, XmlFormat format, boolean isMixed, boolean preserveWhitespace, BeanPropertyMeta pMeta) Workhorse method.protected XmlSerializerSession.ContentResultwriteAnything(XmlWriter<?> out, Object o, ClassMeta<?> eType, String name, BeanPropertyMeta pMeta, int xIndent, boolean isRoot, boolean nlIfElement) Serialize the specified object to the specified writer.Methods inherited from class org.apache.juneau.marshall.xml.XmlSerializerSession
create, findNsfMappings, getDefaultNamespace, getNamespaces, getXmlBeanMeta, getXmlBeanPropertyMeta, getXmlClassMeta, getXmlWriter, isAddJsonTags, isAddNamespaceUrisToRoot, isAutoDetectNamespaces, isEnableNamespaces, isRecordStreaming, writeRecordsMethods inherited from class org.apache.juneau.marshall.serializer.WriterSerializerSession
create, createPipe, getMaxIndent, getQuoteChar, getStreamCharset, isUseWhitespace, isWriterSerializer, properties, write, writeToStringMethods inherited from class org.apache.juneau.marshall.serializer.SerializerSession
addVarBean, canIgnoreValue, canIgnoreValue, create, createBeanTypeNameProperty, createDefaultVarResolverSession, forEachEntry, forEachEntry, forEachStreamableEntry, generalize, getBeanTypeName, getCalendarFormat, getDateFormat, getDurationFormat, getExpectedRootType, getJavaMethod, getListener, getListener, getLocaleFormat, getPeriodFormat, getResponseHeaders, getSchema, getTemporalFormat, getTimeZoneFormat, getUriContext, getUriRelativity, getUriResolution, getUriResolver, getVarResolver, handleThrown, isAddRootType, isKeepNullProperties, isNonDefault, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimStrings, onBeanGetterException, onError, push2, relativizeUri, resolve, resolveUri, sort, sort, sort, swap, toList, toListFromStreamable, toString, trim, unwrapSupplier, write, writeCalendar, writeDate, writeDuration, writePeriod, writeTemporalMethods inherited from class org.apache.juneau.marshall.MarshallingTraverseSession
getInitialDepth, getLastLocation, getMaxDepth, getOptionalType, getOptionalValue, getStack, isDetectRecursions, isIgnoreRecursions, isOptional, isRoot, pop, push, setCurrentClass, setCurrentProperty, willExceedDepth, willRecurseMethods inherited from class org.apache.juneau.marshall.MarshallingSession
addWarning, convertToMemberType, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, convertToType, create, get, getActiveView, getAnnotationProvider, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionary, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassLoader, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getLocale, getMarshallingContext, getMediaType, getNotBeanClasses, getNotBeanPackagesNames, getPropertyNamer, getSwaps, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFindFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnoreMissingSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isPropertyInActiveView, isRecordComponentOrder, isUnsortedProperties, isUseInterfaceProxies, isUseJavaBeanIntrospector, isValidateSchema, newBean, newBean, newBeanMap, newBeanMap, newGenericList, newGenericMap, newGenericMap, object, parseToList, parseToMap, string, toArray, toBeanMap, toBeanMap, toBeanMapMethods inherited from class org.apache.juneau.marshall.ContextSession
checkForWarnings, getContext, getSessionProperties, getWarnings, isDebug, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.juneau.commons.conversion.ConverterSession
get
-
Constructor Details
-
HtmlSerializerSession
Constructor.- Parameters:
builder- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Parameters:
ctx- The context creating this session.
Cannot benull .- Returns:
- A new builder.
-
getAnchorText
Returns the anchor text to use for the specified URL object.- Parameters:
pMeta- The property metadata of the bean property of the object. Can benull if the object isn't from a bean property; thePROPERTY_NAMEanchor-text mode then falls back to the URL string itself.o- The URL object.- Returns:
- The anchor text to use for the specified URL object.
-
isHtmlMode
Description copied from class:XmlSerializerSessionReturnstrue if we're serializing HTML.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.
- Overrides:
isHtmlModein classXmlSerializerSession- Returns:
true if we're generating HTML.
-
isUri
Returnstrue if the specified object is a URL.- Parameters:
cm- The ClassMeta of the object being serialized.pMeta- The property metadata of the bean property of the object. Can benull if the object isn't from a bean property; bean-property-level URI detection is then skipped, relying solely oncm .o- The object.- Returns:
true if the specified object is a URL.
-
doWrite
Description copied from class:SerializerSessionSerializes a POJO to the specified pipe.This method should NOT close the context object.
The default implementation of this method simply calls
Serializer.doWrite(SerializerSession,SerializerPipe,Object).- Overrides:
doWritein classXmlSerializerSession- Parameters:
out- Where to send the output from the serializer.o- The object to serialize.- Throws:
IOException- Thrown by underlying stream.SerializeException- Problem occurred trying to serialize object.
-
getHtmlBeanPropertyMeta
Returns the language-specific metadata on the specified bean property.- Parameters:
bpm- The bean property to return the metadata on.- Returns:
- The metadata.
-
getHtmlClassMeta
Returns the language-specific metadata on the specified class.- Parameters:
cm- The class to return the metadata on.- Returns:
- The metadata.
-
getHtmlWriter
Converts the specified output target object to anHtmlWriter.- Parameters:
out- The output target object.
Must not benull .- Returns:
- The output target object wrapped in an
HtmlWriter.
-
getLabelParameter
Link label parameter name.- Returns:
- The parameter name to look for when resolving link labels.
- See Also:
-
getUriAnchorText
Anchor text source.- Returns:
- When creating anchor tags (e.g.
) in HTML, this setting defines what to set the inner text to.<a href ='...' > text</a> - See Also:
-
isAddBeanTypes
Description copied from class:SerializerSessionAdd"_type" properties when needed.- Overrides:
isAddBeanTypesin classXmlSerializerSession- Returns:
true if"_type" properties added to beans if their type cannot be inferred through reflection.- See Also:
-
isAddKeyValueTableHeaders
Add key/value headers on bean/map tables.- Returns:
true ifkey andvalue column headers are added to tables.- See Also:
-
isDetectLabelParameters
Look for link labels in URIs.- Returns:
true if we should ook for URL label parameters (e.g."?label=foobar" ).- See Also:
-
isDetectLinksInStrings
Look for URLs inStrings.- Returns:
true if we should automatically convert strings to URLs if they look like a URL.- See Also:
-
writeAnything
protected XmlSerializerSession.ContentResult writeAnything(XmlWriter<?> out, Object o, ClassMeta<?> eType, String name, BeanPropertyMeta pMeta, int xIndent, boolean isRoot, boolean nlIfElement) throws SerializeException Serialize the specified object to the specified writer.- Parameters:
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 aMap.Entryor property name of a bean).pMeta- The bean property being serialized, ornull if we're not serializing a bean property.xIndent- The current indentation value.isRoot-true if this is the root element of the document.nlIfElement-true if we should add a newline to the output before serializing only if the object is an element and not text.- Returns:
- The type of content encountered. Either simple (no whitespace) or normal (elements with whitespace).
- Throws:
SerializeException- Generic serialization error occurred.
-
writeAnything
protected XmlSerializerSession.ContentResult writeAnything(XmlWriter<?> out, Object o, ClassMeta<?> eType, String keyName, String elementName, Namespace elementNamespace, boolean addNamespaceUris, XmlFormat format, boolean isMixed, boolean preserveWhitespace, BeanPropertyMeta pMeta) throws SerializeException Description copied from class:XmlSerializerSessionWorkhorse method.- Overrides:
writeAnythingin classXmlSerializerSession- Parameters:
out- The writer to send the output to.
Must not benull .o- The object to serialize.
Can benull (written as the XML null representation, e.g.type='null' ).eType- The expected type if this is a bean property value being serialized.
Can benull (treated as the genericObjecttype).keyName- The property name or map key name.
Can benull (the element is written without a separate property/key name).elementName- The root element name.
Can benull (falls back to the bean dictionary name, thenkeyName , then the JSON type name).elementNamespace- The namespace of the element.
Can benull (resolved from the serialized type's, then the actual type's, then the session's default namespace).addNamespaceUris- Flag indicating that namespace URIs need to be added.format- The format to serialize the output to.
Must not benull .isMixed- We're serializing mixed content, so don't use whitespace.preserveWhitespace-true if we're serializingXmlFormat.MIXED_PWSorXmlFormat.TEXT_PWS.pMeta- The bean property metadata if this is a bean property being serialized.
Can benull (no bean-property-level URI/child-name/namespace metadata is applied).- Returns:
- The same writer passed in so that calls to the writer can be chained.
- Throws:
SerializeException- General serialization error occurred.
-