package mediawiki.task.config.nt2; import java.util.HashMap; import java.util.Map; import mediawiki.task.NormdatenTask2.NormdatenTask2Exception; import mediawiki.task.NormdatenTask2.NormdatenTask2ExceptionLevel; public class StatHandler implements NormdatenTask2ErrorHandler { private static enum Properties { TYPE, LEVEL, MESSAGE } private HashMap<String, Integer> type = new HashMap<>(); private HashMap<NormdatenTask2ExceptionLevel, Integer> level = new HashMap<>(); private HashMap<String, Integer> message = new HashMap<>(); public StatHandler() { } @Override public void handle(NormdatenTask2Exception e) throws Exception { handle(e.getLevel(), Properties.LEVEL); handle(e.getType(), Properties.TYPE); handle(e.getMessage(), Properties.MESSAGE); } @Override public boolean accept(NormdatenTask2Exception e) { return true; } private <T> void handle(T s, Properties p){ HashMap<T, Integer> h = null; switch(p){ case LEVEL: h = (HashMap<T, Integer>) level; break; case MESSAGE: h = (HashMap<T, Integer>) message; break; case TYPE: h = (HashMap<T, Integer>) type; break; } if(h.containsKey(s)) h.put(s, h.get(s)+1); else h.put(s, 1); } public Map<String, Integer> getTypeMap() { return type; } public Map<NormdatenTask2ExceptionLevel, Integer> getLevelMap() { return level; } public Map<String, Integer> getMessageMap() { return message; } }