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

java.lang.Object
  extended by net.sf.mmm.util.pojo.path.base.PojoPathContextBean
All Implemented Interfaces:
PojoPathContext
Direct Known Subclasses:
DefaultPojoPathContext

public class PojoPathContextBean
extends Object
implements PojoPathContext

This is an implementation of the PojoPathContext interface as simple Java bean.

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

Field Summary
private  ComposedValueConverter additionalConverter
           
private  PojoPathFunctionManager additionalFunctionManager
           
private  Map<Object,Object> cache
           
private  PojoFactory pojoFactory
           
private  Properties properties
           
private  PojoPathRecognizer recognizer
           
 
Constructor Summary
PojoPathContextBean()
          The constructor.
 
Method Summary
 ComposedValueConverter getAdditionalConverter()
          This method gets an optional ComposedValueConverter that is used in favor to ComposedValueConverter registered to the PojoPathNavigator itself.
 PojoPathFunctionManager getAdditionalFunctionManager()
          This method gets an optional PojoPathFunctionManager.
 Map<Object,Object> getCache()
          This method provides a cache that is used by the PojoPathNavigator to speed up repetitive calls with the same initial Pojo and PojoPaths with a common prefix.
 PojoFactory getPojoFactory()
          This method gets an optional PojoFactory instance used if favor to the PojoFactory registered to the PojoPathNavigator itself.
 Properties getProperties()
          This method gets the properties of the context.
 PojoPathRecognizer getRecognizer()
          This method gets an optional recognizer that adds support for the visitor-pattern.
 void setAdditionalConverter(ComposedValueConverter additionalConverter)
          This method sets the additional converter .
 void setAdditionalFunctionManager(PojoPathFunctionManager additionalFunctionManager)
          This method sets the additional function-manager.
 void setCache(Map<Object,Object> cache)
          This method sets the cache.
 void setPojoFactory(PojoFactory pojoFactory)
          This method sets the pojo-factory.
 void setProperties(Properties properties)
          This method sets the properties.
 void setRecognizer(PojoPathRecognizer recognizer)
          This method sets the recognizer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

private Map<Object,Object> cache
See Also:
getCache()

properties

private Properties properties
See Also:
getProperties()

recognizer

private PojoPathRecognizer recognizer
See Also:
getRecognizer()

additionalConverter

private ComposedValueConverter additionalConverter
See Also:
getAdditionalConverter()

additionalFunctionManager

private PojoPathFunctionManager additionalFunctionManager
See Also:
getAdditionalFunctionManager()

pojoFactory

private PojoFactory pojoFactory
See Also:
getPojoFactory()
Constructor Detail

PojoPathContextBean

public PojoPathContextBean()
The constructor. All fields are initially null.

Method Detail

getAdditionalFunctionManager

public PojoPathFunctionManager getAdditionalFunctionManager()
This method gets an optional PojoPathFunctionManager. PojoPathFunctions provided by this manager overrules the PojoPathFunctions that may be provided by the PojoPathNavigator itself. While PojoPathFunctions that may be registered globally in the PojoPathNavigator should be stateless and thread-safe, the PojoPathFunctions provided here may be stateful depending on the usage of this context.

Specified by:
getAdditionalFunctionManager in interface PojoPathContext
Returns:
the PojoPathFunctionManager of this context or null if no context-specific PojoPathFunctions should be provided.

setAdditionalFunctionManager

public void setAdditionalFunctionManager(PojoPathFunctionManager additionalFunctionManager)
This method sets the additional function-manager.

Parameters:
additionalFunctionManager - is the PojoPathFunctionManager to set.

getAdditionalConverter

public ComposedValueConverter getAdditionalConverter()
This method gets an optional ComposedValueConverter that is used in favor to ComposedValueConverter registered to the PojoPathNavigator itself.

Specified by:
getAdditionalConverter in interface PojoPathContext
Returns:
the ComposedValueConverter of this context or null if no context-specific ComposedValueConverter is provided.

setAdditionalConverter

public void setAdditionalConverter(ComposedValueConverter additionalConverter)
This method sets the additional converter .

Parameters:
additionalConverter - is the ComposedValueConverter to set.

getCache

public Map<Object,Object> getCache()
This method provides a cache that is used by the PojoPathNavigator to speed up repetitive calls with the same initial Pojo and PojoPaths with a common prefix.
WARNING:
If caching is enabled and the initial or an intermediate Pojo changed outside the navigator the result will be wrong because the evaluation used an old value from the cache.
Please also note that the PojoPathNavigator only adds objects from the cache. It will never remove cached objects. To avoid memory-leaks, you should use a PojoPathContext instance only per transaction, per request, or whatever your grouping block will be.
ATTENTION:
Never make assumptions about the content of this cache. It is provided here to allow the PojoPathNavigator to be thread-safe and more efficient and NOT to expose it for external usage. The internal structure of the cache may change in future releases. Use the recognizer to track visited Pojos.

Specified by:
getCache in interface PojoPathContext
Returns:
a mutable Map to use as cache or null to disable caching.
See Also:
HashMap, WeakHashMap

setCache

public void setCache(Map<Object,Object> cache)
This method sets the cache.

Parameters:
cache - is the cache to set.

getProperties

public Properties getProperties()
This method gets the properties of the context. These can be accessed from PojoPathFunctions for evaluation. Please note that conditional evaluation can conflict with caching. Ensure that such PojoPathFunctions are declared to be NOT deterministic.

Specified by:
getProperties in interface PojoPathContext
Returns:
the properties of this context.

setProperties

public void setProperties(Properties properties)
This method sets the properties.

Parameters:
properties - are the Properties to set.

getRecognizer

public PojoPathRecognizer getRecognizer()
This method gets an optional recognizer that adds support for the visitor-pattern. Therefore all POJOs traversed by the PojoPathNavigator are recognized by the returned object.

Specified by:
getRecognizer in interface PojoPathContext
Returns:
the PojoPathRecognizer or null to turn this feature off.

setRecognizer

public void setRecognizer(PojoPathRecognizer recognizer)
This method sets the recognizer.

Parameters:
recognizer - is the PojoPathRecognizer to set.

getPojoFactory

public PojoFactory getPojoFactory()
This method gets an optional PojoFactory instance used if favor to the PojoFactory registered to the PojoPathNavigator itself. The PojoFactory is used to create new Pojos.

Specified by:
getPojoFactory in interface PojoPathContext
Returns:
the PojoFactory or null if no context-specific PojoFactory is provided.

setPojoFactory

public void setPojoFactory(PojoFactory pojoFactory)
This method sets the pojo-factory.

Parameters:
pojoFactory - is the PojoFactory to set.


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