1 56 package org.objectstyle.cayenne.access.jdbc; 57 58 import java.io.IOException ; 59 import java.io.Writer ; 60 61 import org.apache.velocity.context.InternalContextAdapter; 62 import org.apache.velocity.exception.MethodInvocationException; 63 import org.apache.velocity.exception.ParseErrorException; 64 import org.apache.velocity.exception.ResourceNotFoundException; 65 import org.apache.velocity.runtime.directive.Directive; 66 import org.apache.velocity.runtime.parser.node.Node; 67 68 83 public class ChunkDirective extends Directive { 84 85 public String getName() { 86 return "chunk"; 87 } 88 89 public int getType() { 90 return BLOCK; 91 } 92 93 public boolean render(InternalContextAdapter context, Writer writer, Node node) 94 throws 95 IOException , 96 ResourceNotFoundException, 97 ParseErrorException, 98 MethodInvocationException { 99 100 if (node.jjtGetNumChildren() > 1 && !node.jjtGetChild(0).evaluate(context)) { 102 return false; 104 } 105 106 Node block = node.jjtGetChild(node.jjtGetNumChildren() - 1); 108 block.render(context, writer); 109 return true; 110 } 111 112 } 113 | Popular Tags |