public static String convertClassName ( String className , String stringToInsert , int location ) { int startSeq = 0 ; if ( location >= 0 ) { for ( int i = 0 ; i < location ; i ++ ) { startSeq = className . indexOf ( ' ' , startSeq + 1 ) ; } } else { startSeq = className . length ( ) ; for ( int i = location ; i < 0 ; i ++ ) { startSeq = className . lastIndexOf ( ' ' , startSeq - 1 ) ; } } if ( startSeq == - 1 ) return null ; int domainSeq = startSeq ; if ( className . indexOf ( Constant . THIN_SUBPACKAGE , startSeq ) == startSeq + 1 ) startSeq = startSeq + Constant . THIN_SUBPACKAGE . length ( ) ; className = className . substring ( 0 , domainSeq + 1 ) + stringToInsert + className . substring ( startSeq + 1 ) ; return className ; }
Convert this class name by inserting this package after the domain . ie . if location = 2 com . xyz . abc . ClassName - > com . xyz . newpackage . abc . ClassName .