org.norther.tammi.spray.engine.context
Interface TemplateContext

All Known Implementing Classes:
DefaultContextToolFilter.InternalTemplateContext, DefaultTemplateContext

public interface TemplateContext

TemplateContext is a template engine independent interface to contexts. It supports chaining of contexts through parent contexts.

Version:
$Id: TemplateContext.java,v 1.9 2009/09/28 15:08:28 cvsimp Exp $
Author:
Ilkka Priha

Method Summary
 boolean addParent(int index, TemplateContext context)
          Adds a parent context to a specied index.
 boolean addParent(TemplateContext context)
          Adds a parent context.
 void clear()
          Clears the context but not its parents.
 void clearParents()
          Clears all parents from this context.
 boolean containsKey(String key)
          Checks whether a key is in the context or in its parents.
 Object get(String key)
          Gets an object from the context or from its parents.
 Content getContent()
          Gets the content of this context.
 ContextToolFilter getContextToolFilter()
          Gets the context tool filter of this context.
 HttpFilterChain getFilterChain()
          Gets the filter chain of this context.
 MBeanServer getMBeanServer()
          Gets the MBean server.
 TemplateContext getParent(int index)
          Gets the indexed parent from the context.
 List<TemplateContext> getParents()
          Gets a read-only list of parents.
 Set<String> keySet()
          Gets a set of all keys in the context and in its parents.
 int numberOfParents()
          Returns the number of parents.
 Object put(String key, Object value)
          Puts an object into the context.
 Object remove(String key)
          Removes an object from the context.
 TemplateContext removeParent(int index)
          Removes an indexed parent context.
 boolean removeParent(TemplateContext context)
          Removes a parent context.
 void set(String key, Object value)
          Sets an object int the context.
 TemplateContext setParent(int index, TemplateContext context)
          Sets a parent context to a specied index.
 int size()
          Gets the size of the context including its parents.
 Collection<Object> values()
          Gets a collection of all values in the context and in its parents.
 

Method Detail

getParents

List<TemplateContext> getParents()
Gets a read-only list of parents.

Returns:
a list of parents.

getParent

TemplateContext getParent(int index)
Gets the indexed parent from the context.

Parameters:
index - the index.
Returns:
the parent context.
Throws:
IndexOutOfBoundsException - for invalid index.

setParent

TemplateContext setParent(int index,
                          TemplateContext context)
Sets a parent context to a specied index. If the same parent is already included in the context, the duplicate will be removed.

Parameters:
context - a parent context.
index - the index.
Returns:
the previous parent, if any.
Throws:
IndexOutOfBoundsException - for invalid index.

addParent

boolean addParent(TemplateContext context)
Adds a parent context. If the same parent is already included in the context, it will not be added.

Parameters:
context - a parent context.
Returns:
true if added, false otherwise.

addParent

boolean addParent(int index,
                  TemplateContext context)
Adds a parent context to a specied index. If the same parent is already included in the context, it will not be added. The parent at the lowest index has the highest precedence.

Parameters:
index - the index.
context - a parent context.
Returns:
true if added, false otherwise.
Throws:
IndexOutOfBoundsException - for invalid index.

removeParent

boolean removeParent(TemplateContext context)
Removes a parent context.

Parameters:
context - a parent context.
Returns:
true if removed, false otherwise.

removeParent

TemplateContext removeParent(int index)
Removes an indexed parent context.

Parameters:
index - the index.
Returns:
the removed parent or null.
Throws:
IndexOutOfBoundsException - for invalid index.

numberOfParents

int numberOfParents()
Returns the number of parents.

Returns:
the number of parents.

clearParents

void clearParents()
Clears all parents from this context.


getContent

Content getContent()
Gets the content of this context.

Returns:
the content.

getFilterChain

HttpFilterChain getFilterChain()
Gets the filter chain of this context.

Returns:
the filter chain.

get

Object get(String key)
Gets an object from the context or from its parents.

Parameters:
key - the key.
Returns:
the value.

set

void set(String key,
         Object value)
Sets an object int the context.

Parameters:
key - the key.
value - the value.

put

Object put(String key,
           Object value)
Puts an object into the context.

Parameters:
key - the key.
value - the value.
Returns:
the previous value.

remove

Object remove(String key)
Removes an object from the context.

Parameters:
key - the key.
Returns:
the removed value.

containsKey

boolean containsKey(String key)
Checks whether a key is in the context or in its parents.

Parameters:
key - the key.
Returns:
true if found.

keySet

Set<String> keySet()
Gets a set of all keys in the context and in its parents.

Returns:
a set of keys.

values

Collection<Object> values()
Gets a collection of all values in the context and in its parents.

Returns:
a collection of values.

size

int size()
Gets the size of the context including its parents.

Returns:
the size of the context.

clear

void clear()
Clears the context but not its parents.


getContextToolFilter

ContextToolFilter getContextToolFilter()
Gets the context tool filter of this context.

Returns:
the context tool filter.
Throws:
IllegalStateException - if not available.

getMBeanServer

MBeanServer getMBeanServer()
Gets the MBean server.

Returns:
the MBean server.


Copyright © 2004 The Norther Organization. All rights reserved.