public class BeanTraverseSession extends BeanSession
BeanTraverseContext
.
Used by serializers and other classes that traverse POJOs for the following purposes:
This class is NOT thread safe. It is typically discarded after one-time use although it can be reused within the same thread.
Modifier and Type | Field and Description |
---|---|
int |
indent
The current indentation depth into the model.
|
Modifier | Constructor and Description |
---|---|
protected |
BeanTraverseSession(BeanTraverseContext ctx,
BeanSessionArgs args)
Create a new session using properties specified in the context.
|
Modifier and Type | Method and Description |
---|---|
protected int |
getInitialDepth()
Configuration property: Initial depth.
|
ObjectMap |
getLastLocation()
Returns information used to determine at what location in the parse a failure occurred.
|
protected int |
getMaxDepth()
Configuration property: Max traversal depth.
|
protected ClassMeta<?> |
getOptionalType(ClassMeta<?> cm)
Returns the inner type of an
Optional . |
protected Object |
getOptionalValue(Object o)
If the specified object is an
Optional , returns the inner object. |
protected String |
getStack(boolean full)
Returns the current stack trace.
|
protected boolean |
isDetectRecursions()
Configuration property: Automatically detect POJO recursions.
|
protected boolean |
isIgnoreRecursions()
Configuration property: Ignore recursion errors.
|
protected boolean |
isOptional(ClassMeta<?> cm)
Same as
ClassMeta.isOptional() but gracefully handles a null ClassMeta . |
protected void |
onError(Throwable t,
String msg,
Object... args)
Logs a warning message.
|
protected void |
pop()
Pop an object off the stack.
|
protected ClassMeta<?> |
push(String attrName,
Object o,
ClassMeta<?> eType)
Push the specified object onto the stack.
|
protected void |
setCurrentClass(ClassMeta<?> currentClass)
Sets the current class being traversed for proper error messages.
|
protected void |
setCurrentProperty(BeanPropertyMeta currentProperty)
Sets the current bean property being traversed for proper error messages.
|
ObjectMap |
toMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
protected boolean |
willRecurse(String attrName,
Object o,
ClassMeta<?> cm)
Returns
BeanTraverseContext.BEANTRAVERSE_detectRecursions is enabled, and the specified
object is already higher up in the traversal chain. |
_class, checkForWarnings, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionaryClasses, getBeanFieldVisibility, getBeanFilters, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getBpi, getBpro, getBpwo, getBpx, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getExamples, getImplClasses, getLocale, getMediaType, getNotBeanClasses, getNotBeanPackagesNames, getNotBeanPackagesPrefixes, getPojoSwaps, getPropertyNamer, getSchema, getStringBuilder, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isDebug, isFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnorePropertiesWithoutSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, object, returnStringBuilder, string, toArray, toBeanMap, toBeanMap
addToCache, addToCache, addWarning, getClassProperty, getFromCache, getInstanceArrayProperty, getInstanceProperty, getLogger, getProperties, getProperty, getProperty, getProperty, getPropertyKeys, getWarnings, hasProperty, hasWarnings, toString
public int indent
protected BeanTraverseSession(BeanTraverseContext ctx, BeanSessionArgs args)
ctx
- The context creating this session object.
The context contains all the configuration settings for this object.
Can be args
- Runtime arguments.
These specify session-level information such as locale and URI context.
It also include session-level properties that override the properties defined on the bean and
serializer contexts.protected final void setCurrentProperty(BeanPropertyMeta currentProperty)
currentProperty
- The current property being traversed.protected final void setCurrentClass(ClassMeta<?> currentClass)
currentClass
- The current class being traversed.protected final ClassMeta<?> push(String attrName, Object o, ClassMeta<?> eType) throws BeanRecursionException
attrName
- The attribute name.o
- The current object being traversed.eType
- The expected class type.ClassMeta
of the object so that BeanRecursionException
- If recursion occurred.protected final boolean willRecurse(String attrName, Object o, ClassMeta<?> cm) throws BeanRecursionException
BeanTraverseContext.BEANTRAVERSE_detectRecursions
is enabled, and the specified
object is already higher up in the traversal chain.attrName
- The bean property attribute name, or some other identifier.o
- The object to check for recursion.cm
- The metadata on the object class.BeanRecursionException
- If recursion occurred.protected final void pop()
protected final boolean isOptional(ClassMeta<?> cm)
ClassMeta.isOptional()
but gracefully handles a null ClassMeta
.cm
- The meta to check.Optional
.protected final ClassMeta<?> getOptionalType(ClassMeta<?> cm)
Optional
.cm
- The meta to check.Optional
.protected final Object getOptionalValue(Object o)
Optional
, returns the inner object.o
- The object to check.Optional
, protected void onError(Throwable t, String msg, Object... args)
t
- The throwable that was thrown (if there was one).msg
- The warning message.args
- Optional MessageFormat
-style arguments.protected String getStack(boolean full)
full
- If public final ObjectMap getLastLocation()
protected final boolean isDetectRecursions()
BeanTraverseContext.BEANTRAVERSE_detectRecursions
protected final boolean isIgnoreRecursions()
BeanRecursionException
is thrown with the message BeanTraverseContext.BEANTRAVERSE_ignoreRecursions
protected final int getInitialDepth()
BeanTraverseContext.BEANTRAVERSE_initialDepth
protected final int getMaxDepth()
BeanTraverseContext.BEANTRAVERSE_maxDepth
public ObjectMap toMap()
Session
toMap
in class BeanSession
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.