private String incrementAlias ( KeyStore jKeyStore , String alias ) throws KeyStoreException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "incrementAlias: " + alias ) ; int num = 0 ; String base ; int index = alias . lastIndexOf ( ' ' ) ; if ( - 1 == index ) { // no underscore found base = alias + ' ' ; } else if ( index == ( alias . length ( ) - 1 ) ) { // alias ends with underscore base = alias ; } else { // alias ends with _X where X might be a number... try { ++ index ; // jump past the underscore num = Integer . parseInt ( alias . substring ( index ) ) ; base = alias . substring ( 0 , index ) ; } catch ( NumberFormatException nfe ) { // not a number base = alias + ' ' ; } } String newAlias = base + Integer . toString ( ++ num ) ; while ( jKeyStore . containsAlias ( newAlias ) ) { newAlias = base + Integer . toString ( ++ num ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "incrementAlias: " + newAlias ) ; return newAlias ; }
Increment the trailing number on the alias value until one is found that does not currently exist in the input store .