Package net.sf.jguiraffe.transform
Interface TransformerContext
-
- All Known Subinterfaces:
ApplicationContext
- All Known Implementing Classes:
ApplicationContextImpl
,TransformerContextPropertiesWrapper
public interface TransformerContext
Definition of an interface for accessing data needed by transformers.
This interface defines a set of methods for accessing system information like the current
Locale
or the resource manager. ATransformer
object is passed an implementation of this interface, so it can make use of the methods defined here to obtain the data it needs.- Version:
- $Id: TransformerContext.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Locale
getLocale()
Returns the currentLocale
.ResourceManager
getResourceManager()
Returns the currentResourceManager
.<T> T
getTypedProperty(Class<T> propCls)
Returns the value of the property with the given type.ValidationMessageHandler
getValidationMessageHandler()
Returns theValidationMessageHandler
associated with this context.Map<String,Object>
properties()
Returns a map with properties.
-
-
-
Method Detail
-
getLocale
Locale getLocale()
Returns the currentLocale
.- Returns:
- the
Locale
to use
-
getResourceManager
ResourceManager getResourceManager()
Returns the currentResourceManager
. This object can be used to access resources.- Returns:
- the
ResourceManager
-
properties
Map<String,Object> properties()
Returns a map with properties. Transformers or validators can use this method for obtaining specific properties that may influence their behavior.- Returns:
- a map with properties assigned to this context
-
getTypedProperty
<T> T getTypedProperty(Class<T> propCls)
Returns the value of the property with the given type. Objects that are passed aTransformerContext
have access to a set of properties which can impact their behavior. Using this method properties can be queried in a type-safe way. This is in contrast to the properties available through theproperties()
method. While the standard transformer implementations shipped with this library typically use the plain properties, this method is intended to be used by high-level custom transformers that need access to certain application-global objects. For instance, an application may store information about the currently edited object in its context. AValidator
implementation may then access this data to perform specific checks. The type-safe properties available through this method are typically disjunct to the the ones provided byproperties()
.An implementation should check whether a property of the specified type is available and return it. Otherwise, the method should return null.- Type Parameters:
T
- the type of the property- Parameters:
propCls
- the property class- Returns:
- the value of this property or null if it is not set
-
getValidationMessageHandler
ValidationMessageHandler getValidationMessageHandler()
Returns theValidationMessageHandler
associated with this context. This object can be used for obtaining validation messages. It is used for instance by concreteValidator
implementations.- Returns:
- the
ValidationMessageHandler
for this context
-
-