Package org.apache.juneau.marshall.uon
Class UonSerializerSession
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.uon.UonSerializerSession
- All Implemented Interfaces:
BeanSession,ConverterSession,HttpPartSerializerSession,RecordWritable
- Direct Known Subclasses:
OpenApiSerializerSession,UrlEncodingSerializerSession
public class UonSerializerSession
extends WriterSerializerSession
implements HttpPartSerializerSession, RecordWritable
Session object that lives for the duration of a single use of
UonSerializer.
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic UonSerializerSession.Builder<?>create(UonSerializer ctx) Creates a new builder for this object.protected voiddoWrite(SerializerPipe out, Object o) Serializes a POJO to the specified pipe.protected final ParamFormatFormat to use for query/form-data/header values.protected final UonWriterConverts the specified output target object to anUonWriter.final booleanAdd"_type" properties when needed.protected final booleanEncode non-valid URI characters.booleanStreaming-quality signal queryable before opening a cursor.write(HttpPartType type, HttpPartSchema schema, Object value) Converts the specified value to a string that can be used as an HTTP header value, query parameter value, form-data parameter, or URI path variable.protected UonWriterwriteAnything(UonWriter out, Object o, ClassMeta<?> eType, String attrName, BeanPropertyMeta pMeta) Workhorse method.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, 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
-
UonSerializerSession
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.
-
write
public String write(HttpPartType type, HttpPartSchema schema, Object value) throws SerializeException, SchemaValidationException Description copied from interface:HttpPartSerializerSessionConverts the specified value to a string that can be used as an HTTP header value, query parameter value, form-data parameter, or URI path variable.Returned values should NOT be URL-encoded.
- Specified by:
writein interfaceHttpPartSerializerSession- Parameters:
type- The category of value being serialized.schema- Schema information about the part.
May benull .
Not all part serializers use the schema information.value- The value being serialized.- Returns:
- The serialized value.
- Throws:
SerializeException- If a problem occurred while trying to parse the input.SchemaValidationException- If the output fails schema validation.
-
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.
-
getParamFormat
Format to use for query/form-data/header values.- Returns:
- Specifies the format to use for URL GET parameter keys and values.
- See Also:
-
getUonWriter
Converts the specified output target object to anUonWriter.- Parameters:
out- The output target object.
Must not benull .- Returns:
- The output target object wrapped in an
UonWriter.
-
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:
-
isEncoding
Encode non-valid URI characters.- Returns:
true if non-valid URI characters should be encoded with"%xx" constructs.- See Also:
-
writeAnything
protected UonWriter writeAnything(UonWriter out, Object o, ClassMeta<?> eType, String attrName, BeanPropertyMeta pMeta) throws SerializeException Workhorse method.Determines the type of object, and then calls the appropriate type-specific serialization method.
- Parameters:
out- The writer to serialize to.
Must not benull .o- The object being serialized.
Can benull (written as the UON null literal).eType- The expected type of the object if this is a bean property.
Can benull (defaults toObject).attrName- The bean property name if this is a bean property.null if this isn't a bean property being serialized.pMeta- The bean property metadata.
Can benull (bean-property-level URI detection is skipped).- Returns:
- The same writer passed in.
- Throws:
SerializeException- Generic serialization error occurred.
-