1 package net.sourceforge.pmd.lang.vm.directive; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 /** 23 * Base class for all directives used in Velocity. 24 * 25 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a> 26 * @author Nathan Bubna 27 * @version $Id: Directive.java 778045 2009-05-23 22:17:46Z nbubna $ 28 */ 29 public abstract class Directive implements Cloneable 30 { 31 /** Block directive indicator */ 32 public static final int BLOCK = 1; 33 34 /** Line directive indicator */ 35 public static final int LINE = 2; 36 37 private int line = 0; 38 private int column = 0; 39 private boolean provideScope = false; 40 private String templateName; 41 42 /** 43 * Return the name of this directive. 44 * @return The name of this directive. 45 */ 46 public abstract String getName(); 47 48 /** 49 * Get the directive type BLOCK/LINE. 50 * @return The directive type BLOCK/LINE. 51 */ 52 public abstract int getType(); 53 54 /** 55 * Allows the template location to be set. 56 * @param line 57 * @param column 58 */ 59 public void setLocation( int line, int column ) 60 { 61 this.line = line; 62 this.column = column; 63 } 64 65 /** 66 * Allows the template location to be set. 67 * @param line 68 * @param column 69 */ 70 public void setLocation(int line, int column, String templateName) 71 { 72 setLocation(line, column); 73 this.templateName = templateName; 74 } 75 76 /** 77 * for log msg purposes 78 * @return The current line for log msg purposes. 79 */ 80 public int getLine() 81 { 82 return line; 83 } 84 85 /** 86 * for log msg purposes 87 * @return The current column for log msg purposes. 88 */ 89 public int getColumn() 90 { 91 return column; 92 } 93 94 /** 95 * @return The template file name this directive was defined in, or null if not 96 * defined in a file. 97 */ 98 public String getTemplateName() 99 { 100 return templateName; 101 } 102 103 /** 104 * @returns the name to be used when a scope control is provided for this 105 * directive. 106 */ 107 public String getScopeName() 108 { 109 return getName(); 110 } 111 112 /** 113 * @return true if there will be a scope control injected into the context 114 * when rendering this directive. 115 */ 116 public boolean isScopeProvided() 117 { 118 return provideScope; 119 } 120 121 }