1 package net.sourceforge.pmd.lang.vm.ast; 2 3 import org.apache.commons.lang3.builder.ToStringBuilder; 4 5 /* 6 * Licensed to the Apache Software Foundation (ASF) under one 7 * or more contributor license agreements. See the NOTICE file 8 * distributed with this work for additional information 9 * regarding copyright ownership. The ASF licenses this file 10 * to you under the Apache License, Version 2.0 (the 11 * "License"); you may not use this file except in compliance 12 * with the License. You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, 17 * software distributed under the License is distributed on an 18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 * KIND, either express or implied. See the License for the 20 * specific language governing permissions and limitations 21 * under the License. 22 */ 23 24 /** 25 * This class is responsible for handling the pluggable directives in VTL. 26 * 27 * For example : #foreach() 28 * 29 * Please look at the Parser.jjt file which is what controls the generation of this class. 30 * 31 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a> 32 * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a> 33 * @author <a href="mailto:kav@kav.dk">Kasper Nielsen</a> 34 * @version $Id: ASTDirective.java 724825 2008-12-09 18:56:06Z nbubna $ 35 */ 36 public class ASTDirective extends AbstractVmNode { 37 private String directiveName = ""; 38 39 /** 40 * @param id 41 */ 42 public ASTDirective(final int id) { 43 super(id); 44 } 45 46 /** 47 * @param p 48 * @param id 49 */ 50 public ASTDirective(final VmParser p, final int id) { 51 super(p, id); 52 } 53 54 /** 55 * @see org.apache.velocity.runtime.parser.node.SimpleNode#jjtAccept(org.apache.velocity.runtime.parser.node.VmParserVisitor, 56 * java.lang.Object) 57 */ 58 @Override 59 public Object jjtAccept(final VmParserVisitor visitor, final Object data) { 60 return visitor.visit(this, data); 61 } 62 63 /** 64 * Sets the directive name. Used by the parser. This keeps us from having to dig it out of the token stream and 65 * gives the parse the change to override. 66 * 67 * @param str 68 */ 69 public void setDirectiveName(final String str) { 70 directiveName = str; 71 } 72 73 /** 74 * Gets the name of this directive. 75 * 76 * @return The name of this directive. 77 */ 78 public String getDirectiveName() { 79 return directiveName; 80 } 81 82 /** 83 * @since 1.5 84 */ 85 @Override 86 public String toString() { 87 return new ToStringBuilder(this).appendSuper(super.toString()).append("directiveName", getDirectiveName()) 88 .toString(); 89 } 90 91 }