public Match match ( String path ) { SortedMap < String , Match > tail = treeMap . tailMap ( path ) ; if ( tail . isEmpty ( ) ) return null ; String after = tail . firstKey ( ) ; //System.out.println(" "+path+"; after="+afterPath); if ( path . startsWith ( after ) ) // common case return treeMap . get ( after ) ; // have to check more, until no common starting chars for ( String key : tail . keySet ( ) ) { if ( path . startsWith ( key ) ) return treeMap . get ( key ) ; // terminate when there's no match at all. if ( StringUtil2 . match ( path , key ) == 0 ) break ; } return null ; }
Find the longest match .