Class TransformerContextPropertiesWrapper
- java.lang.Object
-
- net.sf.jguiraffe.transform.TransformerContextPropertiesWrapper
-
- All Implemented Interfaces:
TransformerContext
public class TransformerContextPropertiesWrapper extends Object implements TransformerContext
A specialized implementation of the
TransformerContext
interface that allows wrapping an existing context and extending its properties.One important feature of a
TransformerContext
is to provide a set of properties that can be queried by transformers or validators. While these properties are typically global, in some situations it is useful to override or extend them on a local basis, e.g. to define some special properties for a single transformer only.This class supports exactly this use case: An instance is created by specifying a
TransformerContext
to wrap and a map with (additional) properties. Theproperties()
method is implemented to construct a union from the properties of the original context and the map of this instance. The remaining methods simply delegate to the wrapped context.- Version:
- $Id: TransformerContextPropertiesWrapper.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description TransformerContextPropertiesWrapper(TransformerContext orgCtx, Map<String,Object> newProps)
Creates a new instance ofTransformerContextPropertiesWrapper
and initializes it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Locale
getLocale()
Returns the current locale.ResourceManager
getResourceManager()
Returns the resource manager.<T> T
getTypedProperty(Class<T> propCls)
Returns the value of the specified typed property.ValidationMessageHandler
getValidationMessageHandler()
Returns theValidationMessageHandler
.TransformerContext
getWrappedContext()
Returns the wrapped context.Map<String,Object>
properties()
Returns a map with properties.
-
-
-
Constructor Detail
-
TransformerContextPropertiesWrapper
public TransformerContextPropertiesWrapper(TransformerContext orgCtx, Map<String,Object> newProps)
Creates a new instance ofTransformerContextPropertiesWrapper
and initializes it.- Parameters:
orgCtx
- the context to be wrapped (must not be null)newProps
- the new properties (must not be null)- Throws:
IllegalArgumentException
- if the original context or the map with the new properties is null
-
-
Method Detail
-
getWrappedContext
public TransformerContext getWrappedContext()
Returns the wrapped context.- Returns:
- the wrapped context
-
getLocale
public Locale getLocale()
Returns the current locale. This implementation delegates to the wrapped context.- Specified by:
getLocale
in interfaceTransformerContext
- Returns:
- the current locale
-
getResourceManager
public ResourceManager getResourceManager()
Returns the resource manager. This implementation delegates to the wrapped context.- Specified by:
getResourceManager
in interfaceTransformerContext
- Returns:
- the resource manager
-
properties
public Map<String,Object> properties()
Returns a map with properties. This implementation constructs a union from the properties of the wrapped context and the properties stored in this object.- Specified by:
properties
in interfaceTransformerContext
- Returns:
- a map with properties
-
getValidationMessageHandler
public ValidationMessageHandler getValidationMessageHandler()
Returns theValidationMessageHandler
. This implementation delegates to the wrapped context.- Specified by:
getValidationMessageHandler
in interfaceTransformerContext
- Returns:
- the
ValidationMessageHandler
-
getTypedProperty
public <T> T getTypedProperty(Class<T> propCls)
Returns the value of the specified typed property. This implementation delegates to the wrapped context.- Specified by:
getTypedProperty
in interfaceTransformerContext
- Type Parameters:
T
- the type of the property- Parameters:
propCls
- the property class- Returns:
- the value of this property
-
-