1 19 20 package org.apache.cayenne.access.jdbc; 21 22 import java.io.IOException ; 23 import java.io.Writer ; 24 25 import org.apache.velocity.context.InternalContextAdapter; 26 import org.apache.velocity.exception.MethodInvocationException; 27 import org.apache.velocity.exception.ParseErrorException; 28 import org.apache.velocity.exception.ResourceNotFoundException; 29 import org.apache.velocity.runtime.directive.Directive; 30 import org.apache.velocity.runtime.parser.node.Node; 31 32 47 public class ChunkDirective extends Directive { 48 49 public String getName() { 50 return "chunk"; 51 } 52 53 public int getType() { 54 return BLOCK; 55 } 56 57 public boolean render(InternalContextAdapter context, Writer writer, Node node) 58 throws 59 IOException , 60 ResourceNotFoundException, 61 ParseErrorException, 62 MethodInvocationException { 63 64 if (node.jjtGetNumChildren() > 1 && !node.jjtGetChild(0).evaluate(context)) { 66 return false; 68 } 69 70 Node block = node.jjtGetChild(node.jjtGetNumChildren() - 1); 72 block.render(context, writer); 73 return true; 74 } 75 76 } 77 | Popular Tags |