Class MsgPackSerializerSession
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.OutputStreamSerializerSession
org.apache.juneau.marshall.msgpack.MsgPackSerializerSession
- All Implemented Interfaces:
BeanSession,ConverterSession,ArrayRecordWritable,RecordWritable,TokenWritable
public class MsgPackSerializerSession
extends OutputStreamSerializerSession
implements TokenWritable, ArrayRecordWritable
Session object that lives for the duration of a single use of
MsgPackSerializer.
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.OutputStreamSerializerSession
OutputStreamSerializerSession.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(MsgPackSerializer ctx) Creates a new builder for this object.protected voiddoWrite(SerializerPipe out, Object o) Serializes a POJO to the specified pipe.booleanAdd"_type" properties when needed.booleanStreaming-quality signal queryable before opening a cursor.writeArrayRecords(Object output) Buffered array-elementRecordWriter.writeArrayRecords(Object output, int expectedCount) Streaming array-elementRecordWriterthat pre-declares the element count and writes each element directly to the output stream — no per-element buffering.writeTokens(Object output) Opens a low-level push generator that emits MessagePack one structural event at a time, bound to this live session.Methods inherited from class org.apache.juneau.marshall.serializer.OutputStreamSerializerSession
create, createPipe, getBinaryFormat, hasNativeBytes, isWriterSerializer, 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, properties, 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
getMethods inherited from interface org.apache.juneau.marshall.stream.RecordWritable
isRecordStreamingMethods inherited from interface org.apache.juneau.marshall.stream.TokenWritable
writeRecords
-
Constructor Details
-
MsgPackSerializerSession
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.
-
writeTokens
Opens a low-level push generator that emits MessagePack one structural event at a time, bound to this live session.MsgPack containers are length-prefixed with no indefinite-length encoding, so the writer buffers each open container's body bytes until the matching
endXxxcall; memory cost is O(largest open container).Builder properties honored:
keepNullProperties ,trimEmptyMaps ,trimEmptyCollections ,sortMaps ,sortCollections ,trimStrings — all flow through toobject(Object).Builder properties NOT honored:
useWhitespace ,maxIndent ,quoteChar ,escapeSolidus (binary format);uriContext ,uriResolution ,uriRelativity ,listener .- Specified by:
writeTokensin interfaceTokenWritable- Parameters:
output- The output.- Returns:
- A new
MsgPackTokenWriter. - Throws:
IOException- If the output type is not supported or could not be opened.
-
writeArrayRecords
Buffered array-elementRecordWriter. MsgPack's array wire format is length-prefixed, so streaming without a known element count requires either buffering (this method) or thewriteArrayRecords(Object, int)overload that takes a count.- Specified by:
writeArrayRecordsin interfaceArrayRecordWritable- Parameters:
output- The output.- Returns:
- A buffered
RecordWriter. - Throws:
IOException- If a problem occurred opening the underlying output.
-
isArrayRecordStreaming
Description copied from interface:ArrayRecordWritableStreaming-quality signal queryable before opening a cursor.- Specified by:
isArrayRecordStreamingin interfaceArrayRecordWritable- Returns:
true for true element streaming (json/cbor/msgpack);false for the bufferedRecordAdapter.arrayWriter(org.apache.juneau.marshall.serializer.SerializerSession, java.lang.Object)-backed formats (yaml, parquet, bson).
-
writeArrayRecords
Streaming array-elementRecordWriterthat pre-declares the element count and writes each element directly to the output stream — no per-element buffering. The caller must pass exactlyexpectedCountRecordWriter.write(Object)calls beforeRecordWriter.close(); mismatch throws on close.- Specified by:
writeArrayRecordsin interfaceArrayRecordWritable- Parameters:
output- The output (must be anOutputStream).expectedCount- The number of elements that will be written.- Returns:
- A streaming
RecordWriter. - Throws:
IOException- If a problem occurred opening the underlying output.
-
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.
-
isAddBeanTypes
Description copied from class:SerializerSessionAdd"_type" properties when needed.- Overrides:
isAddBeanTypesin classSerializerSession- Returns:
true if"_type" properties added to beans if their type cannot be inferred through reflection.- See Also:
-