public static String cleanupVersion(String versionStr){
  if (StringUtilities.isEmpty(versionStr)) {
    return versionStr;
  }
  versionStr=toOSGICompatibleVersionString(versionStr);
  String[] versionComponents=versionStr.split("\\.");
  if (versionComponents.length != 3) {
    return versionStr;
  }
  String lastComponent=versionComponents[2];
  int nonDigitIndex=-1;
  for (int i=0, len=lastComponent.length(); i < len; i++) {
    if (!Character.isDigit(lastComponent.charAt(i))) {
      nonDigitIndex=i;
      break;
    }
  }
  if (nonDigitIndex == -1) {
    return versionStr;
  }
  if (nonDigitIndex == 0) {
    return versionComponents[0] + '.' + versionComponents[1]+ ".0."+ lastComponent;
  }
  return versionComponents[0] + '.' + versionComponents[1]+ '.'+ lastComponent.substring(0,nonDigitIndex)+ '.'+ lastComponent.substring(nonDigitIndex);
}

public static String cleanupVersion ( String versionStr ) { if ( StringUtilities . isEmpty ( versionStr ) ) { return versionStr ; } versionStr = toOSGICompatibleVersionString ( versionStr ) ; String [ ] versionComponents = versionStr . split ( "\\." ) ; if ( versionComponents . length != 3 ) { return versionStr ; } String lastComponent = versionComponents [ 2 ] ; int nonDigitIndex = - 1 ; for ( int i = 0 , len = lastComponent . length ( ) ; i < len ; i ++ ) { if ( ! Character . isDigit ( lastComponent . charAt ( i ) ) ) { nonDigitIndex = i ; break ; } } if ( nonDigitIndex == - 1 ) { return versionStr ; } if ( nonDigitIndex == 0 ) { return versionComponents [ 0 ] + '.' + versionComponents [ 1 ] + ".0." + lastComponent ; } return versionComponents [ 0 ] + '.' + versionComponents [ 1 ] + '.' + lastComponent . substring ( 0 , nonDigitIndex ) + '.' + lastComponent . substring ( nonDigitIndex ) ; }
in some cases , the 3rd component of the version string can contain both digits and non - digits ( e . g . , 2 . 1 . 0m1 , 2 . 1 . 0 - m1 ) ; this is incompatible with what gpe expects for a sdk version string .
