/** * determines the common prefix of the nodes. * * @param currentPrefix the common prefix found so far * @return the result of the search */ protected String determineCommonPrefix(String currentPrefix) { String result; String newPrefix; if (!isRoot() && (getChar() != STOP)) { newPrefix = currentPrefix + getChar(); } else { newPrefix = currentPrefix; } if (m_Children.size() == 1) { result = ((TrieNode) getChildAt(0)).determineCommonPrefix(newPrefix); } else { result = newPrefix; } return result; }
/** * determines the common prefix of the nodes. * * @param currentPrefix the common prefix found so far * @return the result of the search */ protected String determineCommonPrefix(String currentPrefix) { String result; String newPrefix; if (!isRoot() && (getChar() != STOP)) { newPrefix = currentPrefix + getChar(); } else { newPrefix = currentPrefix; } if (m_Children.size() == 1) { result = ((TrieNode) getChildAt(0)).determineCommonPrefix(newPrefix); } else { result = newPrefix; } return result; }
/** * returns the full string up to the root * * @return the full string to the root */ public String getString() { char[] result; TrieNode node; result = new char[this.getLevel()]; node = this; while (node.getParent() != null) { if (node.isRoot()) { break; } else { result[node.getLevel() - 1] = node.getChar(); } node = (TrieNode) node.getParent(); } return new String(result); }
/** * returns the full string up to the root * * @return the full string to the root */ public String getString() { char[] result; TrieNode node; result = new char[this.getLevel()]; node = this; while (node.getParent() != null) { if (node.isRoot()) { break; } else { result[node.getLevel() - 1] = node.getChar(); } node = (TrieNode) node.getParent(); } return new String(result); }