public class DefaultContext extends Object implements Context
get()
and put
methods. The hide
method will hide a property. When
a property has been hidden the context will not search in the parent context for the value.Constructor and Description |
---|
DefaultContext()
Create a empty Context with no parent.
|
DefaultContext(Context parent)
Create a Context with specified parent.
|
DefaultContext(Map contextData)
Create a empty Context with specified data.
|
DefaultContext(Map contextData,
Context parent)
Create a Context with specified data and parent.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkWriteable()
Utility method to check if context is writeable and if not throw exception.
|
boolean |
contains(Object key)
Returns true if the map or the parent map contains the key.
|
Object |
get(Object key)
Returns the value of the key.
|
protected Map |
getContextData()
Utility method to retrieve context data.
|
protected Context |
getParent()
Get parent context if any.
|
void |
hide(Object key)
Hides the item in the context.
|
void |
makeReadOnly()
Make the context read-only.
|
void |
put(Object key,
Object value)
Helper method for adding items to Context.
|
public DefaultContext(Map contextData, Context parent)
contextData
- the context dataparent
- the parent Context (may be null)public DefaultContext(Map contextData)
contextData
- the context datapublic DefaultContext(Context parent)
parent
- the parent Context (may be null)public DefaultContext()
public boolean contains(Object key)
public Object get(Object key) throws ContextException
get
in interface Context
key
- The key of the value to look up.ContextException
- If the key doesn't exist.public void put(Object key, Object value) throws IllegalStateException
put
in interface Context
key
- the items keyvalue
- the itemIllegalStateException
- if context is read onlypublic void hide(Object key) throws IllegalStateException
hide
in interface Context
key
- the items keyIllegalStateException
- if context is read onlyprotected Map getContextData()
protected Context getParent()
public void makeReadOnly()
makeReadOnly
in interface Context
protected void checkWriteable() throws IllegalStateException
IllegalStateException
- if context is read onlyCopyright © 2001-2013 Codehaus. All Rights Reserved.