jvanzyl 00/11/02 14:24:22
Modified: src/java/org/apache/velocity/runtime/parser/node
ASTReference.java SimpleNode.java
Log:
- we can now get the literal value for any node easily.
Revision Changes Path
1.7 +0 -36
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Index: ASTReference.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ASTReference.java 2000/11/02 19:33:08 1.6
+++ ASTReference.java 2000/11/02 22:24:20 1.7
@@ -41,12 +41,6 @@
return visitor.visit(this, data);
}
- public void jjtClose()
- {
- super.jjtClose();
- last.last = true;
- }
-
public Object init(Context context, Object data) throws Exception
{
rootString = getRoot();
@@ -247,36 +241,6 @@
nullString = literal();
return t.image.substring(1);
}
- }
-
- /**
- * Return the literal string representation
- * of a reference. Used when a reference has
- * a null value.
- *
- * For a variable reference like $foo this isn't
- * working. hmmm.
- */
- public String literal()
- {
- Token t = getFirstToken();
- StringBuffer sb = new StringBuffer(t.image);
-
- // Check to see if there are any children. If
- // there aren't then we can return with the first
- // token becasue it's a shorthand variable reference
- // like $foo.
- if (children == null && referenceType == NORMAL_REFERENCE)
- return sb.toString();
-
- while(t.next != null && t.next.last == false)
- {
- t = t.next;
- sb.append(t.image);
- }
- sb.append(getLastToken().image);
-
- return sb.toString();
}
public Object getVariableValue(Context context, String variable)
1.7 +14 -5
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
Index: SimpleNode.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/SimpleNode.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SimpleNode.java 2000/11/02 19:33:09 1.6
+++ SimpleNode.java 2000/11/02 22:24:20 1.7
@@ -148,6 +148,20 @@
// All additional methods
+ public String literal()
+ {
+ Token t = first;
+ StringBuffer sb = new StringBuffer(t.image);
+
+ while (t != last)
+ {
+ t = t.next;
+ sb.append(t.image);
+ }
+
+ return sb.toString();
+ }
+
public Object init(Context context, Object data) throws Exception
{
int i, k = jjtGetNumChildren();
@@ -206,11 +220,6 @@
public int getInfo()
{
return info;
- }
-
- public String literal()
- {
- return first.image;
}
public void setInvalid()