protected String normalizeVersion(String version){
  Pattern regex=Pattern.compile("^(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:\\.(\\d+)| +rc(\\d+))?");
  Matcher m=regex.matcher(version);
  if (m != null && m.lookingAt()) {
    StringBuilder normal=new StringBuilder();
    for (int i=1; i <= 4; i++) {
      int v=0;
      if (i == 4 && i < m.groupCount() && m.group(i) == null && m.group(i + 1) != null) {
        i++;
      }
      if (m.group(i) != null) {
        try {
          v=Integer.parseInt(m.group(i));
        }
 catch (        Exception ignore) {
        }
      }
      if (i > 1) {
        normal.append('.');
      }
      normal.append(v);
    }
    return normal.toString();
  }
  throw new IllegalArgumentException("Bad version: " + version);
}

protected String normalizeVersion ( String version ) { Pattern regex = Pattern . compile ( "^(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:\\.(\\d+)| +rc(\\d+))?" ) ; Matcher m = regex . matcher ( version ) ; if ( m != null && m . lookingAt ( ) ) { StringBuilder normal = new StringBuilder ( ) ; for ( int i = 1 ; i <= 4 ; i ++ ) { int v = 0 ; if ( i == 4 && i < m . groupCount ( ) && m . group ( i ) == null && m . group ( i + 1 ) != null ) { i ++ ; } if ( m . group ( i ) != null ) { try { v = Integer . parseInt ( m . group ( i ) ) ; } catch ( Exception ignore ) { } } if ( i > 1 ) { normal . append ( '.' ) ; } normal . append ( v ) ; } return normal . toString ( ) ; } throw new IllegalArgumentException ( "Bad version: " + version ) ; }
validate the supplied application version , and normalize the version .
