public static void main(String[] args) throws Exception { if (args.length == 0) { System.out.println("Usage: StateMachineLogParser <logfile> | dot -Tsvg "); System.exit(-1); } BufferedReader f = new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), Charset.forName("UTF-8"))); Map<String, List<String>> fsms = getFsmEventMap(f); Set<Tuple> tuples = getStateTuples(fsms); drawDotGraph(tuples); } }
static Set<Tuple> getStateTuples(Map<String, List<String>> fsms) { Set<Tuple> tuples = new HashSet<Tuple>(); for (List<String> transitions : fsms.values()) { String currentEvent = null; for (String s : transitions) { //System.err.println(s); Matcher m = eventPattern.matcher(s); if (m.find()) { currentEvent = m.group(1); continue; } m = transitionPattern.matcher(s); if (m.find()) { if (currentEvent == null) { System.err.println("event is null"); } String state1 = m.group(1); String state2 = m.group(2); tuples.add(new Tuple(cleanupState(state1), currentEvent, cleanupState(state2))); continue; } if (s.contains("deferred")) { currentEvent = currentEvent + "[deferred]"; } } } return tuples; }
static Set<Tuple> getStateTuples(Map<String, List<String>> fsms) { Set<Tuple> tuples = new HashSet<Tuple>(); for (List<String> transitions : fsms.values()) { String currentEvent = null; for (String s : transitions) { //System.err.println(s); Matcher m = eventPattern.matcher(s); if (m.find()) { currentEvent = m.group(1); continue; } m = transitionPattern.matcher(s); if (m.find()) { if (currentEvent == null) { System.err.println("event is null"); } String state1 = m.group(1); String state2 = m.group(2); tuples.add(new Tuple(cleanupState(state1), currentEvent, cleanupState(state2))); continue; } if (s.contains("deferred")) { currentEvent = currentEvent + "[deferred]"; } } } return tuples; }
public static void main(String[] args) throws Exception { if (args.length == 0) { System.out.println("Usage: StateMachineLogParser <logfile> | dot -Tsvg "); System.exit(-1); } BufferedReader f = new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), Charset.forName("UTF-8"))); Map<String, List<String>> fsms = getFsmEventMap(f); Set<Tuple> tuples = getStateTuples(fsms); drawDotGraph(tuples); } }