net.sf.mmm.util.context.api
Interface MutableGenericContext

All Superinterfaces:
GenericContext
All Known Implementing Classes:
AbstractMutableGenericContext, MutableGenericContextImpl

public interface MutableGenericContext
extends GenericContext

This is the interface for a context that can be modified.

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

Method Summary
 GenericContext getImmutableContext()
          This method gets an immutable proxy of this context that can NOT be casted to MutableGenericContext.
 Object removeVariable(String variableName)
          This method removes (unsets) the variable specified by variableName.
 Object setVariable(Object value)
          This method sets the variable given by value.
 Object setVariable(String variableName, Object value)
          This method sets the variable specified by variableName to the given value.
 
Methods inherited from interface net.sf.mmm.util.context.api.GenericContext
createChildContext, getVariable, getVariable, getVariable, getVariableNames, hasVariable, requireVariable, requireVariable, requireVariable, toMap
 

Method Detail

setVariable

Object setVariable(String variableName,
                   Object value)
This method sets the variable specified by variableName to the given value. If the variable is already set, it will be overridden.

Parameters:
variableName - is the name of the variable to set.
value - is the value to assign to the variable.
Returns:
the old value of the variable in this context (excluding inherited variables) or null if the variable was undefined or NOT overridden in this context.
See Also:
GenericContext.getVariable(String)

setVariable

Object setVariable(Object value)
This method sets the variable given by value. If the variable is already set, it will be overridden. This method will use the classname as variable-name.
ATTENTION:
Only use this method in combination with expressive types. E.g. types like String or Integer are bad candidates while MySpecificSingletonComponentInterface might be a good option.

Parameters:
value - is the value to assign to the variable.
Returns:
the old value of the variable in this context (excluding inherited variables) or null if the variable was undefined or NOT overridden in this context.
Since:
2.0.0
See Also:
GenericContext.getVariable(String), GenericContext.getVariable(Class)

removeVariable

Object removeVariable(String variableName)
This method removes (unsets) the variable specified by variableName. This will only remove a variable defined in this context. A variable inherited from a parent context can not be removed here.
If this method is called with the name of a variable not defined in this context it will have no effect. You might want to set a variable to null instead.

Parameters:
variableName - is the name of the variable to unset.
Returns:
the old value of the variable or null if the variable is NOT defined (in this context).

getImmutableContext

GenericContext getImmutableContext()
This method gets an immutable proxy of this context that can NOT be casted to MutableGenericContext.

Returns:
the immutable view on this context.


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