Class DefaultContext
java.lang.Object
org.apache.avalon.framework.context.DefaultContext
- All Implemented Interfaces:
Context
Default implementation of Context.
This implementation is a static hierarchial store.
- Version:
- CVS $Revision: 1.27 $ $Date: 2004/02/11 14:34:26 $
- Author:
- Avalon Development Team
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a Context with no parent.DefaultContext
(Map contextData) Create a Context with specified data.DefaultContext
(Map contextData, Context parent) Create a Context with specified data and parent.DefaultContext
(Context parent) Create a Context with specified parent. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Utility method to check if context is writeable and if not throw exception.Retrieve an item from the Context.protected final Map
Utility method to retrieve context data.protected final Context
Get parent context if any.void
Hides the item in the context.void
Make the context read-only.void
Helper method fo adding items to Context.
-
Constructor Details
-
DefaultContext
Create a Context with specified data and parent.- Parameters:
contextData
- the context dataparent
- the parent Context (may be null)
-
DefaultContext
Create a Context with specified data.- Parameters:
contextData
- the context data
-
DefaultContext
Create a Context with specified parent.- Parameters:
parent
- the parent Context (may be null)
-
DefaultContext
public DefaultContext()Create a Context with no parent.
-
-
Method Details
-
get
Retrieve an item from the Context.- Specified by:
get
in interfaceContext
- Parameters:
key
- the key of item- Returns:
- the item stored in context
- Throws:
ContextException
- if item not present
-
put
Helper method fo adding items to Context.- Parameters:
key
- the items keyvalue
- the item- Throws:
IllegalStateException
- if context is read only
-
hide
Hides the item in the context. After remove(key) has been called, a get(key) will always fail, even if the parent context has such a mapping.- Parameters:
key
- the items key- Throws:
IllegalStateException
- if context is read only
-
getContextData
Utility method to retrieve context data.- Returns:
- the context data
-
getParent
Get parent context if any.- Returns:
- the parent Context (may be null)
-
makeReadOnly
public void makeReadOnly()Make the context read-only. Any attempt to write to the context via put() will result in an IllegalStateException. -
checkWriteable
Utility method to check if context is writeable and if not throw exception.- Throws:
IllegalStateException
- if context is read only
-