net.sf.morph.context
Interface HierarchicalContext

All Superinterfaces:
Context
All Known Implementing Classes:
BaseHierarchicalContext, HttpServletContext, JspContext, MapContext, ReflectorHierarchicalContext

public interface HierarchicalContext
extends Context

A context which participates in a context hierarchy (i.e. - a context that has one or more parents). Hierarchical contexts lookup property values first in the current context, and then through in any parent context(s). This allows properties in child context to override properties in parent contexts.

Since:
Nov 21, 2004
Author:
Matt Sgarlata

Method Summary
 java.lang.Object get(java.lang.String propertyName)
          Retrieve the property named propertyName from this context, or if it's not found, from the nearest ancestor context.
 Context getParentContext()
          Retrieves this context's parent context.
 java.lang.String[] getPropertyNames()
          Gets the names of the properties which are currently defined for this context and all parents of this context.
 void set(java.lang.String propertyName, java.lang.Object propertyValue)
          Sets propertyName to propertyValue in the current context.
 void setParentContext(Context context)
          Sets this context's parent context.
 

Method Detail

getPropertyNames

java.lang.String[] getPropertyNames()
                                    throws ContextException
Gets the names of the properties which are currently defined for this context and all parents of this context. It will often be an O(n) operation to list all property names in the context, so callers should avoid frequent calls to this method.

Specified by:
getPropertyNames in interface Context
Returns:
the property names
Throws:
ContextException - if the properties could not be retieved for some reason

get

java.lang.Object get(java.lang.String propertyName)
                     throws ContextException
Retrieve the property named propertyName from this context, or if it's not found, from the nearest ancestor context.

Specified by:
get in interface Context
Parameters:
propertyName - the name of the property to be retrieved
Returns:
the value of the property
Throws:
ContextException - if propertyName is empty or
the property can't be accessed for some reason

set

void set(java.lang.String propertyName,
         java.lang.Object propertyValue)
         throws ContextException
Sets propertyName to propertyValue in the current context. No change will be made to the property values in any ancestor contexts.

Specified by:
set in interface Context
Parameters:
propertyName - the name of the property to set
propertyValue - the new value for the property
Throws:
ContextExcception - if propertyName is empty or
the property can't be accessed for some reason
ContextException - if propertyName is empty or
the property can't be set for some reason

getParentContext

Context getParentContext()
Retrieves this context's parent context.

Returns:
this context's parent context

setParentContext

void setParentContext(Context context)
Sets this context's parent context.

Parameters:
context - this context's parent context


Copyright © 2004-2008.