@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException { String block = ""; TypeDef clazz = null; for (int i = 0; i < node.jjtGetNumChildren(); i++) { if (node.jjtGetChild(i) != null) { if (!(node.jjtGetChild(i) instanceof ASTBlock)) { //reading and casting inline parameters if (i == 0) { clazz = (TypeDef) node.jjtGetChild(i).value(context); } else { break; } } else { //reading block content and rendering it StringWriter blockContent = new StringWriter(); node.jjtGetChild(i).render(context, blockContent); block = blockContent.toString(); break; } } } writeClazz(writer, clazz, block); return true; }
@Override protected Params getParams(InternalContextAdapter context, Node node) throws IOException { final Params params = new Params(); params.setPrefix("WHERE"); params.setPrefixOverrides("AND |OR |AND\n|OR\n|AND\r|OR\r"); if (node.jjtGetNumChildren() == 1) { final Node child = node.jjtGetChild(0); if (child instanceof ASTBlock) { StringWriter blockContent = new StringWriter(); child.render(context, blockContent); params.setBody(blockContent.toString().trim()); return params; } } return null; }
@Override protected Params getParams(InternalContextAdapter context, Node node) throws IOException { final Params params = new Params(); params.setPrefix("SET"); params.setSuffixOverrides(","); if (node.jjtGetNumChildren() == 1) { final Node child = node.jjtGetChild(0); if (child instanceof ASTBlock) { StringWriter blockContent = new StringWriter(); child.render(context, blockContent); params.setBody(blockContent.toString().trim()); return params; } } return null; }
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException { String block = ""; Method method = null; Boolean isInterface = false; for (int i = 0; i < node.jjtGetNumChildren(); i++) { if (node.jjtGetChild(i) != null) { if (!(node.jjtGetChild(i) instanceof ASTBlock)) { //reading and casting inline parameters if (i == 0) { method = (Method) node.jjtGetChild(i).value(context); } else if (i == 1) { isInterface = (Boolean) node.jjtGetChild(i).value(context); } else { break; } } else { //reading block content and rendering it StringWriter blockContent = new StringWriter(); node.jjtGetChild(i).render(context, blockContent); block = blockContent.toString(); break; } } } writeMethod(writer, method, block, isInterface); return true; }
protected Params getParams(final InternalContextAdapter context, final Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { final Params params = new Params(); final int nodes = node.jjtGetNumChildren(); for (int i = 0; i < nodes; i++) { Node child = node.jjtGetChild(i); if (child != null) { if (!(child instanceof ASTBlock)) { if (i == 0) { params.setPrefix(String.valueOf(child.value(context))); } else if (i == 1) { params.setPrefixOverrides(String.valueOf(child.value(context)).toUpperCase(Locale.ENGLISH)); } else if (i == 2) { params.setSuffix(String.valueOf(child.value(context))); } else if (i == 3) { params.setSuffixOverrides(String.valueOf(child.value(context)).toUpperCase(Locale.ENGLISH)); } else { break; } } else { StringWriter blockContent = new StringWriter(); child.render(context, blockContent); if ("".equals(blockContent.toString().trim())) { return null; } params.setBody(blockContent.toString().trim()); break; } } } return params; }
protected Params getParams(final InternalContextAdapter context, final Node node) throws IOException { final Params params = new Params(); final int nodes = node.jjtGetNumChildren(); for (int i = 0; i < nodes; i++) { Node child = node.jjtGetChild(i); if (child != null) { if (!(child instanceof ASTBlock)) { if (i == 0) { params.setPrefix(String.valueOf(child.value(context))); } else if (i == 1) { params.setPrefixOverrides(String.valueOf(child.value(context)).toUpperCase(Locale.ENGLISH)); } else if (i == 2) { params.setSuffix(String.valueOf(child.value(context))); } else if (i == 3) { params.setSuffixOverrides(String.valueOf(child.value(context)).toUpperCase(Locale.ENGLISH)); } else { break; } } else { StringWriter blockContent = new StringWriter(); child.render(context, blockContent); params.setBody(blockContent.toString().trim()); break; } } } return params; }
/** * @see org.apache.velocity.runtime.parser.node.ParserVisitor#visit(org.apache.velocity.runtime.parser.node.ASTBlock, * java.lang.Object) */ public Object visit(ASTBlock aNode, Object aData) { return aNode.childrenAccept(this, aData); }