protected String findPackageSuffix ( String uri ) { String temp = uri . startsWith ( "/" ) ? uri . substring ( 1 ) : uri ; temp = temp . replace ( "." , "_" ) ; temp = temp . replace ( "/" , "." ) ; //find all matches List < String > candidates = new ArrayList <> ( ) ; for ( String pack : Configuration . getControllerPackages ( ) ) { if ( temp . startsWith ( pack ) && ( temp . length ( ) == pack . length ( ) || temp . length ( ) > pack . length ( ) && temp . charAt ( pack . length ( ) ) == ' ' ) ) { candidates . add ( pack ) ; } } int resultIndex = 0 ; int size = 0 ; //find the longest package for ( int i = 0 ; i < candidates . size ( ) ; i ++ ) { String candidate = candidates . get ( i ) ; if ( candidate . length ( ) > size ) { size = candidate . length ( ) ; resultIndex = i ; } } return ! candidates . isEmpty ( ) ? candidates . get ( resultIndex ) : null ; }
Finds a part of a package name which can be found in between app . controllers and short name of class .