private int doSearch ( final CharBuffer buffer , final int matchedLength , final int currentLength , final boolean ignoreCase ) { /* * Try and see if there is a possible match here; there is if "fullword" * is true, in this case the next "matchedLength" argument to a possible * child call will be the current length. */ final int nextLength = fullWord ? currentLength : matchedLength ; /* * If there is nothing left in the buffer, we have a match. */ if ( ! buffer . hasRemaining ( ) ) return nextLength ; /* * OK, there is at least one character remaining, so pick it up and see * whether it is in the list of our children... */ char c = buffer . get ( ) ; int index = Arrays . binarySearch ( nextChars , c ) ; if ( index < 0 && ignoreCase ) { final boolean isUpper = Character . isUpperCase ( c ) ; final boolean isLower = Character . isLowerCase ( c ) ; if ( isUpper != isLower ) { c = isUpper ? Character . toLowerCase ( c ) : Character . toUpperCase ( c ) ; index = Arrays . binarySearch ( nextChars , c ) ; } } /* * If not, we return the last good match; if yes, we call this same * method on the matching child node with the (possibly new) matched * length as an argument and a depth increased by 1. */ if ( index < 0 ) return nextLength ; return nextNodes [ index ] . doSearch ( buffer , nextLength , currentLength + 1 , ignoreCase ) ; }
Core search method