View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.ast;
5   
6   import java.util.HashMap;
7   import java.util.Map;
8   
9   import net.sourceforge.pmd.PMD;
10  
11  public abstract class AbstractTokenManager {
12  
13      // Because the TokenMgrError class does not have access to the TokenManager instance, we
14      // cannot store the file name as an instance field, but must use a static.
15      private static ThreadLocal<String> fileName = new ThreadLocal<>();
16  
17      protected Map<Integer, String> suppressMap = new HashMap<>();
18      protected String suppressMarker = PMD.SUPPRESS_MARKER;
19  
20      public static void setFileName(String fileName) {
21  	AbstractTokenManager.fileName.set(fileName);
22      }
23  
24      public static String getFileName() {
25  	String fileName = AbstractTokenManager.fileName.get();
26  	return fileName == null ? "(no file name provided)" : fileName;
27      }
28  
29      public void setSuppressMarker(String marker) {
30  	this.suppressMarker = marker;
31      }
32  
33      public Map<Integer, String> getSuppressMap() {
34  	return suppressMap;
35      }
36  }