org.apache.commons.jelly.tags.velocity
Class JellyContextAdapter

java.lang.Object
  extended byorg.apache.commons.jelly.tags.velocity.JellyContextAdapter
All Implemented Interfaces:
org.apache.velocity.context.Context

public class JellyContextAdapter
extends java.lang.Object
implements org.apache.velocity.context.Context

Adapts a JellyContext for use as a Velocity Context. This context can be used in either read-only or read-write mode. When used as a read-only adapter, items put or removeed from the Velocity context are not permitted to propogate to the JellyContext, which is the default behavior. The adapter can also be used in a read-write mode. This permits changes made by Velocity to propogate to the JellyContext.

Version:
$Id: JellyContextAdapter.java,v 1.2 2003/03/03 20:49:37 werken Exp $
Author:
Pete Kazmier

Field Summary
private  org.apache.commons.jelly.JellyContext jellyContext
          The JellyContext being adapted
private  java.util.HashMap privateContext
          The store for Velocity in the event the adpater is read-only
private  boolean readOnly
          Flag to indicate read-only or read-write mode
 
Constructor Summary
JellyContextAdapter(org.apache.commons.jelly.JellyContext jellyContext)
          Constructor.
 
Method Summary
 boolean containsKey(java.lang.Object key)
           
 java.lang.Object get(java.lang.String key)
           
 java.lang.Object[] getKeys()
           
 boolean isReadOnly()
          Tests if the adapter is read-only.
 java.lang.Object put(java.lang.String key, java.lang.Object value)
           
 java.lang.Object remove(java.lang.Object key)
           
 void setReadOnly(boolean readOnly)
          Sets the read-only flag for this adapter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

readOnly

private boolean readOnly
Flag to indicate read-only or read-write mode


jellyContext

private org.apache.commons.jelly.JellyContext jellyContext
The JellyContext being adapted


privateContext

private java.util.HashMap privateContext
The store for Velocity in the event the adpater is read-only

Constructor Detail

JellyContextAdapter

public JellyContextAdapter(org.apache.commons.jelly.JellyContext jellyContext)
Constructor.

Parameters:
jellyContext - The JellyContext to adapt
Method Detail

setReadOnly

public void setReadOnly(boolean readOnly)
Sets the read-only flag for this adapter. If the read-only flag is set, changes to the Velocity Context will not be propogated to the JellyContext. Turning the read-only flag off enables changes to propogate.

Parameters:
readOnly - If this parameter is true, the adapter becomes read-only. Setting the parameter to false the adapter becomes read-write.

isReadOnly

public boolean isReadOnly()
Tests if the adapter is read-only.

Returns:
true if the adpater is read-only; otherwise returns false.

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface org.apache.velocity.context.Context

get

public java.lang.Object get(java.lang.String key)
Specified by:
get in interface org.apache.velocity.context.Context

getKeys

public java.lang.Object[] getKeys()
Specified by:
getKeys in interface org.apache.velocity.context.Context

put

public java.lang.Object put(java.lang.String key,
                            java.lang.Object value)
Specified by:
put in interface org.apache.velocity.context.Context

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface org.apache.velocity.context.Context