Package org.apache.juneau.marshall.yaml
Class YamlSerializerSession
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.yaml.YamlSerializerSession
- All Implemented Interfaces:
BeanSession,ConverterSession,ArrayRecordWritable,RecordWritable
public class YamlSerializerSession
extends WriterSerializerSession
implements RecordWritable, ArrayRecordWritable
Session object that lives for the duration of a single use of
YamlSerializer.
Notes:
- This class is not thread safe and is typically discarded after one use.
See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.juneau.marshall.serializer.WriterSerializerSession
WriterSerializerSession.DefaultBuilder -
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 TypeMethodDescriptioncreate(YamlSerializer ctx) Creates a new builder for this object.protected voiddoWrite(SerializerPipe out, Object o) Serializes a POJO to the specified pipe.protected final YamlWriterConverts the specified output target object to aYamlWriter.booleanThe YAML array-record writer is buffered/RecordAdapter-backed, not O(1) streaming.booleanThe YAML record writer is buffered/RecordAdapter-backed, not O(1) streaming.protected YamlWriterwriteAnything(YamlWriter out, Object o, ClassMeta<?> eType, String attrName, BeanPropertyMeta pMeta, boolean asField) Workhorse method.writeArrayRecords(Object output) Buffered array-elementRecordWriterfor YAML, bound to this live session.writeRecords(Object output) Opens a whole-value push generator targeting YAML output, bound to this live session.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.marshall.stream.ArrayRecordWritable
writeArrayRecordsMethods inherited from interface org.apache.juneau.commons.conversion.ConverterSession
get
-
Constructor Details
-
YamlSerializerSession
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.
-
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:
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.
-
writeRecords
Opens a whole-value push generator targeting YAML output, bound to this live session.write(Object)delegates toSerializerSession.write(Object, Object).- Specified by:
writeRecordsin interfaceRecordWritable- Parameters:
output- The output.- Returns:
- A new
RecordWriter. - Throws:
IOException- If a problem occurred opening the underlying output.
-
writeArrayRecords
Buffered array-elementRecordWriterfor YAML, bound to this live session. Buffers eachwrite(...)and emits the whole list onclose().- Specified by:
writeArrayRecordsin interfaceArrayRecordWritable- Parameters:
output- The output.- Returns:
- A new
RecordWriter. - Throws:
IOException- If a problem occurred opening the underlying output.
-
isRecordStreaming
The YAML record writer is buffered/RecordAdapter-backed, not O(1) streaming.- Specified by:
isRecordStreamingin interfaceRecordWritable- Returns:
- Always
false .
-
isArrayRecordStreaming
The YAML array-record writer is buffered/RecordAdapter-backed, not O(1) streaming.- Specified by:
isArrayRecordStreamingin interfaceArrayRecordWritable- Returns:
- Always
false .
-
getYamlWriter
Converts the specified output target object to aYamlWriter.- Parameters:
out- The output target object.
Must not benull .- Returns:
- The output target object wrapped in a
YamlWriter.
-
writeAnything
protected YamlWriter writeAnything(YamlWriter out, Object o, ClassMeta<?> eType, String attrName, BeanPropertyMeta pMeta, boolean asField) throws SerializeException Workhorse method. Determines the type of object, and then calls the appropriate type-specific serialization method.- Parameters:
out- The output writer.o- The object to serialize.eType- The expected type.attrName- The attribute name.pMeta- The bean property currently being parsed.asField- Iftrue , this value appears inline after a key or at root level. Iffalse , this value needs its own indentation as a standalone block.- Returns:
- The same writer passed in.
- Throws:
SerializeException- General serialization error occurred.
-