| 34 | import pcgen.util.Logging; |
| 35 | |
| 36 | public class CharacterFilter implements OutputFilter |
| 37 | { |
| 38 | private String outputFilterName = ""; |
| 39 | private Map<Integer, String> outputFilter = null; |
| 40 | |
| 41 | /** |
| 42 | * Create a new CharacterFilter instance suitable for processing output to |
| 43 | * files produced using the supplied template. |
| 44 | * |
| 45 | * @param templateFileName The file name of the output template file. |
| 46 | */ |
| 47 | public CharacterFilter(String templateFileName) |
| 48 | { |
| 49 | |
| 50 | final int idx = templateFileName.lastIndexOf('.'); |
| 51 | |
| 52 | String filterName = templateFileName; |
| 53 | if (idx >= 0) |
| 54 | { |
| 55 | filterName = filterName.substring(idx + 1); |
| 56 | } |
| 57 | |
| 58 | filterName = filterName.toLowerCase(); |
| 59 | |
| 60 | if (filterName.equals(outputFilterName)) |
| 61 | { |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | outputFilter = null; |
| 66 | |
| 67 | filterName = new File(ConfigurationSettings.getSystemsDir()) + File.separator + "outputFilters" + File.separator |
| 68 | + filterName + Constants.EXTENSION_LIST_FILE; |
| 69 | |
| 70 | final File filterFile = new File(filterName); |
| 71 | |
| 72 | if (filterFile.canRead() && filterFile.isFile()) |
| 73 | { |
| 74 | |
| 75 | try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filterFile), StandardCharsets.UTF_8))) |
| 76 | { |
| 77 | |
| 78 | outputFilterName = filterName; |
| 79 | outputFilter = new HashMap<>(); |
| 80 | |
| 81 | while (true) |
| 82 | { |
| 83 | final String aLine = br.readLine(); |
| 84 | |
| 85 | if (aLine == null) |
| 86 | { |
| 87 | break; |
| 88 | } |
| 89 | |
| 90 | final List<String> filterEntry = CoreUtility.split(aLine, '\t'); |
| 91 | |
| 92 | if (filterEntry.size() >= 2) |
| 93 | { |
nothing calls this directly
no outgoing calls
no test coverage detected