* Loops through the list of tokens and builds a character tree
*
*/
private void buildTrees() {
// First, create a root node
forwardTree = new Char2ObjectOpenHashMap();
reverseTree = new Char2ObjectOpenHashMap();
String token = null;
char chr;
Char2ObjectOpenHashMap currentNode = null;
Char2ObjectOpenHashMap targetNode = null;
for (int i = 0; i < tokens.length; i++) {
token = tokens[i];
if(token != null) {
// Build the forward tree
currentNode = forwardTree;
for (int j = 0; j < token.length(); j++) {
chr = token.charAt(j);
// Attempt to locate the node from the current node
targetNode = (Char2ObjectOpenHashMap)currentNode.get(chr);
if(targetNode == null) {
targetNode = new Char2ObjectOpenHashMap(1);
//targetNode.setCharacter(chr);
currentNode.put(chr, targetNode);
}
currentNode = targetNode;
}
// Build the reverse tree
currentNode = reverseTree;
for (int j = token.length() - 1; j >= 0; j--) {
chr = token.charAt(j);
// Attempt to locate the node from the current node
targetNode =(Char2ObjectOpenHashMap)currentNode.get(chr);
if(targetNode == null) {
targetNode = new Char2ObjectOpenHashMap(1);
//targetNode.setCharacter(chr);
currentNode.put(chr, targetNode);
}
currentNode = targetNode;