|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface GenericContext
This is the interface for a context of variables. It allows to read all
variables as well as to create a child-context
this is mutable.
Note: Initially the name of this interface should be just
Context. However there are tons of common java projects shipped
with a type of this name so to avoid confusion a longer name was chosen.
| Method Summary | ||
|---|---|---|
MutableGenericContext |
createChildContext()
This method creates a new context that inherits all variables from this context (and its parent contexts). |
|
|
getVariable(Class<T> type)
This method gets the variable associated with the given type. |
|
Object |
getVariable(String variableName)
This method gets the variable associated with the given variableName. |
|
|
getVariable(String variableName,
Class<T> type)
This method gets the variable associated with the given variableName as the given type. |
|
Set<String> |
getVariableNames()
This method returns the names of all defined variables. |
|
boolean |
hasVariable(String variableName)
This method determines if the variable for the
given variableName exists. |
|
|
requireVariable(Class<T> type)
This method gets the variable associated with the given type. |
|
Object |
requireVariable(String variableName)
This method gets the variable associated with the given variableName. |
|
|
requireVariable(String variableName,
Class<T> type)
This method gets the variable associated with the given variableName. |
|
Map<String,Object> |
toMap()
This method allows to create a Map representing the variables of
this context. |
|
| Method Detail |
|---|
Object requireVariable(String variableName)
throws ValueNotSetException
variableName.
variableName - is the name of the requested variable.
ValueNotSetException - if the requested variable is NOT set.
<T> T requireVariable(String variableName,
Class<T> type)
throws ValueNotSetException
variableName.
T - the generic type of the variable.variableName - is the name of the requested variable.type - is the class reflecting the type of the variable.
ValueNotSetException - if the requested variable is NOT set.
<T> T requireVariable(Class<T> type)
throws ValueNotSetException
type.
It will use the classname as
variable-name.String or Integer are bad candidates while
MySpecificSingletonComponentInterface might be a good option.
T - the generic type of the variable.type - is the class reflecting the type of the variable.
ValueNotSetException - if the requested variable is NOT set.MutableGenericContext.setVariable(String, Object)Object getVariable(String variableName)
variableName.
variableName - is the name of the requested variable.
null if the variable is
NOT set.
<T> T getVariable(String variableName,
Class<T> type)
variableName as the given type. If the
type does NOT match the actual type of the variable it may
automatically be converted as possible.
T - the generic type of the variable.variableName - is the name of the requested variable.type - is the class reflecting the type of the variable.
null if the variable is
NOT set.<T> T getVariable(Class<T> type)
type.
It will use the classname as
variable-name.String or Integer are bad candidates while
MySpecificSingletonComponentInterface might be a good option.
T - the generic type of the variable.type - is the class reflecting the type of the variable.
null if the variable is
NOT set.MutableGenericContext.setVariable(String, Object)boolean hasVariable(String variableName)
variable for the
given variableName exists.
variableName - is the name of the requested variable.
true if a value exists for the given
variableName, false otherwise.Set<String> getVariableNames()
hasVariable(String) where possible.
MutableGenericContext createChildContext()
Map<String,Object> toMap()
Map representing the variables of
this context. This can be useful to pass this context to an external
component (e.g. a template-engine) that typically accepts a Map.Map will NOT reflect
changes of this context and vice versa.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||