Almost all of Pronghorn’s string manipulation utilizes a bitwise trie. It is called the TrieParser and is used in route matching, JSON parsing, HTTP header parsing, and much more.
Utilize the TrieParser for fast parsing and matching in your Pronghorn projects.
Example
// Define a tag. This number is an ID used to associate with certain matches. Make sure this is unique.finalint tagIndex =120;// Create a new TrieParserTrieParser map =newTrieParser();// Define your matches here// Use %b for bytes and stringsmap.setUTF8Value("<strong>%b</strong>", tagIndex);// Create a new reader. Since we already know all of our content, make sure to set alwaysCompletePayloads to trueTrieParserReader reader =newTrieParserReader(true);// Our example string. Since it has to be in bytes, use CharSequenceToUTF8Local to convert to a String.CharSequenceToUTF8Local.get().convert("Wow, it is a beautiful day <strong>today</strong>!").parseSetup(reader);// This will store the outputStringBuilder tag =newStringBuilder();// Now do the actual parsing. Make sure we have content and check if we found our tagIndexwhile (TrieParserReader.parseHasContent(reader)) {long val =TrieParserReader.parseNext(reader, map); // The ID the parser found// The parser found our indexif(val == tagIndex) {// Capture it and output it to the StringBuilderTrieParserReader.capturedFieldBytesAsUTF8(reader,0, tag); } else {// Skip over anything elseTrieParserReader.parseSkipOne(reader); }}System.out.println("This is what's inside the strong tag: "+ tag);