Author: nbubna
Date: Tue Sep 2 22:36:11 2008
New Revision: 691519
URL: http://svn.apache.org/viewvc?rev=691519&view=rev
Log:
simplify InternalContextAdapter implementations
Added:
velocity/engine/trunk/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
(with props)
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java
velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
Added:
velocity/engine/trunk/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java?rev=691519&view=auto
==============================================================================
---
velocity/engine/trunk/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
(added)
+++
velocity/engine/trunk/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
Tue Sep 2 22:36:11 2008
@@ -0,0 +1,289 @@
+package org.apache.velocity.context;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.List;
+
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.event.EventCartridge;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.resource.Resource;
+import org.apache.velocity.util.ClassUtils;
+import org.apache.velocity.util.introspection.IntrospectionCacheData;
+
+/**
+ * This is an abstract internal-use-only context implementation to be
+ * used as a subclass for other internal-use-only contexts that wrap
+ * other internal-use-only contexts.
+ *
+ * We use this context to make it easier to chain an existing context
+ * as part of a new context implementation. It just delegates everything
+ * to the inner/parent context. Subclasses then only need to override
+ * the methods relevant to them.
+ *
+ * @author Nathan Bubna
+ * @version $Id: ChainedInternalContextAdapter.java 685724 2008-08-13
23:12:12Z nbubna $
+ * @since 1.6
+ */
+public abstract class ChainedInternalContextAdapter implements
InternalContextAdapter
+{
+ /** the parent context */
+ protected InternalContextAdapter innerContext = null;
+
+ /**
+ * CTOR, wraps an ICA
+ * @param inner context
+ */
+ public ChainedInternalContextAdapter(InternalContextAdapter inner)
+ {
+ innerContext = inner;
+ }
+
+ /**
+ * Return the inner / user context.
+ * @return The inner / user context.
+ */
+ public Context getInternalUserContext()
+ {
+ return innerContext.getInternalUserContext();
+ }
+
+ /**
+ * @see org.apache.velocity.context.InternalWrapperContext#getBaseContext()
+ */
+ public InternalContextAdapter getBaseContext()
+ {
+ return innerContext.getBaseContext();
+ }
+
+ /**
+ * Retrieves from parent context.
+ *
+ * @param key name of item to get
+ * @return stored object or null
+ */
+ public Object get(String key)
+ {
+ return innerContext.get(key);
+ }
+
+ /**
+ * Put method also stores values in parent context
+ *
+ * @param key name of item to set
+ * @param value object to set to key
+ * @return old stored object
+ */
+ public Object put(String key, Object value)
+ {
+ /*
+ * just put in the local context
+ */
+ return innerContext.put(key, value);
+ }
+
+ /**
+ * @see org.apache.velocity.context.Context#containsKey(java.lang.Object)
+ */
+ public boolean containsKey(Object key)
+ {
+ return innerContext.containsKey(key);
+ }
+
+ /**
+ * @see org.apache.velocity.context.Context#getKeys()
+ */
+ public Object[] getKeys()
+ {
+ return innerContext.getKeys();
+ }
+
+ /**
+ * @see org.apache.velocity.context.Context#remove(java.lang.Object)
+ */
+ public Object remove(Object key)
+ {
+ return innerContext.remove(key);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#pushCurrentTemplateName(java.lang.String)
+ */
+ public void pushCurrentTemplateName(String s)
+ {
+ innerContext.pushCurrentTemplateName(s);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#popCurrentTemplateName()
+ */
+ public void popCurrentTemplateName()
+ {
+ innerContext.popCurrentTemplateName();
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentTemplateName()
+ */
+ public String getCurrentTemplateName()
+ {
+ return innerContext.getCurrentTemplateName();
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#getTemplateNameStack()
+ */
+ public Object[] getTemplateNameStack()
+ {
+ return innerContext.getTemplateNameStack();
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#pushCurrentMacroName(java.lang.String)
+ */
+ public void pushCurrentMacroName(String s)
+ {
+ innerContext.pushCurrentMacroName(s);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#popCurrentMacroName()
+ */
+ public void popCurrentMacroName()
+ {
+ innerContext.popCurrentMacroName();
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentMacroName()
+ */
+ public String getCurrentMacroName()
+ {
+ return innerContext.getCurrentMacroName();
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentMacroCallDepth()
+ */
+ public int getCurrentMacroCallDepth()
+ {
+ return innerContext.getCurrentMacroCallDepth();
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#getMacroNameStack()
+ */
+ public Object[] getMacroNameStack()
+ {
+ return innerContext.getMacroNameStack();
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#icacheGet(java.lang.Object)
+ */
+ public IntrospectionCacheData icacheGet(Object key)
+ {
+ return innerContext.icacheGet(key);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#localPut(java.lang.String,java.lang.Object)
+ */
+ public Object localPut(final String key, final Object value)
+ {
+ return innerContext.put(key, value);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#icachePut(java.lang.Object,
org.apache.velocity.util.introspection.IntrospectionCacheData)
+ */
+ public void icachePut(Object key, IntrospectionCacheData o)
+ {
+ innerContext.icachePut(key, o);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#getAllowRendering()
+ */
+ public boolean getAllowRendering()
+ {
+ return innerContext.getAllowRendering();
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#setAllowRendering(boolean)
+ */
+ public void setAllowRendering(boolean v)
+ {
+ innerContext.setAllowRendering(v);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#setMacroLibraries(List)
+ */
+ public void setMacroLibraries(List macroLibraries)
+ {
+ innerContext.setMacroLibraries(macroLibraries);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#getMacroLibraries()
+ */
+ public List getMacroLibraries()
+ {
+ return innerContext.getMacroLibraries();
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalEventContext#attachEventCartridge(org.apache.velocity.app.event.EventCartridge)
+ */
+ public EventCartridge attachEventCartridge(EventCartridge ec)
+ {
+ return innerContext.attachEventCartridge(ec);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalEventContext#getEventCartridge()
+ */
+ public EventCartridge getEventCartridge()
+ {
+ return innerContext.getEventCartridge();
+ }
+
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#setCurrentResource(org.apache.velocity.runtime.resource.Resource)
+ */
+ public void setCurrentResource(Resource r)
+ {
+ innerContext.setCurrentResource(r);
+ }
+
+ /**
+ * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentResource()
+ */
+ public Resource getCurrentResource()
+ {
+ return innerContext.getCurrentResource();
+ }
+}
Propchange:
velocity/engine/trunk/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
velocity/engine/trunk/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
velocity/engine/trunk/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
------------------------------------------------------------------------------
svn:keywords = Revision
Propchange:
velocity/engine/trunk/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java?rev=691519&r1=691518&r2=691519&view=diff
==============================================================================
---
velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java
(original)
+++
velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java
Tue Sep 2 22:36:11 2008
@@ -47,14 +47,10 @@
* @version $Id$
* @since 1.6
*/
-public class EvaluateContext implements InternalContextAdapter
+public class EvaluateContext extends ChainedInternalContextAdapter
{
/** container for any local items */
Context localContext;
-
- /** the base context store. This is the 'global' context */
- InternalContextAdapter innerContext = null;
-
boolean allowRendering = true;
/**
@@ -64,7 +60,7 @@
*/
public EvaluateContext( InternalContextAdapter inner, RuntimeServices
rsvc )
{
- innerContext = inner;
+ super(inner);
initContext(rsvc);
}
@@ -118,23 +114,6 @@
}
}
-
- /**
- * Return the inner / user context.
- * @return The inner / user context.
- */
- public Context getInternalUserContext()
- {
- return innerContext.getInternalUserContext();
- }
-
- /**
- * @see org.apache.velocity.context.InternalWrapperContext#getBaseContext()
- */
- public InternalContextAdapter getBaseContext()
- {
- return innerContext.getBaseContext();
- }
/**
* Put method also stores values in local scope
@@ -168,7 +147,7 @@
if ( o == null)
{
- o = innerContext.get( key );
+ o = super.get( key );
}
return o;
@@ -179,7 +158,7 @@
*/
public boolean containsKey(Object key)
{
- return localContext.containsKey(key) || innerContext.containsKey(key);
+ return localContext.containsKey(key) || super.containsKey(key);
}
/**
@@ -194,7 +173,7 @@
keys.add(localKeys[i]);
}
- Object[] innerKeys = innerContext.getKeys();
+ Object[] innerKeys = super.getKeys();
for (int i=0; i < innerKeys.length; i++)
{
keys.add(innerKeys[i]);
@@ -211,86 +190,6 @@
}
/**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#pushCurrentTemplateName(java.lang.String)
- */
- public void pushCurrentTemplateName( String s )
- {
- innerContext.pushCurrentTemplateName( s );
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#popCurrentTemplateName()
- */
- public void popCurrentTemplateName()
- {
- innerContext.popCurrentTemplateName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentTemplateName()
- */
- public String getCurrentTemplateName()
- {
- return innerContext.getCurrentTemplateName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getTemplateNameStack()
- */
- public Object[] getTemplateNameStack()
- {
- return innerContext.getTemplateNameStack();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#pushCurrentMacroName(java.lang.String)
- */
- public void pushCurrentMacroName( String s )
- {
- innerContext.pushCurrentMacroName( s );
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#popCurrentMacroName()
- */
- public void popCurrentMacroName()
- {
- innerContext.popCurrentMacroName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentMacroName()
- */
- public String getCurrentMacroName()
- {
- return innerContext.getCurrentMacroName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentMacroCallDepth()
- */
- public int getCurrentMacroCallDepth()
- {
- return innerContext.getCurrentMacroCallDepth();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getMacroNameStack()
- */
- public Object[] getMacroNameStack()
- {
- return innerContext.getMacroNameStack();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#icacheGet(java.lang.Object)
- */
- public IntrospectionCacheData icacheGet( Object key )
- {
- return innerContext.icacheGet( key );
- }
-
- /**
* Allows callers to explicitly put objects in the local context.
* Objects added to the context through this method always end up
* in the top-level context of possible wrapped contexts.
@@ -305,14 +204,6 @@
}
/**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#icachePut(java.lang.Object,
org.apache.velocity.util.introspection.IntrospectionCacheData)
- */
- public void icachePut( Object key, IntrospectionCacheData o )
- {
- innerContext.icachePut( key, o );
- }
-
- /**
* @see
org.apache.velocity.context.InternalHousekeepingContext#getAllowRendering()
*/
public boolean getAllowRendering()
@@ -328,57 +219,4 @@
allowRendering = false;
}
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#setMacroLibraries(List)
- */
- public void setMacroLibraries(List macroLibraries)
- {
- innerContext.setMacroLibraries(macroLibraries);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getMacroLibraries()
- */
- public List getMacroLibraries()
- {
- return innerContext.getMacroLibraries();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalEventContext#attachEventCartridge(org.apache.velocity.app.event.EventCartridge)
- */
- public EventCartridge attachEventCartridge( EventCartridge ec )
- {
- EventCartridge cartridge = innerContext.attachEventCartridge( ec );
- return cartridge;
- }
-
- /**
- * @see
org.apache.velocity.context.InternalEventContext#getEventCartridge()
- */
- public EventCartridge getEventCartridge()
- {
- return innerContext.getEventCartridge();
- }
-
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#setCurrentResource(org.apache.velocity.runtime.resource.Resource)
- */
- public void setCurrentResource( Resource r )
- {
- innerContext.setCurrentResource( r );
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentResource()
- */
- public Resource getCurrentResource()
- {
- return innerContext.getCurrentResource();
- }
}
-
-
-
-
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java?rev=691519&r1=691518&r2=691519&view=diff
==============================================================================
---
velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java
(original)
+++
velocity/engine/trunk/src/java/org/apache/velocity/context/ProxyVMContext.java
Tue Sep 2 22:36:11 2008
@@ -49,7 +49,7 @@
* @version $Id$
* @since 1.6
*/
-public class ProxyVMContext implements InternalContextAdapter
+public class ProxyVMContext extends ChainedInternalContextAdapter
{
/** container for our macro AST node arguments. Size must be power of 2. */
Map vmproxyhash = new HashMap(8, 0.8f);
@@ -57,9 +57,6 @@
/** container for any local or constant macro arguments. Size must be
power of 2. */
Map localcontext = new HashMap(8, 0.8f);;
- /** the base context store. This is the 'global' context */
- InternalContextAdapter innerContext;
-
/** context that we are wrapping */
InternalContextAdapter wrappedContext;
@@ -78,29 +75,12 @@
RuntimeServices rsvc,
boolean localContextScope)
{
+ super(inner);
+
this.localContextScope = localContextScope;
this.rsvc = rsvc;
wrappedContext = inner;
- innerContext = inner.getBaseContext();
- }
-
- /**
- * Return the inner / user context.
- *
- * @return The inner / user context.
- */
- public Context getInternalUserContext()
- {
- return innerContext.getInternalUserContext();
- }
-
- /**
- * @see org.apache.velocity.context.InternalWrapperContext#getBaseContext()
- */
- public InternalContextAdapter getBaseContext()
- {
- return innerContext.getBaseContext();
}
/**
@@ -223,7 +203,7 @@
}
else
{
- return innerContext.put(key, value);
+ return super.put(key, value);
}
}
}
@@ -293,7 +273,7 @@
if (o == null)
{
- o = innerContext.get(key);
+ o = super.get(key);
}
}
@@ -335,163 +315,10 @@
Object oldValue = localcontext.remove(key);
if (oldValue == null)
{
- oldValue = innerContext.remove(key);
+ oldValue = super.remove(key);
}
return oldValue;
}
}
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#pushCurrentTemplateName(java.lang.String)
- */
- public void pushCurrentTemplateName(String s)
- {
- innerContext.pushCurrentTemplateName(s);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#popCurrentTemplateName()
- */
- public void popCurrentTemplateName()
- {
- innerContext.popCurrentTemplateName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentTemplateName()
- */
- public String getCurrentTemplateName()
- {
- return innerContext.getCurrentTemplateName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getTemplateNameStack()
- */
- public Object[] getTemplateNameStack()
- {
- return innerContext.getTemplateNameStack();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#pushCurrentMacroName(java.lang.String)
- */
- public void pushCurrentMacroName(String s)
- {
- innerContext.pushCurrentMacroName(s);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#popCurrentMacroName()
- */
- public void popCurrentMacroName()
- {
- innerContext.popCurrentMacroName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentMacroName()
- */
- public String getCurrentMacroName()
- {
- return innerContext.getCurrentMacroName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentMacroCallDepth()
- */
- public int getCurrentMacroCallDepth()
- {
- return innerContext.getCurrentMacroCallDepth();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getMacroNameStack()
- */
- public Object[] getMacroNameStack()
- {
- return innerContext.getMacroNameStack();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#icacheGet(java.lang.Object)
- */
- public IntrospectionCacheData icacheGet(Object key)
- {
- return innerContext.icacheGet(key);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#icachePut(java.lang.Object,
- * org.apache.velocity.util.introspection.IntrospectionCacheData)
- */
- public void icachePut(Object key, IntrospectionCacheData o)
- {
- innerContext.icachePut(key, o);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getAllowRendering()
- */
- public boolean getAllowRendering()
- {
- return innerContext.getAllowRendering();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#setAllowRendering(boolean)
- */
- public void setAllowRendering(boolean v)
- {
- innerContext.setAllowRendering(v);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#setMacroLibraries(List)
- */
- public void setMacroLibraries(List macroLibraries)
- {
- innerContext.setMacroLibraries(macroLibraries);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getMacroLibraries()
- */
- public List getMacroLibraries()
- {
- return innerContext.getMacroLibraries();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalEventContext#attachEventCartridge(org.apache.velocity.app.event.EventCartridge)
- */
- public EventCartridge attachEventCartridge(EventCartridge ec)
- {
- EventCartridge cartridge = innerContext.attachEventCartridge(ec);
- return cartridge;
- }
-
- /**
- * @see
org.apache.velocity.context.InternalEventContext#getEventCartridge()
- */
- public EventCartridge getEventCartridge()
- {
- return innerContext.getEventCartridge();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#setCurrentResource(org.apache.velocity.runtime.resource.Resource)
- */
- public void setCurrentResource(Resource r)
- {
- innerContext.setCurrentResource(r);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentResource()
- */
- public Resource getCurrentResource()
- {
- return innerContext.getCurrentResource();
- }
}
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java?rev=691519&r1=691518&r2=691519&view=diff
==============================================================================
---
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
(original)
+++
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
Tue Sep 2 22:36:11 2008
@@ -25,6 +25,7 @@
import java.util.List;
import org.apache.velocity.app.event.EventCartridge;
+import org.apache.velocity.context.ChainedInternalContextAdapter;
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
@@ -58,9 +59,8 @@
* All puts and gets are passed through, except for the foreach iterator
key.
* @since 1.5
*/
- protected static class NullHolderContext implements InternalContextAdapter
+ protected static class NullHolderContext extends
ChainedInternalContextAdapter
{
- private InternalContextAdapter innerContext = null;
private String loopVariableKey = "";
private boolean active = true;
@@ -71,7 +71,7 @@
*/
private NullHolderContext( String key, InternalContextAdapter context )
{
- innerContext = context;
+ super(context);
if( key != null )
loopVariableKey = key;
}
@@ -85,7 +85,7 @@
{
return ( active && loopVariableKey.equals(key) )
? null
- : innerContext.get(key);
+ : super.get(key);
}
/**
@@ -98,7 +98,7 @@
active = true;
}
- return innerContext.put( key, value );
+ return super.put( key, value );
}
/**
@@ -115,23 +115,6 @@
return put(key, value);
}
- /**
- * Does the context contain the key
- * @see
org.apache.velocity.context.InternalContextAdapter#containsKey(java.lang.Object
key)
- */
- public boolean containsKey( Object key )
- {
- return innerContext.containsKey(key);
- }
-
- /**
- * @see org.apache.velocity.context.InternalContextAdapter#getKeys()
- */
- public Object[] getKeys()
- {
- return innerContext.getKeys();
- }
-
/**
* Remove an object from the context
* @see
org.apache.velocity.context.InternalContextAdapter#remove(java.lang.Object key)
@@ -142,186 +125,8 @@
{
active = false;
}
- return innerContext.remove(key);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#pushCurrentTemplateName(java.lang.String
s)
- */
- public void pushCurrentTemplateName(String s)
- {
- innerContext.pushCurrentTemplateName(s);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#popCurrentTemplateName()
- */
- public void popCurrentTemplateName()
- {
- innerContext.popCurrentTemplateName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#getCurrentTemplateName()
- */
- public String getCurrentTemplateName()
- {
- return innerContext.getCurrentTemplateName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#getTemplateNameStack()
- */
- public Object[] getTemplateNameStack()
- {
- return innerContext.getTemplateNameStack();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#pushCurrentMacroName(java.lang.String)
- * @since 1.6
- */
- public void pushCurrentMacroName( String s )
- {
- innerContext.pushCurrentMacroName( s );
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#popCurrentMacroName()
- * @since 1.6
- */
- public void popCurrentMacroName()
- {
- innerContext.popCurrentMacroName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentMacroName()
- * @since 1.6
- */
- public String getCurrentMacroName()
- {
- return innerContext.getCurrentMacroName();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getCurrentMacroCallDepth()
- * @since 1.6
- */
- public int getCurrentMacroCallDepth()
- {
- return innerContext.getCurrentMacroCallDepth();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalHousekeepingContext#getMacroNameStack()
- * @since 1.6
- */
- public Object[] getMacroNameStack()
- {
- return innerContext.getMacroNameStack();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#icacheGet(java.lang.Object
key)
- */
- public IntrospectionCacheData icacheGet(Object key)
- {
- return innerContext.icacheGet(key);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#icachePut(java.lang.Object
key, org.apache.velocity.util.introspection.IntrospectionCacheData o)
- */
- public void icachePut(Object key, IntrospectionCacheData o)
- {
- innerContext.icachePut(key,o);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#setCurrentResource(org.apache.velocity.runtime.resource.Resource
r)
- */
- public void setCurrentResource( Resource r )
- {
- innerContext.setCurrentResource(r);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#getCurrentResource()
- */
- public Resource getCurrentResource()
- {
- return innerContext.getCurrentResource();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#getBaseContext()
- */
- public InternalContextAdapter getBaseContext()
- {
- return innerContext.getBaseContext();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#getInternalUserContext()
- */
- public Context getInternalUserContext()
- {
- return innerContext.getInternalUserContext();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#attachEventCartridge(org.apache.velocity.app.event.EventCartridge
ec)
- */
- public EventCartridge attachEventCartridge(EventCartridge ec)
- {
- EventCartridge cartridge = innerContext.attachEventCartridge( ec );
-
- return cartridge;
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#getEventCartridge()
- */
- public EventCartridge getEventCartridge()
- {
- return innerContext.getEventCartridge();
+ return super.remove(key);
}
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#getAllowRendering()
- */
- public boolean getAllowRendering()
- {
- return innerContext.getAllowRendering();
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#setAllowRendering(boolean v)
- */
- public void setAllowRendering(boolean v)
- {
- innerContext.setAllowRendering(v);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#setMacroLibraries(List)
- * @since 1.6
- */
- public void setMacroLibraries(List macroLibraries)
- {
- innerContext.setMacroLibraries(macroLibraries);
- }
-
- /**
- * @see
org.apache.velocity.context.InternalContextAdapter#getMacroLibraries()
- * @since 1.6
- */
- public List getMacroLibraries()
- {
- return innerContext.getMacroLibraries();
- }
-
}
/**