Class SerializerSession
- All Implemented Interfaces:
BeanSession,ConverterSession
- Direct Known Subclasses:
OutputStreamSerializerSession,WriterSerializerSession
Serializer.
Used by serializers for the following purposes:
- Keeping track of how deep it is in a model for indentation purposes.
- Ensuring infinite loops don't occur by setting a limit on how deep to traverse a model.
- Ensuring infinite loops don't occur from loops in the model (when detectRecursions is enabled.
- Allowing serializer properties to be overridden on method calls.
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
ConstructorsModifierConstructorDescriptionprotectedSerializerSession(SerializerSession.Builder<?> builder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddVarBean(Class<T> c, T value) Adds a session object to theVarResolverSessionin this session.final booleancanIgnoreValue(BeanPropertyMeta pMeta, String attrName, Object value) Per-bean-property variant ofcanIgnoreValue(ClassMeta, String, Object).final booleancanIgnoreValue(ClassMeta<?> cm, String attrName, Object value) Returnstrue if the specified value should not be serialized.static SerializerSession.Builder<?>create(Serializer ctx) Creates a new builder for this object.protected static final BeanPropertyValuecreateBeanTypeNameProperty(BeanMap<?> m, String typeName) Create a "_type" property that contains the dictionary name of the bean.protected VarResolverSessionAdds a session object to theVarResolverSessionin this session.protected SerializerPipecreatePipe(Object output) Wraps the specified output object into aSerializerPipeobject so that it can be easily converted into a stream or writer.protected voiddoWrite(SerializerPipe pipe, Object o) Serializes a POJO to the specified pipe.final <E> voidforEachEntry(Collection<E> c, Consumer<E> consumer) Consumes each entry in the list.final <K,V> void forEachEntry(Map<K, V> m, Consumer<Map.Entry<K, V>> consumer) Consumes each map entry in the map.final voidforEachStreamableEntry(Object o, ClassMeta<?> type, Consumer consumer) Iterates over a streamable object (Iterator, Iterable, or Stream), consuming each entry.protected final Objectgeneralize(Object o, ClassMeta<?> type) Generalize the specified object if a POJO swap is associated with it.protected final StringgetBeanTypeName(SerializerSession session, ClassMeta<?> eType, ClassMeta<?> aType, BeanPropertyMeta pMeta) Resolves the dictionary name for the actual type.protected final CalendarFormatReturns the configured default calendar wire format.protected final DateFormatReturns the configured default date wire format.protected final DurationFormatReturns the configured default duration wire format.protected final ClassMeta<?>Returns the parser-side expected type for the object.protected final MethodReturns the Java method that invoked this serializer.Returns the listener associated with this session.<T extends SerializerListener>
TgetListener(Class<T> c) Returns the listener associated with this session.protected final LocaleFormatReturns the configured default locale wire format.protected final PeriodFormatReturns the configured default period wire format.Optional method that specifies HTTP request headers for this serializer.final HttpPartSchemaHTTP part schema of object being serialized.protected final TemporalFormatReturns the configured default temporal wire format.protected final TimeZoneFormatReturns the configured default time-zone wire format.protected final UriContextURI context bean.protected final UriRelativityURI relativity.protected final UriResolutionURI resolution.protected final UriResolverReturns the URI resolver.Returns the variable resolver session.protected static <T extends Throwable>
voidhandleThrown(T causedBy) Converts the specified throwable to either aRuntimeExceptionorSerializeException.protected booleanAdd"_type" properties when needed.protected final booleanAdd type attribute to root nodes.protected final booleanDon't trim null bean property values.protected final booleanDon't serialize bean properties whose values equal the default for their type.protected final booleanSort arrays and collections alphabetically.protected final booleanSort maps alphabetically.protected final booleanTrim empty lists and arrays.protected final booleanTrim empty maps.protected booleanTrim strings.booleanReturnstrue if this serializer subclasses fromWriterSerializer.protected final voidSpecialized warning when an exception is thrown while executing a bean getter.protected voidLogs a warning message.Returns the properties on this bean as a map for debugging.protected final ClassMeta<?>Same asMarshallingTraverseSession.push(String, Object, ClassMeta)but wrapsMarshallingRecursionExceptioninsideSerializeException.protected final StringrelativizeUri(Object relativeTo, Object uri) Opposite ofresolveUri(Object).Resolves any variables in the specified string.final StringresolveUri(Object uri) Converts a String to an absolute URI based on theUriContexton this session.final <E> Collection<E>sort(Collection<E> c) Sorts the specified collection ifisSortCollections()returnstrue .final <E> List<E>Sorts the specified collection ifisSortCollections()returnstrue .final <K,V> Map<K, V> Sorts the specified map ifisSortMaps()returnstrue .protected Objectswap(ObjectSwap swap, Object o) Invokes the specified swap on the specified object if the swap is not null.Converts the contents of the specified object array to a list.toListFromStreamable(Object o, ClassMeta<?> type) Converts a streamable object (Iterator, Iterable, or Stream) to a List.final StringConverts the specified object to aString .final StringTrims the specified string ifisTrimStrings()returnstrue .protected final ObjectunwrapSupplier(Object o, int depth) Recursively unwraps nestedSupplierchains to their underlying value.Shortcut method for serializing objects directly to either aString ordepending on the serializer type.byte []final voidSerialize the specified object using the specified session.protected final StringwriteCalendar(Object c, ClassMeta<?> cm) Formats aCalendarorXMLGregorianCalendarvalue using this session's configured calendar format and time zone.protected final Stringprotected final StringFormats aDurationvalue using this session's configured duration format.protected final StringFormats aPeriodvalue using this session's configured period format.protected final StringwriteTemporal(TemporalAccessor t, ClassMeta<?> cm) Shortcut method for serializing an object to a String.Methods 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
-
SerializerSession
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.
-
createBeanTypeNameProperty
Create a "_type" property that contains the dictionary name of the bean.- Parameters:
m- The bean map to create a class property on.
Must not benull .typeName- The type name of the bean.
Can benull (the created property's value isnull ).- Returns:
- A new bean property value.
-
handleThrown
Converts the specified throwable to either aRuntimeExceptionorSerializeException.- Type Parameters:
T- The throwable type.- Parameters:
causedBy- The exception to cast or wrap.
Must not benull .
-
toList
Converts the contents of the specified object array to a list.Works on both object and primitive arrays.
In the case of multi-dimensional arrays, the outgoing list will contain elements of type n-1 dimension. i.e. if
typeisthenint [][]listwill have entries of type.int []- Parameters:
type- The type of array.
Must not benull .array- The array being converted.
Must not benull .- Returns:
- The array as a list.
-
addVarBean
Adds a session object to theVarResolverSessionin this session.- Type Parameters:
T- The bean type.- Parameters:
c- The bean type being added.value- The bean being added.- Returns:
- This object.
-
canIgnoreValue
public final boolean canIgnoreValue(ClassMeta<?> cm, String attrName, Object value) throws SerializeException Returnstrue if the specified value should not be serialized.A value is also omitted (dropped) when it would exceed
maxDepth(viaMarshallingTraverseSession.willExceedDepth()) — over-depth values are silently truncated from the output rather than throwing. ExceedingmaxDepth is a size guard, not a cycle detector; whendetectRecursionsis enabled, an actual recursion instead throws aSerializeException.- Parameters:
cm- The class type of the object being serialized.
Can benull (treated as theObjecttype).attrName- The bean attribute name, ornull if this isn't a bean attribute.value- The object being serialized.
Can benull , in which case the result depends onkeepNullProperties(ignored unless that setting is enabled).- Returns:
true if the specified value should not be serialized.- Throws:
SerializeException- If recursion occurred.
-
canIgnoreValue
public final boolean canIgnoreValue(BeanPropertyMeta pMeta, String attrName, Object value) throws SerializeException Per-bean-property variant ofcanIgnoreValue(ClassMeta, String, Object).Applies the same standard inclusion rules (
keepNullProperties,trimEmptyCollections/trimEmptyMaps, recursion detection), then additionally:- Treats
Optional.empty()(and its primitive cousinsOptionalInt/OptionalLong/OptionalDouble) as anull property value for inclusion purposes — the shared Optional/absent contract. - Applies
nonDefaultby comparing the surviving value against a cached reference instance of the property's containing bean. When no reference instance can be built (no accessible no-arg ctor / instantiation throws),nonDefaultis silently skipped for that bean — the property is emitted normally rather than failing.
Precedence (first "omit" wins): (1)
null / empty Optional, (2) trimEmpty*, (3) value-equals-default.- Parameters:
pMeta- The bean property meta for the value being considered. Must not benull .attrName- The bean attribute name. Must not benull .value- The current property value.
Can benull (treated as an absent value; whether it's omitted depends onkeepNullProperties).- Returns:
true if the property should be omitted from the output.- Throws:
SerializeException- If recursion occurred.- Since:
- 10.0.0
- Treats
-
forEachEntry
Consumes each entry in the list.- Type Parameters:
E- The element type.- Parameters:
c- The collection being sorted.consumer- The entry consumer.
-
forEachEntry
Consumes each map entry in the map.- Type Parameters:
K- The key type.V- The value type.- Parameters:
m- The map being consumed.consumer- The map entry consumer.
-
forEachStreamableEntry
Iterates over a streamable object (Iterator, Iterable, or Stream), consuming each entry.For collections, delegates to
forEachEntry(Collection, Consumer)which supports sorting. For other streamable types, iterates lazily without materializing into a List.- Parameters:
o- The streamable object.type- The class meta for the object.consumer- The entry consumer.- Since:
- 9.2.1
-
toListFromStreamable
Converts a streamable object (Iterator, Iterable, or Stream) to a List.Used by serializers that need to know the collection size or inspect elements before serializing (e.g. MsgPack, HTML, CSV).
- Parameters:
o- The streamable object.type- The class meta for the object.- Returns:
- A new list containing all elements.
- Since:
- 9.2.1
-
getListener
Returns the listener associated with this session.- Returns:
- The listener associated with this session, or
null if there is no listener.
-
getListener
Returns the listener associated with this session.- Type Parameters:
T- The listener type.- Parameters:
c- The listener class to cast to.- Returns:
- The listener associated with this session, or
null if there is no listener.
-
getResponseHeaders
Optional method that specifies HTTP request headers for this serializer.For example,
SoapXmlSerializerneeds to set aSOAPAction header.This method is typically meaningless if the serializer is being used stand-alone (i.e. outside of a REST server or client).
The default implementation of this method simply calls
Serializer.getResponseHeaders(SerializerSession).- Returns:
- The HTTP headers to set on HTTP requests.
Never
null .
-
getSchema
HTTP part schema of object being serialized.- Returns:
- HTTP part schema of object being serialized, or
null if not specified.
-
getVarResolver
Returns the variable resolver session.- Returns:
- The variable resolver session.
-
isWriterSerializer
Returnstrue if this serializer subclasses fromWriterSerializer.- Returns:
true if this serializer subclasses fromWriterSerializer.
-
resolve
Resolves any variables in the specified string.- Parameters:
string- The string to resolve values in.- Returns:
- The string with variables resolved.
-
resolveUri
Converts a String to an absolute URI based on theUriContexton this session.- Parameters:
uri- The input URI. Can be any of the following: URI can be any of the following forms:"foo://foo" - Absolute URI."/foo" - Root-relative URI."/" - Root URI."context:/foo" - Context-root-relative URI."context:/" - Context-root URI."servlet:/foo" - Servlet-path-relative URI."servlet:/" - Servlet-path URI."request:/foo" - Request-path-relative URI."request:/" - Request-path URI."foo" - Path-info-relative URI."" - Path-info URI.
- Returns:
- The resolved URI.
-
write
Shortcut method for serializing objects directly to either aString ordepending on the serializer type.byte []- Parameters:
o- The object to serialize.- Returns:
- The serialized object.
Character-based serializers will return aString .
Stream-based serializers will return a.byte [] - Throws:
SerializeException- If a problem occurred trying to convert the output.
-
write
Serialize the specified object using the specified session.- Parameters:
out- Where to send the output from the serializer.o- The object to serialize.- Throws:
SerializeException- If a problem occurred trying to convert the output.IOException- Thrown by the underlying stream.
-
unwrapSupplier
Recursively unwraps nestedSupplierchains to their underlying value.Supports chains of the form
Supplier<Supplier<T>>→Twith a maximum depth of 10 to prevent infinite loops. Note thatBeanSupplierinstances are NOT unwrapped here — they are treated asIterablesequences by the serializer.- Parameters:
o- The object to unwrap.depth- The current recursion depth (must be 0 on initial call).- Returns:
- The unwrapped value, or the original object if it is not a
Supplier. - Throws:
SerializeException- If theSupplierchain exceeds 10 levels.
-
writeToString
Shortcut method for serializing an object to a String.- 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.
-
sort
Sorts the specified collection ifisSortCollections()returnstrue .- Type Parameters:
E- The element type.- Parameters:
c- The collection being sorted.
Can benull (returnsnull unchanged).- Returns:
- The sorted collection, or the input collection unchanged if sorting is disabled or the collection isn't sortable.
-
sort
Sorts the specified collection ifisSortCollections()returnstrue .- Type Parameters:
E- The element type.- Parameters:
c- The collection being sorted.
Can benull (returnsnull unchanged).- Returns:
- The sorted list, or the input list unchanged if sorting is disabled or the list isn't sortable.
-
sort
Sorts the specified map ifisSortMaps()returnstrue .- Type Parameters:
K- The key type.V- The value type.- Parameters:
m- The map being sorted.
Can benull (returnsnull unchanged).- Returns:
- A new sorted
TreeMap, or the input map unchanged if sorting is disabled or the keys aren't sortable.
-
toString
Converts the specified object to aString .Also has the following effects:
Class object is converted to a readable name. SeeClassInfo.getNameFull().- Whitespace is trimmed if the trim-strings setting is enabled.
- Parameters:
o- The object to convert to aString .- Returns:
- The object converted to a String, or
null if the input wasnull .
-
writeDuration
Formats aDurationvalue using this session's configured duration format.- Parameters:
d- The value to format.null returnsnull .- Returns:
- The formatted value, or
null ifdisnull .
-
writePeriod
Formats aPeriodvalue using this session's configured period format.- Parameters:
p- The value to format.null returnsnull .- Returns:
- The formatted value, or
null ifpisnull .
-
writeDate
- Parameters:
d- The value to format.null returnsnull .cm- The class metadata for the value (kept for symmetry withIso8601Utils.formatDate(java.util.Date, org.apache.juneau.marshall.ClassMeta<?>, org.apache.juneau.marshall.DateFormat, java.util.TimeZone)).- Returns:
- The formatted value, or
null ifdisnull .
-
writeCalendar
Formats aCalendarorXMLGregorianCalendarvalue using this session's configured calendar format and time zone.XMLGregorianCalendarvalues always emit theirXMLGregorianCalendar.toXMLFormat()form regardless of the configured format, mirroring the parse-side rule.- Parameters:
c- The value to format. Must be aCalendarorXMLGregorianCalendar.null returnsnull .cm- The class metadata for the value (kept for symmetry withIso8601Utils.formatCalendar(java.lang.Object, org.apache.juneau.marshall.ClassMeta<?>, org.apache.juneau.marshall.CalendarFormat, java.util.TimeZone)).- Returns:
- The formatted value, or
null ifcisnull .
-
writeTemporal
- Parameters:
t- The value to format. Must be aTemporalsubtype.null returnsnull .cm- The class metadata for the value (kept for symmetry withIso8601Utils.formatTemporal(java.time.temporal.TemporalAccessor, org.apache.juneau.marshall.ClassMeta<?>, org.apache.juneau.marshall.TemporalFormat, java.util.TimeZone)).- Returns:
- The formatted value, or
null iftisnull .
-
trim
Trims the specified string ifisTrimStrings()returnstrue .- Parameters:
o- The input string to trim.- Returns:
- The trimmed string, or
null if the input wasnull .
-
createDefaultVarResolverSession
Adds a session object to theVarResolverSessionin this session.- Returns:
- This object.
-
createPipe
Wraps the specified output object into aSerializerPipeobject so that it can be easily converted into a stream or writer.- 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.
-
doWrite
Serializes 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).- Parameters:
pipe- 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.
-
generalize
Generalize the specified object if a POJO swap is associated with it.- Parameters:
o- The object to generalize.
Can benull (returnsnull ).type- The type of object.
Can benull (the object's actual runtime class's swap, if any, is used instead).- Returns:
- The generalized object, or
null if the object isnull . - Throws:
SerializeException- If a problem occurred trying to convert the output.
-
getBeanTypeName
protected final String getBeanTypeName(SerializerSession session, ClassMeta<?> eType, ClassMeta<?> aType, BeanPropertyMeta pMeta) Resolves the dictionary name for the actual type.- Parameters:
session- The current serializer session.eType- The expected type of the bean property.aType- The actual type of the bean property.pMeta- The current bean property being serialized.
Can benull (the bean-property-level dictionary lookup tier is skipped).- Returns:
- The bean dictionary name, or
null if a name could not be found.
-
getExpectedRootType
Returns the parser-side expected type for the object.The return value depends on the
Serializer.Builder.addRootType()setting. When disabled, the parser already knows the Java POJO type being parsed, so there is no reason to add"_type" attributes to the root-level object.- Parameters:
o- The object to get the expected type on.
Can benull (returnsnull unless root typing is enabled, in which case the genericObjecttype is returned).- Returns:
- The expected type, or
null if the object wasnull and root typing is disabled.
-
getJavaMethod
Returns the Java method that invoked this serializer.When using the REST API, this is the Java method invoked by the REST call. Can be used to access annotations defined on the method or class.
- Returns:
- The Java method that invoked this serializer, or
null if not specified.
-
getUriContext
URI context bean.- Returns:
- Bean used for resolution of URIs to absolute or root-relative form.
- See Also:
-
getUriRelativity
URI relativity.- Returns:
- Defines what relative URIs are relative to when serializing any of the following:
- See Also:
-
getUriResolution
URI resolution.- Returns:
- Defines the resolution level for URIs when serializing URIs.
- See Also:
-
getDurationFormat
Returns the configured default duration wire format.- Returns:
- The configured default duration wire format.
-
getPeriodFormat
Returns the configured default period wire format.- Returns:
- The configured default period wire format.
-
getCalendarFormat
Returns the configured default calendar wire format.- Returns:
- The configured default calendar wire format.
-
getDateFormat
Returns the configured default date wire format.- Returns:
- The configured default date wire format.
-
getTemporalFormat
Returns the configured default temporal wire format.- Returns:
- The configured default temporal wire format.
-
getTimeZoneFormat
Returns the configured default time-zone wire format.- Returns:
- The configured default time-zone wire format.
-
getLocaleFormat
Returns the configured default locale wire format.- Returns:
- The configured default locale wire format.
-
getUriResolver
Returns the URI resolver.- Returns:
- The URI resolver.
-
isAddBeanTypes
Add"_type" properties when needed.- Returns:
true if"_type" properties added to beans if their type cannot be inferred through reflection.- See Also:
-
isAddRootType
Add type attribute to root nodes.- Returns:
true if type property should be added to root node.- See Also:
-
isKeepNullProperties
Don't trim null bean property values.- Returns:
true if null bean values are serialized to the output.- See Also:
-
isNonDefault
Don't serialize bean properties whose values equal the default for their type.- Returns:
true if bean properties whose value equals the type / bean-constructed default are omitted.- Since:
- 10.0.0
- See Also:
-
isSortCollections
Sort arrays and collections alphabetically.- Returns:
true if arrays and collections are copied and sorted before serialization.- See Also:
-
isSortMaps
Sort maps alphabetically.- Returns:
true if maps are copied and sorted before serialization.- See Also:
-
isTrimEmptyCollections
Trim empty lists and arrays.- Returns:
true if empty lists and arrays are not serialized to the output.- See Also:
-
isTrimEmptyMaps
Trim empty maps.- Returns:
true if empty map values are not serialized to the output.- See Also:
-
isTrimStrings
Trim strings.- Returns:
true if string values will be trimmed of whitespace usingString.trim()before being serialized.- See Also:
-
onBeanGetterException
protected final void onBeanGetterException(BeanPropertyMeta p, Throwable t) throws SerializeException Specialized warning when an exception is thrown while executing a bean getter.- Parameters:
p- The bean map entry representing the bean property.
Must not benull .t- The throwable that the bean getter threw.- Throws:
SerializeException- Thrown if ignoreInvocationExceptionOnGetters is false.
-
onError
Logs a warning message.- Overrides:
onErrorin classMarshallingTraverseSession- Parameters:
t- The throwable that was thrown (if there was one).msg- The warning message.args- OptionalString.format-style arguments.
-
properties
Description copied from class:ContextSessionReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classMarshallingTraverseSession- Returns:
- The properties on this bean as a map for debugging.
-
push2
protected final ClassMeta<?> push2(String attrName, Object o, ClassMeta<?> eType) throws SerializeException Same asMarshallingTraverseSession.push(String, Object, ClassMeta)but wrapsMarshallingRecursionExceptioninsideSerializeException.- Parameters:
attrName- The attribute name.
Can benull for unnamed entries (e.g. array elements); used only for stack-trace labeling.o- The current object being traversed.
Can benull (returnsnull ).eType- The expected class type.
Can benull , in which case the object's actual runtime type is used instead.- Returns:
- The
ClassMetaof the object so thatinstanceof operations only need to be performed once (since they can be expensive). - Throws:
SerializeException- If recursion occurred.
-
relativizeUri
Opposite ofresolveUri(Object).Converts the URI to a value relative to the specified
relativeTo parameter.Both parameters can be any of the following:
Both URIs can be any of the following forms:
"foo://foo" - Absolute URI."/foo" - Root-relative URI."/" - Root URI."context:/foo" - Context-root-relative URI."context:/" - Context-root URI."servlet:/foo" - Servlet-path-relative URI."servlet:/" - Servlet-path URI."request:/foo" - Request-path-relative URI."request:/" - Request-path URI."foo" - Path-info-relative URI."" - Path-info URI.
- Parameters:
relativeTo- The URI to relativize against.uri- The URI to relativize.- Returns:
- The relativized URI.
-
swap
Invokes the specified swap on the specified object if the swap is not null.- Parameters:
swap- The swap to invoke. Can benull (no-op; the input object is returned unchanged).o- The input object.- Returns:
- The swapped object.
- Throws:
SerializeException- If swap method threw an exception.
-