1 package org.apache.velocity.runtime.parser.node; 2 3 18 19 import org.apache.velocity.runtime.parser.Parser; 20 import org.apache.velocity.runtime.parser.Token; 21 import org.apache.velocity.context.InternalContextAdapter; 22 import org.apache.velocity.exception.ResourceNotFoundException; 23 import org.apache.velocity.exception.ParseErrorException; 24 import org.apache.velocity.exception.MethodInvocationException; 25 26 import java.io.IOException ; 27 import java.io.Writer ; 28 29 35 public class ASTComment extends SimpleNode 36 { 37 private static final char[] ZILCH = "".toCharArray(); 38 39 private char[] carr; 40 41 public ASTComment(int id) 42 { 43 super(id); 44 } 45 46 public ASTComment(Parser p, int id) 47 { 48 super(p, id); 49 } 50 51 52 public Object jjtAccept(ParserVisitor visitor, Object data) 53 { 54 return visitor.visit(this, data); 55 } 56 57 60 public Object init(InternalContextAdapter context, Object data) 61 throws Exception 62 { 63 Token t = getFirstToken(); 64 65 int loc1 = t.image.indexOf("##"); 66 int loc2 = t.image.indexOf("#*"); 67 68 if (loc1 == -1 && loc2 == -1) 69 { 70 carr = ZILCH; 71 } 72 else 73 { 74 carr = t.image.substring(0, (loc1 == -1) ? loc2 : loc1).toCharArray(); 75 } 76 77 return data; 78 } 79 80 public boolean render( InternalContextAdapter context, Writer writer) 81 throws IOException , MethodInvocationException, ParseErrorException, ResourceNotFoundException 82 { 83 writer.write(carr); 84 85 return true; 86 } 87 88 } 89 | Popular Tags |