Class OutputStreamSerializer
java.lang.Object
org.apache.juneau.marshall.Context
org.apache.juneau.marshall.MarshallingContextable
org.apache.juneau.marshall.MarshallingTraverseContext
org.apache.juneau.marshall.serializer.Serializer
org.apache.juneau.marshall.serializer.OutputStreamSerializer
- All Implemented Interfaces:
Function<Object,,byte[]> ThrowingFunction<Object,byte[]>
- Direct Known Subclasses:
BsonSerializer,CborSerializer,ImageSerializer,MsgPackSerializer,ParquetSerializer,PetPhotoSerializer,RdfStreamSerializer
Subclass of
Serializer for byte-based serializers.
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class.static final classConcrete default builder leaf for the non-subclassedcreate()/Serializer.copy()path.Nested classes/interfaces inherited from class org.apache.juneau.marshall.serializer.Serializer
Serializer.Null -
Field Summary
Fields inherited from class org.apache.juneau.marshall.serializer.Serializer
accept, addBeanTypes, addRootType, keepNullProperties, listener, nonDefault, produces, sortCollections, sortMaps, trimEmptyCollections, trimEmptyMaps, trimStringsFields inherited from class org.apache.juneau.marshall.MarshallingContextable
marshallingContextFields inherited from class org.apache.juneau.marshall.Context
CONTEXT_APPLY_FILTER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOutputStreamSerializer(OutputStreamSerializer.Builder<?> builder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal byte[]Allows this serializer to be used as aThrowingFunctionthat converts an object to its serialized byte array form.static OutputStreamSerializer.Builder<?>create()Creates a new builder for this object.Create a session builder based on the properties defined on this context.protected final BinaryFormatBinary output format.Returns a session to use for this context.final booleanReturnstrue if this serializer subclasses fromWriterSerializer.final byte[]Convenience method for serializing an object to a.byte Methods inherited from class org.apache.juneau.marshall.serializer.Serializer
copy, createSerializerBuilder, doWrite, forEachAcceptMediaType, getListener, getMediaTypeRanges, getPrimaryMediaType, getResponseContentType, getResponseHeaders, getUriContext, getUriRelativity, getUriResolution, isAddBeanTypes, isAddRootType, isKeepNullProperties, isNonDefault, isSortCollections, isSortMaps, isTrimEmptyCollections, isTrimEmptyMaps, isTrimStrings, properties, write, writeToStringMethods inherited from class org.apache.juneau.marshall.MarshallingTraverseContext
getDetectRecursions, getIgnoreRecursions, getInitialDepth, getMaxDepth, isDetectRecursions, isIgnoreRecursions, shouldDetectRecursionsMethods inherited from class org.apache.juneau.marshall.MarshallingContextable
getDurationFormat, getMarshallingContext, getPeriodFormatMethods inherited from class org.apache.juneau.marshall.Context
createBuilder, getAnnotationProvider, init, 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.function.ThrowingFunction
apply
-
Constructor Details
-
OutputStreamSerializer
Constructor.- Parameters:
builder- The builder for this object.
Cannot benull .
-
-
Method Details
-
create
Creates a new builder for this object.- Returns:
- A new builder.
-
createSession
Description copied from class:ContextCreate a session builder based on the properties defined on this context.Use this method for creating sessions where you want to override basic settings. Otherwise, use
Context.getSession()directly.- Overrides:
createSessionin classSerializer- Returns:
- A new session builder.
-
getSession
Description copied from class:ContextReturns a session to use for this context.Note that subclasses may opt to return a reusable non-modifiable session.
- Overrides:
getSessionin classSerializer- Returns:
- A new session object.
-
isWriterSerializer
Description copied from class:SerializerReturnstrue if this serializer subclasses fromWriterSerializer.- Overrides:
isWriterSerializerin classSerializer- Returns:
true if this serializer subclasses fromWriterSerializer.
-
write
Convenience method for serializing an object to a.byte - Overrides:
writein classSerializer- 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.
-
applyThrows
Allows this serializer to be used as aThrowingFunctionthat converts an object to its serialized byte array form.Because
OutputStreamSerializerimplementsThrowingFunction<Object,byte[]>, a serializer instance can be passed directly wherever aFunctionorThrowingFunctionis expected (e.g. assertion transform methods).- Specified by:
applyThrowsin interfaceThrowingFunction<Object,byte[]> - Parameters:
o- The object to serialize.- Returns:
- The output serialized to a byte array.
- Throws:
Exception- If a problem occurred trying to convert the output.
-
getBinaryFormat
Binary output format.Resolves from the configured
MarshallingContext.getBinaryFormat().- Returns:
- The binary wire format used by this serializer.
-