net.sf.mmm.util.pojo.path.base
Class AbstractPojoPathNavigator

java.lang.Object
  extended by net.sf.mmm.util.component.base.AbstractComponent
      extended by net.sf.mmm.util.component.base.AbstractLoggableComponent
          extended by net.sf.mmm.util.pojo.path.base.AbstractPojoPathNavigator
All Implemented Interfaces:
PojoPathNavigator
Direct Known Subclasses:
PojoPathNavigatorImpl

public abstract class AbstractPojoPathNavigator
extends AbstractLoggableComponent
implements PojoPathNavigator

This is the abstract base implementation of the PojoPathNavigator.

Since:
1.1.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Nested Class Summary
protected static class AbstractPojoPathNavigator.CachingPojoPath
          This class represents a PojoPath.
protected static class AbstractPojoPathNavigator.PojoPathCache
          This inner class represents the cache for AbstractPojoPathNavigator.CachingPojoPaths based on an initial Pojo.
protected static class AbstractPojoPathNavigator.PojoPathState
          This inner class represents the state for a PojoPath evaluation.
 
Field Summary
private  CollectionReflectionUtil collectionReflectionUtil
           
private  PojoPathFunctionManager functionManager
           
private static String PATH_SUFFIX_COLLECTION_LIST
          The reserved PojoPath-suffix used to cache a CollectionList.
private  PojoFactory pojoFactory
           
private  ReflectionUtil reflectionUtil
           
private  ComposedValueConverter valueConverter
           
 
Constructor Summary
AbstractPojoPathNavigator()
          The constructor.
 
Method Summary
protected  Object convert(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, Object pojo, Class<?> targetClass, GenericType<?> targetType)
          This method converts the given pojo to the given targetClass (or even targetType) as necessary.
protected  Object convertList(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state, Object arrayOrCollection)
          This method converts the given arrayOrCollection to a List as necessary.
protected  Object create(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state, Class<?> pojoClass)
          This method creates a Pojo of the given pojoType.
protected  AbstractPojoPathNavigator.PojoPathState createState(Object initialPojo, String pojoPath, PojoPathMode mode, PojoPathContext context)
          This method gets the AbstractPojoPathNavigator.PojoPathState for the given context.
protected  AbstractPojoPathNavigator.PojoPathState createStateByType(GenericType initialPojoType, String pojoPath, PojoPathMode mode, PojoPathContext context)
          This method gets the AbstractPojoPathNavigator.PojoPathState for the given context.
protected  void doInitialize()
          This method performs the actual initialization.
protected  Object get(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state)
          This method gets the value for the single segment of the given currentPath from the pojo of its parent.
 Object get(Object pojo, String pojoPath, PojoPathMode mode, PojoPathContext context)
          This method evaluates the given pojoPath for the given pojo using the given mode and context.
<TYPE> TYPE
get(Object pojo, String pojoPath, PojoPathMode mode, PojoPathContext context, Class<TYPE> targetClass)
          This method evaluates the given pojoPath for the given pojo using the given mode and context.
 CollectionReflectionUtil getCollectionReflectionUtil()
          This method gets the CollectionReflectionUtil instance to use.
protected  Object getFromFunction(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state, PojoPathFunction function)
          This method gets the single segment of the given currentPath from the Pojo given by parentPojo.
protected  Object getFromList(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state, int index)
          This method gets the single segment of the given currentPath from the array or List given by parentPojo.
protected  Object getFromMap(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state, Map parentPojo)
          This method gets the single segment of the given currentPath from the Map given by parentPojo.
protected abstract  Object getFromPojo(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state)
          This method reflectively gets the single segment of the given currentPath from the Pojo given by parentPojo.
protected  PojoPathFunction getFunction(String functionName, PojoPathContext context)
          This method gets the PojoPathFunction for the given functionName.
protected  PojoPathFunctionManager getFunctionManager()
          This method gets the optional PojoPathFunctionManager for PojoPathFunctions that are global for this PojoPathNavigator instance.
protected  PojoFactory getPojoFactory()
          This method gets the PojoFactory instance used to create new Pojos.
protected  AbstractPojoPathNavigator.CachingPojoPath getRecursive(String pojoPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state)
          This method recursively navigates the given pojoPath.
 ReflectionUtil getReflectionUtil()
          This method gets the ReflectionUtil instance to use.
 GenericType<?> getType(GenericType<?> pojoType, String pojoPath, boolean failOnUnsafePath, PojoPathContext context)
          This method determines the result-type for the given pojoPath starting at the given pojoType using the given context.
 GenericType<?> getType(Type pojoType, String pojoPath, boolean failOnUnsafePath, PojoPathContext context)
          This method determines the result-type for the given pojoPath starting at the given pojoType using the given context.
protected  ComposedValueConverter getValueConverter()
          This method gets the ComposedValueConverter used by default to convert values that are NOT compatible.
 Map<String,Object> pojo2Map(Object pojo)
          This method creates a lazy, immutable Map reflecting the given Pojo.
 Map<String,Object> pojo2Map(Object pojo, PojoPathContext context)
          This method creates a lazy, immutable Map reflecting the given Pojo.
protected  Object set(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state, Object parentPojo, Object value)
          This method sets the single segment of the given currentPath from the Pojo given by parentPojo.
 Object set(Object pojo, String pojoPath, PojoPathMode mode, PojoPathContext context, Object value)
          This method sets the given value for the given pojoPath in the given pojo using the given mode and context.
 void setCollectionReflectionUtil(CollectionReflectionUtil collectionUtil)
           
 void setFunctionManager(PojoPathFunctionManager functionManager)
          This method sets the function-manager used for global PojoPathFunctions.
protected  Object setInList(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state, Object parentPojo, Object value, int index)
          This method sets the single segment of the given currentPath from the array or List given by parentPojo.
protected abstract  Object setInPojo(AbstractPojoPathNavigator.CachingPojoPath currentPath, PojoPathContext context, AbstractPojoPathNavigator.PojoPathState state, Object parentPojo, Object value)
          This method sets the single segment of the given currentPath from the Pojo given by parentPojo.
 void setPojoFactory(PojoFactory pojoFactory)
          This method sets the PojoFactory to use.
 void setReflectionUtil(ReflectionUtil reflectionUtil)
           
 void setValueConverter(ComposedValueConverter valueConverter)
          This method sets the value-converter used by default.
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent
getLogger, setLogger
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent
doInitialized, getInitializationState, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_SUFFIX_COLLECTION_LIST

private static final String PATH_SUFFIX_COLLECTION_LIST
The reserved PojoPath-suffix used to cache a CollectionList.

See Also:
Constant Field Values

reflectionUtil

private ReflectionUtil reflectionUtil
See Also:
getReflectionUtil()

collectionReflectionUtil

private CollectionReflectionUtil collectionReflectionUtil
See Also:
getCollectionReflectionUtil()

functionManager

private PojoPathFunctionManager functionManager
See Also:
getFunctionManager()

valueConverter

private ComposedValueConverter valueConverter
See Also:
getValueConverter()

pojoFactory

private PojoFactory pojoFactory
See Also:
getPojoFactory()
Constructor Detail

AbstractPojoPathNavigator

public AbstractPojoPathNavigator()
The constructor.

Method Detail

getFunctionManager

protected PojoPathFunctionManager getFunctionManager()
This method gets the optional PojoPathFunctionManager for PojoPathFunctions that are global for this PojoPathNavigator instance.
ATTENTION:
PojoPathFunctions provided by this PojoPathFunctionManager need to be stateless / thread-safe.

Returns:
the PojoPathFunctionManager or null if NOT available.

setFunctionManager

@Inject
public void setFunctionManager(PojoPathFunctionManager functionManager)
This method sets the function-manager used for global PojoPathFunctions.

Parameters:
functionManager - is the PojoPathFunctionManager.

getValueConverter

protected ComposedValueConverter getValueConverter()
This method gets the ComposedValueConverter used by default to convert values that are NOT compatible.

Returns:
the valueConverter
See Also:
PojoPathContext.getAdditionalConverter()

setValueConverter

@Inject
public void setValueConverter(ComposedValueConverter valueConverter)
This method sets the value-converter used by default.

Parameters:
valueConverter - is the ComposedValueConverter to set.

getCollectionReflectionUtil

public CollectionReflectionUtil getCollectionReflectionUtil()
This method gets the CollectionReflectionUtil instance to use.

Returns:
the CollectionReflectionUtil to use.

setCollectionReflectionUtil

@Inject
public void setCollectionReflectionUtil(CollectionReflectionUtil collectionUtil)
Parameters:
collectionUtil - is the collectionUtil to set

getReflectionUtil

public ReflectionUtil getReflectionUtil()
This method gets the ReflectionUtil instance to use.

Returns:
the ReflectionUtil to use.

setReflectionUtil

@Inject
public void setReflectionUtil(ReflectionUtil reflectionUtil)
Parameters:
reflectionUtil - is the reflectionUtil to set

getPojoFactory

protected PojoFactory getPojoFactory()
This method gets the PojoFactory instance used to create new Pojos.

Returns:
the PojoFactory to use.
See Also:
PojoPathContext.getPojoFactory()

setPojoFactory

@Inject
public void setPojoFactory(PojoFactory pojoFactory)
This method sets the PojoFactory to use.

Parameters:
pojoFactory - is the PojoFactory to use.

doInitialize

protected void doInitialize()
This method performs the actual initialization. It is called when AbstractComponent.initialize() is invoked for the first time.
ATTENTION:
When you override this method from a sub-class you need to do a super.AbstractComponent.doInitialize().

Overrides:
doInitialize in class AbstractLoggableComponent

createState

protected AbstractPojoPathNavigator.PojoPathState createState(Object initialPojo,
                                                              String pojoPath,
                                                              PojoPathMode mode,
                                                              PojoPathContext context)
This method gets the AbstractPojoPathNavigator.PojoPathState for the given context.

Parameters:
initialPojo - is the initial Pojo this PojoPathNavigator was invoked with.
pojoPath - is the PojoPath to navigate.
mode - is the mode that determines how to deal null values.
context - is the context for this operation.
Returns:
the AbstractPojoPathNavigator.PojoPathState or null if caching is disabled.

createStateByType

protected AbstractPojoPathNavigator.PojoPathState createStateByType(GenericType initialPojoType,
                                                                    String pojoPath,
                                                                    PojoPathMode mode,
                                                                    PojoPathContext context)
This method gets the AbstractPojoPathNavigator.PojoPathState for the given context.

Parameters:
initialPojoType - is the initial pojo-type this PojoPathNavigator was invoked with.
pojoPath - is the PojoPath to navigate.
mode - is the mode that determines how to deal with unsafe PojoPath s.
context - is the context for this operation.
Returns:
the AbstractPojoPathNavigator.PojoPathState or null if caching is disabled.

get

public Object get(Object pojo,
                  String pojoPath,
                  PojoPathMode mode,
                  PojoPathContext context)
This method evaluates the given pojoPath for the given pojo using the given mode and context. It returns the result of the evaluation.
ATTENTION:
If you use caching for repetitive calls on the same initial pojo, you might get wrong results if intermediate objects have changed outside this navigator in the meantime.

Specified by:
get in interface PojoPathNavigator
Parameters:
pojo - is the initial Pojo to operate on.
pojoPath - is the PojoPath to navigate.
mode - is the mode that determines how to deal with null values.
context - is the PojoPathContext for this operation.
Returns:
the result of the navigation of the given pojoPath starting at the given pojo. It may be null according to the given mode.

get

public <TYPE> TYPE get(Object pojo,
                       String pojoPath,
                       PojoPathMode mode,
                       PojoPathContext context,
                       Class<TYPE> targetClass)
This method evaluates the given pojoPath for the given pojo using the given mode and context. It returns the result of the evaluation.
ATTENTION:
If you use caching for repetitive calls on the same initial pojo, you might get wrong results if intermediate objects have changed outside this navigator in the meantime.

Specified by:
get in interface PojoPathNavigator
Type Parameters:
TYPE - is the generic type of the result.
Parameters:
pojo - is the initial Pojo to operate on.
pojoPath - is the PojoPath to navigate.
mode - is the mode that determines how to deal with null values.
context - is the PojoPathContext for this operation.
targetClass - is the required result-type.
Returns:
the result of the navigation of the given pojoPath starting at the given pojo. It may be null according to the given mode.

getRecursive

protected AbstractPojoPathNavigator.CachingPojoPath getRecursive(String pojoPath,
                                                                 PojoPathContext context,
                                                                 AbstractPojoPathNavigator.PojoPathState state)
This method recursively navigates the given pojoPath.

Parameters:
pojoPath - is the current PojoPath to navigate.
context - is the context for this operation.
state - is the state of this operation.
Returns:
the result of the navigation of the given pojoPath starting at the given pojo. It may be null according to the given mode.

get

protected Object get(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                     PojoPathContext context,
                     AbstractPojoPathNavigator.PojoPathState state)
This method gets the value for the single segment of the given currentPath from the pojo of its parent.
If the state indicates an invocation from getType, only the pojo-type should be determined. Otherwise if the result is null and mode is PojoPathMode.CREATE_IF_NULL it creates and attaches (sets) the missing object.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath to evaluate.
context - is the context for this operation.
state - is the cache to use or null to disable caching.
Returns:
the result of the evaluation of the given pojoPath starting at the given pojo. It may be null according to the given mode.

getFromFunction

protected Object getFromFunction(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                                 PojoPathContext context,
                                 AbstractPojoPathNavigator.PojoPathState state,
                                 PojoPathFunction function)
This method gets the single segment of the given currentPath from the Pojo given by parentPojo. If the result is null and mode is PojoPathMode.CREATE_IF_NULL it creates the missing object.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath to evaluate.
context - is the context for this operation.
state - is the state of this operation.
function - is the PojoPathFunction for evaluation.
Returns:
the result of the evaluation. It might be null according to the mode.

getFromMap

protected Object getFromMap(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                            PojoPathContext context,
                            AbstractPojoPathNavigator.PojoPathState state,
                            Map parentPojo)
This method gets the single segment of the given currentPath from the Map given by parentPojo. If the result is null and mode is PojoPathMode.CREATE_IF_NULL it creates and attaches the missing object.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath to evaluate.
context - is the context for this operation.
state - is the state of this operation.
parentPojo - is the parent object to work on.
Returns:
the result of the evaluation. It might be null according to the mode.

getFromList

protected Object getFromList(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                             PojoPathContext context,
                             AbstractPojoPathNavigator.PojoPathState state,
                             int index)
This method gets the single segment of the given currentPath from the array or List given by parentPojo. If the result is null and mode is PojoPathMode.CREATE_IF_NULL it creates and sets the missing object. For arrays a new array has to be created and set in the parent of the parentPojo.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath to evaluate.
context - is the context for this operation.
state - is the state of this operation.
index - is the List-index.
Returns:
the result of the evaluation. It might be null according to the mode.

create

protected Object create(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                        PojoPathContext context,
                        AbstractPojoPathNavigator.PojoPathState state,
                        Class<?> pojoClass)
                 throws PojoPathCreationException
This method creates a Pojo of the given pojoType.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath to evaluate.
context - is the context for this operation.
state - is the state of this operation.
pojoClass - is the Class reflecting the Pojo to create.
Returns:
the created Pojo.
Throws:
PojoPathCreationException - if the creation failed.

getFromPojo

protected abstract Object getFromPojo(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                                      PojoPathContext context,
                                      AbstractPojoPathNavigator.PojoPathState state)
This method reflectively gets the single segment of the given currentPath from the Pojo given by parentPojo. If the result is null and mode is PojoPathMode.CREATE_IF_NULL it creates and attaches (sets) the missing object.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath to evaluate.
context - is the context for this operation.
state - is the state of this operation.
Returns:
the result of the evaluation. It might be null according to the mode.

getFunction

protected PojoPathFunction getFunction(String functionName,
                                       PojoPathContext context)
                                throws PojoPathFunctionUndefinedException
This method gets the PojoPathFunction for the given functionName.

Parameters:
functionName - is the name of the requested PojoPathFunction.
context - is the context for this operation.
Returns:
the requested PojoPathFunction.
Throws:
PojoPathFunctionUndefinedException - if no PojoPathFunction is defined for the given functionName.

getType

public GenericType<?> getType(Type pojoType,
                              String pojoPath,
                              boolean failOnUnsafePath,
                              PojoPathContext context)
                       throws PojoPathException,
                              IllegalPojoPathException,
                              PojoPathUnsafeException
This method determines the result-type for the given pojoPath starting at the given pojoType using the given context.
In other words if get is invoked on this navigator with an instance of pojoType the result will be an instance of the type returned by this method.
Please note that the given pojoPath may be unsafe , what means that it has a segment that points to a property that does NOT exist for the Class determined for the according Pojo. In other words a PojoPath is unsafe if it can NOT be written as native Java method cascade without using casts in order to be compiled. It may be illegal depending on the initial Pojo.

Specified by:
getType in interface PojoPathNavigator
Parameters:
pojoType - is the type of the initial Pojo.
pojoPath - is the PojoPath to navigate.
failOnUnsafePath - determines how to deal with unsafe PojoPaths. If true and the given pojoPath is unsafe for the given pojoType an PojoPathUnsafeException is thrown and if false this method returns null in such case.
context - is the PojoPathContext for this operation.
Returns:
the guaranteed result-type of the navigation of the given pojoPath starting at the given pojoType. It may be Object.class e.g. in case an untyped Collection is hit. It will be null if the given pojoPath is unsafe and the given mode is PojoPathMode.RETURN_IF_NULL.
Throws:
IllegalPojoPathException - if the given pojoPath is illegal.
PojoPathUnsafeException - if the given pojoPath is unsafe for the given pojoType and this is disallowed by mode.
PojoPathException - if the operation failed for arbitrary reasons.

getType

public GenericType<?> getType(GenericType<?> pojoType,
                              String pojoPath,
                              boolean failOnUnsafePath,
                              PojoPathContext context)
This method determines the result-type for the given pojoPath starting at the given pojoType using the given context.
In other words if get is invoked on this navigator with an instance of pojoType the result will be an instance of the type returned by this method.
Please note that the given pojoPath may be unsafe , what means that it has a segment that points to a property that does NOT exist for the Class determined for the according Pojo. In other words a PojoPath is unsafe if it can NOT be written as native Java method cascade without using casts in order to be compiled. It may be illegal depending on the initial Pojo.

Specified by:
getType in interface PojoPathNavigator
Parameters:
pojoType - is the type of the initial Pojo.
pojoPath - is the PojoPath to navigate.
failOnUnsafePath - determines how to deal with unsafe PojoPaths. If true and the given pojoPath is unsafe for the given pojoType an PojoPathUnsafeException is thrown and if false this method returns null in such case.
context - is the PojoPathContext for this operation.
Returns:
the guaranteed result-type of the navigation of the given pojoPath starting at the given pojoType. It may be Object.class e.g. in case an untyped Collection is hit. It will be null if the given pojoPath is unsafe and the given mode is PojoPathMode.RETURN_IF_NULL.

set

public Object set(Object pojo,
                  String pojoPath,
                  PojoPathMode mode,
                  PojoPathContext context,
                  Object value)
This method sets the given value for the given pojoPath in the given pojo using the given mode and context. It acts like a get on the parent-path and then setting the value for the remaining segment on the result.
The result of this method is defined as following:
If pojo is This will typically be the value that replaced value. It may be null.

Specified by:
set in interface PojoPathNavigator
Parameters:
pojo - is the initial Pojo to operate on.
pojoPath - is the PojoPath to navigate.
mode - is the mode that determines how to deal with null values.
context - is the PojoPathContext for this operation.
value - is the value to set. It may be null.
Returns:
the result of the set operation.

set

protected Object set(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                     PojoPathContext context,
                     AbstractPojoPathNavigator.PojoPathState state,
                     Object parentPojo,
                     Object value)
This method sets the single segment of the given currentPath from the Pojo given by parentPojo. If the result is null and mode is PojoPathMode.CREATE_IF_NULL it creates and attaches (sets) the missing object.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath to set.
context - is the context for this operation.
state - is the cache to use or null to disable caching.
parentPojo - is the parent Pojo to work on.
value - is the value to set in parentPojo.
Returns:
the replaced value. It may be null.

setInPojo

protected abstract Object setInPojo(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                                    PojoPathContext context,
                                    AbstractPojoPathNavigator.PojoPathState state,
                                    Object parentPojo,
                                    Object value)
This method sets the single segment of the given currentPath from the Pojo given by parentPojo. If the result is null and mode is PojoPathMode.CREATE_IF_NULL it creates and attaches (sets) the missing object.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath to set.
context - is the context for this operation.
state - is the state to use.
parentPojo - is the parent Pojo to work on.
value - is the value to set in parentPojo.
Returns:
the replaced value. It may be null.

convert

protected Object convert(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                         PojoPathContext context,
                         Object pojo,
                         Class<?> targetClass,
                         GenericType<?> targetType)
                  throws PojoPathConversionException
This method converts the given pojo to the given targetClass (or even targetType) as necessary.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath that lead to pojo.
context - is the context for this operation.
pojo - is the Pojo to convert as necessary.
targetClass - is the expected Class.
targetType - is the expected Type.
Returns:
the pojo converted to the targetType as necessary.
Throws:
PojoPathConversionException - if the given pojo is NOT compatible and could NOT be converted.

convertList

protected Object convertList(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                             PojoPathContext context,
                             AbstractPojoPathNavigator.PojoPathState state,
                             Object arrayOrCollection)
This method converts the given arrayOrCollection to a List as necessary.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath that lead to arrayOrCollection.
context - is the context for this operation.
state - is the state to use.
arrayOrCollection - is the object to be accessed at a given index.
Returns:
a List that adapts arrayOrCollection if it is a Collection but NOT a List. Otherwise the given arrayOrCollection itself.

setInList

protected Object setInList(AbstractPojoPathNavigator.CachingPojoPath currentPath,
                           PojoPathContext context,
                           AbstractPojoPathNavigator.PojoPathState state,
                           Object parentPojo,
                           Object value,
                           int index)
This method sets the single segment of the given currentPath from the array or List given by parentPojo. If the result is null and mode is PojoPathMode.CREATE_IF_NULL it creates and attaches (sets) the missing object.

Parameters:
currentPath - is the current AbstractPojoPathNavigator.CachingPojoPath to set.
context - is the context for this operation.
state - is the state to use.
parentPojo - is the parent Pojo to work on.
value - is the value to set in parentPojo.
index - is the position of the value to set in the array or List given by parentPojo.
Returns:
the replaced value. It may be null.

pojo2Map

public Map<String,Object> pojo2Map(Object pojo)
This method creates a lazy, immutable Map reflecting the given Pojo.
ATTENTION:
The Map will be simple and will NOT support size or iteration.

Specified by:
pojo2Map in interface PojoPathNavigator
Parameters:
pojo - is the Pojo to convert.
Returns:
the Map reflecting the given Pojo.
See Also:
PojoDescriptorBuilder.pojo2Map(Object)

pojo2Map

public Map<String,Object> pojo2Map(Object pojo,
                                   PojoPathContext context)
This method creates a lazy, immutable Map reflecting the given Pojo.
ATTENTION:
The Map will be simple and will NOT support size or iteration.

Specified by:
pojo2Map in interface PojoPathNavigator
Parameters:
pojo - is the Pojo to convert.
context - is the PojoPathContext for this operation.
Returns:
the Map reflecting the given Pojo.
See Also:
PojoDescriptorBuilder.pojo2Map(Object)


Copyright © 2001-2010 mmm-Team. All Rights Reserved.