geirm 01/12/06 20:43:21
Modified: src/java/org/apache/velocity/runtime/parser/node
ASTReference.java
Log:
Fix for the bug reported by Lukas Zimmermann <[EMAIL PROTECTED]>
where a
$foo.bar()THING
resulted in 'THING' being a reference. This fix is the simplest way out of
it, and will be properly solved with the great MORE fix. But this is safe and
efficient for now.
Revision Changes Path
1.42 +26 -3
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.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- ASTReference.java 2001/10/22 03:53:24 1.41
+++ ASTReference.java 2001/12/07 04:43:21 1.42
@@ -85,7 +85,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Christoph Reck</a>
* @author <a href="mailto:[EMAIL PROTECTED]>Kent Johnson</a>
- * @version $Id: ASTReference.java,v 1.41 2001/10/22 03:53:24 jon Exp $
+ * @version $Id: ASTReference.java,v 1.42 2001/12/07 04:43:21 geirm Exp $
*/
public class ASTReference extends SimpleNode
{
@@ -93,6 +93,7 @@
private static final int NORMAL_REFERENCE = 1;
private static final int FORMAL_REFERENCE = 2;
private static final int QUIET_REFERENCE = 3;
+ private static final int RUNT = 4;
private int referenceType;
private String nullString;
@@ -171,6 +172,10 @@
public Object execute(Object o, InternalContextAdapter context)
throws MethodInvocationException
{
+
+ if ( referenceType == RUNT )
+ return null;
+
/*
* get the root object from the context
*/
@@ -235,6 +240,13 @@
public boolean render( InternalContextAdapter context, Writer writer)
throws IOException, MethodInvocationException
{
+
+ if (referenceType == RUNT )
+ {
+ writer.write( rootString );
+ return true;
+ }
+
Object value = execute(null, context);
/*
@@ -665,7 +677,7 @@
referenceType = FORMAL_REFERENCE;
return t.next.image;
}
- else
+ else if ( t.image.startsWith("$") )
{
/*
* just nip off the '$' so we have
@@ -674,7 +686,18 @@
referenceType = NORMAL_REFERENCE;
return t.image.substring(1);
- }
+ }
+ else
+ {
+ /*
+ * this is a 'RUNT', which can happen in certain circumstances where
+ * the parser is fooled into believeing that an IDENTIFIER is a real
+ * reference. Another 'dreaded' MORE hack :).
+ */
+ referenceType = RUNT;
+ return t.image;
+ }
+
}
public Object getVariableValue(Context context, String variable)
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>