Class MarkdownSerializerSession
- All Implemented Interfaces:
BeanSession,ConverterSession,RecordWritable
- Direct Known Subclasses:
MarkdownDocSerializerSession
MarkdownSerializer.
Notes:
- This class is not thread safe and is typically discarded after one use.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class.static final classConcrete default builder leaf for the non-subclassedcreate()path (CRTP terminal). -
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
ConstructorsModifierConstructorDescriptionprotectedConstructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic MarkdownSerializerSession.Builder<?>create(MarkdownSerializer ctx) Creates a new builder for this object.protected voiddoWrite(SerializerPipe pipe, Object o) Serializes a POJO to the specified pipe.protected MarkdownWriterGets or creates aMarkdownWriterfrom the given pipe.protected String[]getTableHeaders(Collection<?> c) Determines if a collection can be rendered as a multi-column table.booleanStreaming-quality signal queryable before opening a cursor.protected voidwriteAnything(MarkdownWriter w, Object o, ClassMeta<?> eType, BeanPropertyMeta pMeta) Main serialization dispatch method.protected voidwriteBeanMap(MarkdownWriter w, BeanMap<?> bm, ClassMeta<?> eType, ClassMeta<?> aType) Serializes a bean as a 2-column key/value Markdown table.protected voidwriteCollection(MarkdownWriter w, Collection<?> c, ClassMeta<?> eType, ClassMeta<?> cm) Serializes a collection as either a multi-column table (uniform beans/maps) or a bulleted list.protected StringSerializes a value for placement in a Markdown table cell.protected voidwriteMap(MarkdownWriter w, Map<?, ?> m, ClassMeta<?> cm) Serializes a Map as a 2-column key/value Markdown table.writeRecords(Object output) Opens a low-levelRecordWritercursor over the specified output.Methods 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, isAddBeanTypes, 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
-
MarkdownSerializerSession
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.
-
writeRecords
Description copied from interface:RecordWritableOpens a low-levelRecordWritercursor over the specified output.When invoked on a convenience
Serializerthe cursor is opened with default session args (mirroringwrite(...)). Callers that need request-derived configuration should instead callcreateSession(args).build()and invoke this method on the resultingSerializerSession.- Specified by:
writeRecordsin interfaceRecordWritable- Parameters:
output- The output. Subtypes define the supported types (typicallyWriter/OutputStream/File/StringBuilder).- Returns:
- A new
RecordWritercursor. - Throws:
IOException- If a problem occurred opening the underlying output.
-
isRecordStreaming
Description copied from interface:RecordWritableStreaming-quality signal queryable before opening a cursor.- Specified by:
isRecordStreamingin interfaceRecordWritable- Returns:
true ifRecordWritable.writeRecords(Object)returns an O(1)-memory streaming cursor;false for buffered (whole-value) formats backed byRecordAdapter.
-
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 classSerializerSession- Parameters:
pipe- 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.
-
writeAnything
protected void writeAnything(MarkdownWriter w, Object o, ClassMeta<?> eType, BeanPropertyMeta pMeta) throws IOException, SerializeException Main serialization dispatch method.- Parameters:
w- The writer to write to.o- The object to serialize.eType- The expected type of the object.pMeta- The bean property meta (may be null).- Throws:
IOException- Thrown by underlying stream.SerializeException- If serialization fails.
-
writeBeanMap
protected void writeBeanMap(MarkdownWriter w, BeanMap<?> bm, ClassMeta<?> eType, ClassMeta<?> aType) throws IOException, SerializeException Serializes a bean as a 2-column key/value Markdown table.- Parameters:
w- The writer.bm- The bean map.eType- The expected type (for type name calculation).aType- The actual type (for type name calculation).- Throws:
IOException- Thrown by underlying stream.SerializeException- If serialization fails.
-
writeMap
protected void writeMap(MarkdownWriter w, Map<?, ?> m, ClassMeta<?> cm) throws IOException, SerializeExceptionSerializes a Map as a 2-column key/value Markdown table.- Parameters:
w- The writer.m- The map.cm- The class meta.- Throws:
IOException- Thrown by underlying stream.SerializeException- If serialization fails.
-
writeCollection
protected void writeCollection(MarkdownWriter w, Collection<?> c, ClassMeta<?> eType, ClassMeta<?> cm) throws IOException, SerializeException Serializes a collection as either a multi-column table (uniform beans/maps) or a bulleted list.- Parameters:
w- The writer.c- The collection.eType- The expected type.cm- The class meta.- Throws:
IOException- Thrown by underlying stream.SerializeException- If serialization fails.
-
writeInlineValue
Serializes a value for placement in a Markdown table cell.Simple values (strings, numbers, booleans, enums, dates) are escaped and returned inline. Complex values (beans, maps, collections) are serialized as JSON5 in backticks.
- Parameters:
o- The value to serialize.- Returns:
- The cell string value.
- Throws:
SerializeException- If serialization fails.
-
getTableHeaders
Determines if a collection can be rendered as a multi-column table.Returns the column header names if the collection is a uniform set of beans or maps, or
nullif it should be rendered as a bulleted list.- Parameters:
c- The collection to inspect.
Must not benull .- Returns:
- The column header names, or
nullfor list rendering. - Throws:
SerializeException- If inspection fails.
-
getMarkdownWriter
Gets or creates aMarkdownWriterfrom the given pipe.- Parameters:
out- The serializer pipe.
Must not benull .- Returns:
- The writer.
-