Class OutputStreamSerializerSession
- All Implemented Interfaces:
BeanSession,ConverterSession
- Direct Known Subclasses:
BsonSerializerSession,CborSerializerSession,MsgPackSerializerSession,ParquetSerializerSession,RdfStreamSerializerSession
SerializerSession for stream-based serializers.
Description
This class is the parent class of all byte-based serializers.It has 1 abstract method to implement...
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). -
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 OutputStreamSerializerSession.Builder<?>Creates a new builder for this object.protected SerializerPipecreatePipe(Object output) Wraps the specified output object into aSerializerPipeobject so that it can be easily converted into a stream or writer.protected final BinaryFormatBinary output format.booleanReturns whether this binary serializer has a native byte-array wire type.final booleanReturnstrue if this serializer subclasses fromWriterSerializer.final byte[]Convenience method for serializing an object to a.byte final StringShortcut method for serializing an object to a String.Methods inherited from class org.apache.juneau.marshall.serializer.SerializerSession
addVarBean, canIgnoreValue, canIgnoreValue, create, createBeanTypeNameProperty, createDefaultVarResolverSession, doWrite, 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, 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
get
-
Constructor Details
-
OutputStreamSerializerSession
Constructor.- Parameters:
builder- The builder for this object.
Cannot benull .
-
-
Method Details
-
create
Creates a new builder for this object.- Parameters:
ctx- The context creating this session.
Cannot benull .- Returns:
- A new builder.
-
isWriterSerializer
Description copied from class:SerializerSessionReturnstrue if this serializer subclasses fromWriterSerializer.- Overrides:
isWriterSerializerin classSerializerSession- Returns:
true if this serializer subclasses fromWriterSerializer.
-
write
Convenience method for serializing an object to a.byte - Overrides:
writein classSerializerSession- Parameters:
o- The object to serialize.- Returns:
- The output serialized to a byte array.
- Throws:
SerializeException- If a problem occurred trying to convert the output.
-
writeToString
Description copied from class:SerializerSessionShortcut method for serializing an object to a String.- Overrides:
writeToStringin classSerializerSession- Parameters:
o- The object to serialize.- Returns:
- The serialized object.
Character-based serializers will return aString
Stream-based serializers will return aconverted to a string based on thebyte []MarshallingContextable.Builder.binaryFormat(BinaryFormat)setting. - Throws:
SerializeException- If a problem occurred trying to convert the output.
-
createPipe
Description copied from class:SerializerSessionWraps the specified output object into aSerializerPipeobject so that it can be easily converted into a stream or writer.- Overrides:
createPipein classSerializerSession- Parameters:
output- The output location.
For character-based serializers, this can be any of the following types:WriterOutputStream- Output will be written as UTF-8 encoded stream.
For byte-based serializers, this must be anOutputStream.- Returns:
- A new
SerializerPipewrapper around the specified output object.
-
getBinaryFormat
Binary output format.- Returns:
- The format to use for the
writeToString(Object)method on stream-based serializers when converting byte arrays to strings. - See Also:
-
hasNativeBytes
Returns whether this binary serializer has a native byte-array wire type.When
true,byte[]payloads bypass the configuredBinaryFormatdispatch inBinarySwapand the variant binary swap installed byMarshalledPropertyPostProcessor, and are written as raw bytes through the serializer's native binary opcode (e.g. MsgPackbinfamily, CBOR byte-string major type 2, BSON binary subtype0x05). Whenfalse, the configuredBinaryFormatfires for non-NOT_SETformats and produces a text wire form (HEX / BASE64 / etc.) that the serializer emits as a string in its native string column / literal type — used by serializers whose wire format has no native byte-array primitive (Parquet column writer, binary RDF formats).Defaults to
true. Subclasses without a native byte-array wire type (e.g.ParquetSerializerSessionand the binary RDF sessions) override and returnfalse.- Returns:
trueif this serializer has a native byte-array wire type.
-