TrieParser implements Serializable { public <A extends Appendable> A toDOT(A builder) { try{ builder.append("digraph {\n"); int i = 0; while (i<limit) { Appendables.appendValue(builder, "node", i, "[label=\""); switch (data[i]) { case TYPE_SWITCH_BRANCH: i = toDotSwitch(builder, i); break; case TYPE_SAFE_END: i = toDotSafe(builder, i); break; case TYPE_ALT_BRANCH: i = toDotAltBranch(builder, i); break; case TYPE_BRANCH_VALUE: i = toDotBranchValue(builder, i); break; case TYPE_VALUE_NUMERIC: i = toDotNumeric(builder, i); break; case TYPE_VALUE_BYTES: i = toDotBytes(builder, i); break; case TYPE_RUN: i = toDotRun(builder, i); break; case TYPE_END: i = toDotEnd(builder, i); break; default: int remaining = limit-i; builder.append("ERROR Unrecognized value, remaining "+remaining+"\n"); if (remaining<100) { builder.append("Remaining:"+Arrays.toString(Arrays.copyOfRange(data, i, limit))+"\n" ); } return builder; } } builder.append("}\n"); } catch (IOException ioex) { throw new RuntimeException(ioex); } return builder; } TrieParser();  TrieParser(int size);  TrieParser(int size, boolean skipDeepChecks);  TrieParser(int size, int resultSize, boolean skipDeepChecks, boolean supportsExtraction);  TrieParser(int size, int resultSize, boolean skipDeepChecks, boolean supportsExtraction, boolean ignoreCase);  TrieParser(int size, int resultSize, boolean skipDeepChecks, boolean supportsExtraction, boolean ignoreCase, byte customEscape); byte[] lastSetValueExtractonPattern(); int lastSetValueExtractionCount(); int maxExtractedFields(); static int maxExtractedFields(TrieParser that); static int getLimit(TrieParser that); int getLimit(); boolean isSkipDeepChecks(); void setValue(byte[] source, int offset, int length, int mask, long value); String toString(); StringBuilder toString(StringBuilder builder); void visitPatterns(TrieParserVisitor pv); A toDOT(A builder); int setUTF8Value(CharSequence cs, long value); int setUTF8Value(CharSequence cs, CharSequence suffix, long value); int setUTF8Value(CharSequence prefix, CharSequence cs, CharSequence suffix, long value); void setValue(Pipe p, long value); int longestKnown(); int shortestKnown(); void setMaxBytesCapturable(int value); void setMaxNumericLengthCapturable(int value); void setValue(byte[] bytes, long value); void toDOTFile(File targetFile); static final byte TYPE_RUN; static final byte TYPE_BRANCH_VALUE; static final byte TYPE_ALT_BRANCH; static final byte TYPE_SWITCH_BRANCH; static final byte TYPE_VALUE_NUMERIC; static final byte TYPE_VALUE_BYTES; static final byte TYPE_SAFE_END; static final byte TYPE_END; final byte ESCAPE_BYTE; final byte NO_ESCAPE_SUPPORT; static final byte ESCAPE_CMD_OPTIONAL_SIGNED_INT; static final byte ESCAPE_CMD_SIGNED_INT; static final byte ESCAPE_CMD_UNSIGNED_INT; static final byte ESCAPE_CMD_SIGNED_HEX; static final byte ESCAPE_CMD_UNSIGNED_HEX; static final byte ESCAPE_CMD_DECIMAL; static final byte ESCAPE_CMD_RATIONAL; static final byte ESCAPE_CMD_BYTES; final byte caseRuleMask; }
@Test public void testToDot() { TrieParser map = new TrieParser(16); map.setValue(wrapping(data1, 3), 0, 3, 7, value2); map.setValue(wrapping(data1, 3), 0, 8, 7, value1); map.setValue(wrapping(data2, 3), 1, 7, 7, value1); map.setValue(wrapping(data3, 3), 1, 7, 7, value2); map.setValue(wrapping(data2b, 3), 1, 7, 7, value3); map.setValue(wrapping(data3b, 3), 1, 7, 7, value4); String actual = map.toDOT(new StringBuilder()).toString(); String expected = "digraph {\n"+ "node0[label=\"BRANCH ON BIT\n"+ " bit:00000010\"]\n"+ "node0->node4\n"+ "node0->node53\n"+ "node4[label=\"RUN of 3\n"+ "klm\"]\n"+ "node4->node9\n"+ "node9[label=\"BRANCH ON BIT\n"+ " bit:00000010\"]\n"+ "node9->node13\n"+ "node9->node33\n"+ "node13[label=\"RUN of 2\n"+ "xy\"]\n"+ "node13->node17\n"+ "node17[label=\"BRANCH ON BIT\n"+ " bit:00000010\"]\n"+ "node17->node21\n"+ "node17->node27\n"+ "node21[label=\"RUN of 2\n"+ "{128}{129}\"]\n"+ "node21->node25\n"+ "node25[label=\"END47[26]\"]\n"+ "node27[label=\"RUN of 2\n"+ "z{\"]\n"+ "node27->node31\n"+ "node31[label=\"END23[32]\"]\n"+ "node33[label=\"RUN of 2\n"+ "no\"]\n"+ "node33->node37\n"+ "node37[label=\"BRANCH ON BIT\n"+ " bit:00000010\"]\n"+ "node37->node41\n"+ "node37->node47\n"+ "node41[label=\"RUN of 2\n"+ "vw\"]\n"+ "node41->node45\n"+ "node45[label=\"END35[46]\"]\n"+ "node47[label=\"RUN of 2\n"+ "pq\"]\n"+ "node47->node51\n"+ "node51[label=\"END10[52]\"]\n"+ "node53[label=\"RUN of 3\n"+ "efg\"]\n"+ "node53->node58\n"+ "node58[label=\"SAFE23[59], \"]\n"+ "node58->node60\n"+ "node60[label=\"RUN of 5\n"+ "hijkl\"]\n"+ "node60->node67\n"+ "node67[label=\"END10[68]\"]\n"+ "}\n"; if (!expected.equals(actual)) { System.out.println("String expected = \"" + (actual.replace("\"", "\\\"").replace("\n", "\\n\"+\n\""))); } assertEquals(expected, actual); int actualLimit = map.getLimit(); assertEquals(69, actualLimit); }