jvanzyl 00/10/21 15:58:41
Modified: src/java/org/apache/velocity/runtime/parser/node
ASTReference.java
Log:
- added full logging for all reference errors.
Revision Changes Path
1.4 +17 -1
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ASTReference.java 2000/10/21 03:04:20 1.3
+++ ASTReference.java 2000/10/21 22:58:41 1.4
@@ -14,6 +14,12 @@
public class ASTReference extends SimpleNode
{
+ /* Reference types */
+ private static final int NORMAL_REFERENCE = 1;
+ private static final int FORMAL_REFERENCE = 2;
+ private static final int QUIET_REFERENCE = 3;
+
+ private int referenceType;
private String nullString;
private Object rootObject;
private Object value;
@@ -78,13 +84,20 @@
value = execute(null, context);
if (value == null)
+ {
writer.write(NodeUtils
.specialText(getFirstToken()) +
nullString);
+
+ if (referenceType != QUIET_REFERENCE)
+ Runtime.error(new ReferenceException("reference", this));
+ }
else
+ {
writer.write(NodeUtils
.specialText(getFirstToken()) +
value.toString());
+ }
return true;
}
@@ -169,6 +182,7 @@
if (t.image.equals("$!"))
{
+ referenceType = QUIET_REFERENCE;
nullString = "";
if (t.next.image.equals("{"))
@@ -181,12 +195,14 @@
else if (t.image.equals("${"))
{
// ${provider.Title}
+ referenceType = FORMAL_REFERENCE;
nullString = literal();
return t.next.image;
}
else
{
// $provider.Title
+ referenceType = NORMAL_REFERENCE;
nullString = literal();
return t.image.substring(1);
}
@@ -209,7 +225,7 @@
// there aren't then we can return with the first
// token becasue it's a shorthand variable reference
// like $foo.
- if (children == null)
+ if (children == null && referenceType == NORMAL_REFERENCE)
return sb.toString();
while(t.next != null && t.next.last == false)