1 package org.apache.velocity.runtime.parser.node; 2 3 18 19 import org.apache.velocity.context.InternalContextAdapter; 20 import org.apache.velocity.runtime.parser.Parser; 21 import org.apache.velocity.exception.MethodInvocationException; 22 23 31 public class ASTAndNode extends SimpleNode 32 { 33 public ASTAndNode(int id) 34 { 35 super(id); 36 } 37 38 public ASTAndNode(Parser p, int id) 39 { 40 super(p, id); 41 } 42 43 44 public Object jjtAccept(ParserVisitor visitor, Object data) 45 { 46 return visitor.visit(this, data); 47 } 48 49 54 public Object value(InternalContextAdapter context ) 55 throws MethodInvocationException 56 { 57 return new Boolean ( evaluate( context ) ); 58 } 59 60 66 public boolean evaluate( InternalContextAdapter context) 67 throws MethodInvocationException 68 { 69 Node left = jjtGetChild(0); 70 Node right = jjtGetChild(1); 71 72 75 76 if (left == null || right == null) 77 { 78 rsvc.error( ( left == null ? "Left" : "Right" ) + " side of '&&' operation is null." 79 + " Operation not possible. " 80 + context.getCurrentTemplateName() + " [line " + getLine() 81 + ", column " + getColumn() + "]"); 82 return false; 83 } 84 85 88 89 if( left.evaluate( context ) ) 90 { 91 if ( right.evaluate( context ) ) 92 { 93 return true; 94 } 95 } 96 97 return false; 98 } 99 } 100 101 | Popular Tags |