public T match ( CharSequence text , boolean matchPrefix ) { if ( root == null ) { throw new IllegalStateException ( "not compiled" ) ; } int length = text . length ( ) ; for ( int ii = 0 ; ii < length ; ii ++ ) { switch ( match ( text . charAt ( ii ) ) ) { case Error : return null ; case Ok : if ( matchPrefix ) { T uniqueMatch = state . getUniqueMatch ( ) ; if ( uniqueMatch != null ) { state = root ; return uniqueMatch ; } } break ; case Match : return getMatched ( ) ; } } return null ; }
Matches given text . Returns associated token if match otherwise null . If matchPrefix is true returns also the only possible match .