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. The properties()
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.
Constructor and Description |
---|
TransformerContextPropertiesWrapper(TransformerContext orgCtx,
Map<String,Object> newProps)
Creates a new instance of
TransformerContextPropertiesWrapper and initializes it. |
Modifier and Type | Method and 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 the
ValidationMessageHandler . |
TransformerContext |
getWrappedContext()
Returns the wrapped context.
|
Map<String,Object> |
properties()
Returns a map with properties.
|
public TransformerContextPropertiesWrapper(TransformerContext orgCtx, Map<String,Object> newProps)
TransformerContextPropertiesWrapper
and initializes it.orgCtx
- the context to be wrapped (must not be null)newProps
- the new properties (must not be null)IllegalArgumentException
- if the original context or the map with
the new properties is nullpublic TransformerContext getWrappedContext()
public Locale getLocale()
getLocale
in interface TransformerContext
public ResourceManager getResourceManager()
getResourceManager
in interface TransformerContext
public Map<String,Object> properties()
properties
in interface TransformerContext
public ValidationMessageHandler getValidationMessageHandler()
ValidationMessageHandler
. This implementation
delegates to the wrapped context.getValidationMessageHandler
in interface TransformerContext
ValidationMessageHandler
public <T> T getTypedProperty(Class<T> propCls)
getTypedProperty
in interface TransformerContext
T
- the type of the propertypropCls
- the property classCopyright © 2016 The JGUIraffe Team. All rights reserved.