1 package com.puppycrawl.tools.checkstyle.api; 20 21 28 public abstract class AbstractViolationReporter 29 extends AutomaticBean 30 { 31 32 private static final Object [] EMPTY_OBJECT_ARRAY = new Object [0]; 33 34 35 private SeverityLevel mSeverityLevel = SeverityLevel.ERROR; 36 37 38 private String mId; 39 40 46 public final SeverityLevel getSeverityLevel() 47 { 48 return mSeverityLevel; 49 } 50 51 58 public final void setSeverity(String aSeverity) 59 { 60 mSeverityLevel = SeverityLevel.getInstance(aSeverity); 61 } 62 63 68 public final String getSeverity() 69 { 70 return mSeverityLevel.getName(); 71 } 72 73 77 public final String getId() 78 { 79 return mId; 80 } 81 82 86 public final void setId(final String aId) 87 { 88 mId = aId; 89 } 90 91 97 protected final void log(int aLine, String aKey) 98 { 99 log(aLine, aKey, EMPTY_OBJECT_ARRAY); 100 } 101 102 109 protected final void log(int aLineNo, String aKey, Object aArg0) 110 { 111 log(aLineNo, aKey, new Object [] {aArg0}); 112 } 113 114 122 protected final void log(int aLineNo, String aKey, 123 Object aArg0, Object aArg1) 124 { 125 log(aLineNo, aKey, new Object [] {aArg0, aArg1}); 126 } 127 128 135 protected final void log(int aLineNo, int aColNo, String aKey) 136 { 137 log(aLineNo, aColNo, aKey, EMPTY_OBJECT_ARRAY); 138 } 139 140 147 protected final void log(DetailAST aAST, String aKey) 148 { 149 log(aAST.getLineNo(), aAST.getColumnNo(), aKey); 150 } 151 152 160 protected final void log(int aLineNo, int aColNo, String aKey, 161 Object aArg0) 162 { 163 log(aLineNo, aColNo, aKey, new Object [] {aArg0}); 164 } 165 166 174 protected final void log(DetailAST aAST, String aKey, Object aArg0) 175 { 176 log(aAST.getLineNo(), aAST.getColumnNo(), aKey, aArg0); 177 } 178 187 protected final void log(int aLineNo, int aColNo, String aKey, 188 Object aArg0, Object aArg1) 189 { 190 log(aLineNo, aColNo, aKey, new Object [] {aArg0, aArg1}); 191 } 192 193 202 protected final void log(DetailAST aAST, String aKey, 203 Object aArg0, Object aArg1) 204 { 205 log(aAST.getLineNo(), aAST.getColumnNo(), aKey, aArg0, aArg1); 206 } 207 208 224 protected String getMessageBundle() 225 { 226 final String className = this.getClass().getName(); 227 return getMessageBundle(className); 228 } 229 230 236 String getMessageBundle(final String aClassName) 237 { 238 final int endIndex = aClassName.lastIndexOf('.'); 239 final String messages = "messages"; 240 if (endIndex < 0) { 241 return messages; 242 } 243 final String packageName = aClassName.substring(0, endIndex); 244 return packageName + "." + messages; 245 } 246 247 256 protected abstract void log(int aLine, String aKey, Object aArgs[]); 257 258 268 protected abstract void log(int aLine, 269 int aCol, 270 String aKey, 271 Object [] aArgs); 272 273 } 274 | Popular Tags |