You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by ge...@apache.org on 2001/02/05 05:30:02 UTC
cvs commit: jakarta-velocity/src/java/org/apache/velocity/context InternalContextAdapterImpl.java InternalContextBase.java InternalHousekeepingContext.java VMContext.java
geirm 01/02/04 20:30:02
Modified: src/java/org/apache/velocity/context
InternalContextAdapterImpl.java
InternalContextBase.java
InternalHousekeepingContext.java VMContext.java
Log:
Small changes to support Christoph's #parse() template name stack
Revision Changes Path
1.2 +12 -2 jakarta-velocity/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java
Index: InternalContextAdapterImpl.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InternalContextAdapterImpl.java 2001/01/13 16:33:57 1.1
+++ InternalContextAdapterImpl.java 2001/02/05 04:30:02 1.2
@@ -130,14 +130,24 @@
/* --- InternalContext interface methods --- */
- public void setCurrentTemplateName( String s )
+ public void pushCurrentTemplateName( String s )
{
- icb.setCurrentTemplateName( s );
+ icb.pushCurrentTemplateName( s );
}
+
+ public void popCurrentTemplateName()
+ {
+ icb.popCurrentTemplateName();
+ }
public String getCurrentTemplateName()
{
return icb.getCurrentTemplateName();
+ }
+
+ public Object[] getTemplateNameStack()
+ {
+ return icb.getTemplateNameStack();
}
public IntrospectionCacheData icacheGet( Object key )
1.4 +32 -9 jakarta-velocity/src/java/org/apache/velocity/context/InternalContextBase.java
Index: InternalContextBase.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/context/InternalContextBase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InternalContextBase.java 2001/01/13 16:36:19 1.3
+++ InternalContextBase.java 2001/02/05 04:30:02 1.4
@@ -55,6 +55,7 @@
*/
import java.util.HashMap;
+import java.util.Stack;
import java.io.Serializable;
import org.apache.velocity.util.introspection.IntrospectionCacheData;
@@ -72,30 +73,39 @@
* is derived from this.
*
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
- * @version $Id: InternalContextBase.java,v 1.3 2001/01/13 16:36:19 geirm Exp $
+ * @version $Id: InternalContextBase.java,v 1.4 2001/02/05 04:30:02 geirm Exp $
*/
class InternalContextBase implements InternalHousekeepingContext,Serializable
{
/**
* cache for node/context specific introspection information
*/
- private HashMap introspectionCache = new HashMap();
+ private HashMap introspectionCache = new HashMap(33);
/**
- * Current template name.
+ * Template name stack. The stack top contains the current template name.
*/
- private String strCurrentTemplate = "<undef>";
+ private Stack templateNameStack = new Stack();
/**
- * set the current template name
+ * set the current template name on top of stack
*
- * @param s current template name to set
+ * @param s current template name
*/
- public void setCurrentTemplateName( String s )
+ public void pushCurrentTemplateName( String s )
{
- strCurrentTemplate = s;
+ templateNameStack.push(s);
return;
}
+
+ /**
+ * remove the current template name from stack
+ */
+ public void popCurrentTemplateName()
+ {
+ templateNameStack.pop();
+ return;
+ }
/**
* get the current template name
@@ -103,8 +113,21 @@
* @return String current template name
*/
public String getCurrentTemplateName()
+ {
+ if ( templateNameStack.empty() )
+ return "<undef>";
+ else
+ return (String) templateNameStack.peek();
+ }
+
+ /**
+ * get the current template name stack
+ *
+ * @return Object[] with the template name stack contents.
+ */
+ public Object[] getTemplateNameStack()
{
- return strCurrentTemplate;
+ return templateNameStack.toArray();
}
/**
1.2 +17 -10 jakarta-velocity/src/java/org/apache/velocity/context/InternalHousekeepingContext.java
Index: InternalHousekeepingContext.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/context/InternalHousekeepingContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InternalHousekeepingContext.java 2001/01/13 16:24:41 1.1
+++ InternalHousekeepingContext.java 2001/02/05 04:30:02 1.2
@@ -66,16 +66,22 @@
* support, as well as node-local context data introspection caching.
*
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
- * @version $Id: InternalHousekeepingContext.java,v 1.1 2001/01/13 16:24:41 geirm Exp $
+ * @author <a href="mailto:Christoph.Reck@dlr.de">Christoph Reck</a>
+ * @version $Id: InternalHousekeepingContext.java,v 1.2 2001/02/05 04:30:02 geirm Exp $
*/
interface InternalHousekeepingContext
{
/**
- * set the current template name
+ * set the current template name on top of stack
*
- * @param s current template name to set
+ * @param s current template name
*/
- void setCurrentTemplateName( String s );
+ void pushCurrentTemplateName( String s );
+
+ /**
+ * remove the current template name from stack
+ */
+ void popCurrentTemplateName();
/**
* get the current template name
@@ -85,6 +91,13 @@
String getCurrentTemplateName();
/**
+ * Returns the template name stack in form of an array.
+ *
+ * @return Object[] with the template name stack contents.
+ */
+ Object[] getTemplateNameStack();
+
+ /**
* returns an IntrospectionCache Data (@see IntrospectionCacheData)
* object if exists for the key
*
@@ -102,9 +115,3 @@
*/
void icachePut( Object key, IntrospectionCacheData o );
}
-
-
-
-
-
-
1.3 +13 -3 jakarta-velocity/src/java/org/apache/velocity/context/VMContext.java
Index: VMContext.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/context/VMContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- VMContext.java 2001/01/14 14:53:14 1.2
+++ VMContext.java 2001/02/05 04:30:02 1.3
@@ -72,7 +72,7 @@
* local to the vm, protecting the global context.
*
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
- * @version $Id: VMContext.java,v 1.2 2001/01/14 14:53:14 geirm Exp $
+ * @version $Id: VMContext.java,v 1.3 2001/02/05 04:30:02 geirm Exp $
*/
public class VMContext implements InternalContextAdapter
{
@@ -268,14 +268,24 @@
return vmproxyhash.remove( key );
}
- public void setCurrentTemplateName( String s )
+ public void pushCurrentTemplateName( String s )
{
- innerContext.setCurrentTemplateName( s );
+ innerContext.pushCurrentTemplateName( s );
}
+
+ public void popCurrentTemplateName()
+ {
+ innerContext.popCurrentTemplateName();
+ }
public String getCurrentTemplateName()
{
return innerContext.getCurrentTemplateName();
+ }
+
+ public Object[] getTemplateNameStack()
+ {
+ return innerContext.getTemplateNameStack();
}
public IntrospectionCacheData icacheGet( Object key )