question: private int matchString ( String text , int start , int field , Map < String , Integer > data , CalendarBuilder calb ) { if ( data != null ) { if ( data instanceof SortedMap ) { for ( String name : data . keySet ( ) ) { if ( text . regionMatches ( true , start , name , 0 , name . length ( ) ) ) { calb . set ( field , data . get ( name ) ) ; return start + name . length ( ) ; } } return - start ; } String bestMatch = null ; for ( String name : data . keySet ( ) ) { int length = name . length ( ) ; if ( bestMatch == null || length > bestMatch . length ( ) ) { if ( text . regionMatches ( true , start , name , 0 , length ) ) { bestMatch = name ; } } } if ( bestMatch != null ) { calb . set ( field , data . get ( bestMatch ) ) ; return start + bestMatch . length ( ) ; } } return - start ; }
target:  Performs the same thing as matchString(String, int, int, String[]). This method takes a Map<String, Integer> instead of String[].