TrieParser implements Serializable { public void setValue(byte[] source, int offset, int length, int mask, long value) { setValue(0, source, offset, length, mask, value); } 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 testSimpleMultipleParse() { TrieParserReader reader = new TrieParserReader(); TrieParser map = new TrieParser(16); byte[] a = "StringA".getBytes(); byte[] b = "BytesB".getBytes(); map.setValue(wrapping(a,5), 0, a.length, 31, 1); map.setValue(wrapping(b,5), 0, b.length, 31, 8); byte[] testBytes = "BytesBStringA".getBytes(); TrieParserReader.parseSetup(reader, testBytes, 0, testBytes.length, 31); long valueB = TrieParserReader.parseNext(reader, map); assertEquals(8L, valueB); long valueA = TrieParserReader.parseNext(reader, map); assertEquals(1L, valueA); }
@Test public void testSimpleValueReplace() { TrieParserReader reader = new TrieParserReader(); TrieParser map = new TrieParser(16); map.setValue(data1, 0, 3, 7, value1); assertEquals(value1, TrieParserReader.query(reader, map, data1, 0, 3, 7)); map.setValue(data1, 0, 3, 7, value2); assertEquals(value2, TrieParserReader.query(reader, map, data1, 0, 3, 7)); }
@Test public void testSimpleValueReplaceWrapping() { TrieParserReader reader = new TrieParserReader(); TrieParser map = new TrieParser(16); map.setValue(data1, 5, 5, 7, value1); assertEquals(value1, TrieParserReader.query(reader, map, data1, 5, 5, 7)); map.setValue(data1, 5, 5, 7, value2); assertEquals(value2, TrieParserReader.query(reader, map, data1, 5, 5, 7)); }
@Test public void testTwoNonOverlapValuesWithReplace() { TrieParserReader reader = new TrieParserReader(); TrieParser map = new TrieParser(16); map.setValue(data1, 1, 3, 7, value1); map.setValue(data2, 1, 3, 7, value2); assertEquals(value1, TrieParserReader.query(reader, map, data1, 1, 3, 7)); assertEquals(value2, TrieParserReader.query(reader, map, data2, 1, 3, 7)); map.setValue(data1, 1, 3, 7, value2); map.setValue(data2, 1, 3, 7, value1); assertEquals(value2, TrieParserReader.query(reader, map, data1, 1, 3, 7)); assertEquals(value1, TrieParserReader.query(reader, map, data2, 1, 3, 7)); }
@Test public void testTwoNonOverlapValuesWrappingWithReplace() { TrieParserReader reader = new TrieParserReader(); TrieParser map = new TrieParser(16); map.setValue(data1, 5, 5, 7, value1); map.setValue(data2, 5, 5, 7, value2); assertEquals(value1, TrieParserReader.query(reader, map, data1, 5, 5, 7)); assertEquals(value2, TrieParserReader.query(reader, map, data2, 5, 5, 7)); map.setValue(data1, 5, 5, 7, value2); map.setValue(data2, 5, 5, 7, value1); assertEquals(value2, TrieParserReader.query(reader, map, data1, 5, 5, 7)); assertEquals(value1, TrieParserReader.query(reader, map, data2, 5, 5, 7)); }
@Test public void testTwoOverlapValues() { TrieParserReader reader = new TrieParserReader(); TrieParser map = new TrieParser(16); map.setValue(data2, 2, 5, 7, value1); map.setValue(data3, 2, 5, 7, value2); assertEquals(value1, TrieParserReader.query(reader, map, data2, 2, 5, 7)); assertEquals(value2, TrieParserReader.query(reader, map, data3, 2, 5, 7)); map.setValue(data2, 2, 5, 7, value2); map.setValue(data3, 2, 5, 7, value1); assertEquals(value2, TrieParserReader.query(reader, map, data2, 2, 5, 7)); assertEquals(value1, TrieParserReader.query(reader, map, data3, 2, 5, 7)); }
@Test public void testThreeOverlapValues() { TrieParserReader reader = new TrieParserReader(); TrieParser map = new TrieParser(16,1,false,true,false); map.setValue(wrapping(data3,3), 2, 5, 7, value2); map.setValue(wrapping(data4,3), 2, 5, 7, value3); map.setValue(wrapping(data2,3), 2, 5, 7, value1); assertEquals(value1, TrieParserReader.query(reader, map, wrapping(data2,3), 2, 5, 7)); assertEquals(value2, TrieParserReader.query(reader, map, wrapping(data3,3), 2, 5, 7)); assertEquals(value3, TrieParserReader.query(reader, map, wrapping(data4,3), 2, 5, 7)); map.setValue(wrapping(data2,3), 2, 5, 7, value3); assertEquals(value3, TrieParserReader.query(reader, map, wrapping(data2,3), 2, 5, 7)); map.setValue(wrapping(data3,3), 2, 5, 7, value2); assertEquals(value2, TrieParserReader.query(reader, map, wrapping(data3,3), 2, 5, 7)); assertEquals(value3, TrieParserReader.query(reader, map, wrapping(data2,3), 2, 5, 7)); map.setValue(wrapping(data4,3), 2, 5, 7, value1); assertEquals(value1, TrieParserReader.query(reader, map, wrapping(data4,3), 2, 5, 7)); assertEquals(value2, TrieParserReader.query(reader, map, wrapping(data3,3), 2, 5, 7)); assertEquals(value3, TrieParserReader.query(reader, map, wrapping(data2,3), 2, 5, 7)); }
@Test public void testInsertBeforeBranch() { TrieParserReader reader = new TrieParserReader(); TrieParser map = new TrieParser(16); assertEquals(8,data3.length); assertEquals(8,data4.length); assertEquals(8,data5.length); map.setValue(data3, 0, 6, 7, value1); map.setValue(data4, 0, 6, 7, value2); map.setValue(data5, 0, 6, 7, value3); assertEquals(value1, TrieParserReader.query(reader, map, data3, 0, 6, 7)); assertEquals(value2, TrieParserReader.query(reader, map, data4, 0, 6, 7)); assertEquals(value3, TrieParserReader.query(reader, map, data5, 0, 6, 7)); map.setValue(data3, 0, 6, 7, value3); map.setValue(data4, 0, 6, 7, value2); map.setValue(data5, 0, 6, 7, value1); assertEquals(value1, TrieParserReader.query(reader, map, data5, 0, 6, 7)); assertEquals(value2, TrieParserReader.query(reader, map, data4, 0, 6, 7)); assertEquals(value3, TrieParserReader.query(reader, map, data3, 0, 6, 7)); }
@Test public void testInsertAfterBothBranchs() { TrieParserReader reader = new TrieParserReader(); TrieParser map = new TrieParser(16); map.setValue(data2, 1, 7, 7, value1); map.setValue(data3, 1, 7, 7, value2); map.setValue(data2b, 1, 7, 7, value3); map.setValue(data3b, 1, 7, 7, value4); assertEquals(value1, TrieParserReader.query(reader, map, data2, 1, 7, 7)); assertEquals(value2, TrieParserReader.query(reader, map, data3, 1, 7, 7)); assertEquals(value3, TrieParserReader.query(reader, map, data2b, 1, 7, 7)); assertEquals(value4, TrieParserReader.query(reader, map, data3b, 1, 7, 7)); map.setValue(data3b, 1, 7, 7, value1); map.setValue(data2b, 1, 7, 7, value2); map.setValue(data3, 1, 7, 7, value3); map.setValue(data2, 1, 7, 7, value4); assertEquals(value4, TrieParserReader.query(reader, map, data2, 1, 7, 7)); assertEquals(value3, TrieParserReader.query(reader, map, data3, 1, 7, 7)); assertEquals(value2, TrieParserReader.query(reader, map, data2b, 1, 7, 7)); assertEquals(value1, TrieParserReader.query(reader, map, data3b, 1, 7, 7)); }
@Test public void testDisabledEscapedEscape() { TrieParser map = new TrieParser(1000, 1, true, false); TrieParserReader reader = new TrieParserReader(); map.setValue(wrapping(data1, 3), 0, 3, 7, value2); map.setValue(wrapping(data1, 3), 0, 8, 7, value1); map.setValue(wrapping(escapedEscape, 3), 1, 7, 7, value3); assertEquals(value2, TrieParserReader.query(reader, map, wrapping(data1, 3), 0, 3, 7)); assertEquals(value1, TrieParserReader.query(reader, map, wrapping(data1, 3), 0, 8, 7)); assertEquals(value3, TrieParserReader.query(reader, map, wrapping(escapedEscape, 3), 1, 7, 7)); map.setValue(wrapping(data2, 3), 1, 7, 7, value1); map.setValue(wrapping(data3, 3), 1, 7, 7, value2); assertEquals(value1, TrieParserReader.query(reader, map, wrapping(data2, 3), 1, 7, 7)); assertEquals(value2, TrieParserReader.query(reader, map, wrapping(data3, 3), 1, 7, 7)); map.setValue(wrapping(data2b, 3), 1, 7, 7, value3); map.setValue(wrapping(data3b, 3), 1, 7, 7, value4); map.setValue(wrapping(escapedEscape, 3), 1, 7, 7, value2); assertEquals(value3, TrieParserReader.query(reader, map, wrapping(data2b, 3), 1, 7, 7)); assertEquals(value4, TrieParserReader.query(reader, map, wrapping(data3b, 3), 1, 7, 7)); assertEquals(value2, TrieParserReader.query(reader, map, wrapping(escapedEscape, 3), 1, 7, 7)); }