public Version(String spec){
  if (spec == null) {
    throw new NullPointerException();
  }
  Pattern pattern2=Pattern.compile("(\\d*)\\.(\\d*)\\.(\\d*)");
  Matcher matcher2=pattern2.matcher(spec);
  Pattern pattern3=Pattern.compile("(\\d*)\\.(\\d*)\\.(\\d*)-(\\d*)");
  Matcher matcher3=pattern3.matcher(spec);
  Pattern pattern4=Pattern.compile("(\\d*)\\.(\\d*)\\.(\\d*)-SNAPSHOT");
  Matcher matcher4=pattern4.matcher(spec);
  Pattern pattern5=Pattern.compile("(\\d*)\\.(\\d*)\\.(\\d*)-(\\d*)\\.(\\d*)");
  Matcher matcher5=pattern5.matcher(spec);
  if (matcher2.matches()) {
    this.majorVersion=Integer.parseInt(matcher2.group(1));
    this.minorVersion=Integer.parseInt(matcher2.group(2));
    this.minorSubversion=Integer.parseInt(matcher2.group(3));
    this.incrementalRelease=0;
  }
 else   if (matcher3.matches()) {
    this.majorVersion=Integer.parseInt(matcher3.group(1));
    this.minorVersion=Integer.parseInt(matcher3.group(2));
    this.minorSubversion=Integer.parseInt(matcher3.group(3));
    this.incrementalRelease=Integer.parseInt(matcher3.group(4));
  }
 else   if (matcher4.matches()) {
    this.majorVersion=Integer.parseInt(matcher4.group(1));
    this.minorVersion=Integer.parseInt(matcher4.group(2));
    this.minorSubversion=Integer.parseInt(matcher4.group(3));
    this.incrementalRelease=0;
  }
 else   if (matcher5.matches()) {
    this.majorVersion=Integer.parseInt(matcher5.group(1));
    this.minorVersion=Integer.parseInt(matcher5.group(2));
    this.minorSubversion=Integer.parseInt(matcher5.group(3));
    this.incrementalRelease=Integer.parseInt(matcher5.group(4));
  }
 else {
    throw new IllegalArgumentException("Version should be either of the " + "form a.b.c or a.b.c-d or a.b.c-SNAPSHOT or a.b.c-d.e " + spec);
  }
}

public Version ( String spec ) { if ( spec == null ) { throw new NullPointerException ( ) ; } Pattern pattern2 = Pattern . compile ( "(\\d*)\\.(\\d*)\\.(\\d*)" ) ; Matcher matcher2 = pattern2 . matcher ( spec ) ; Pattern pattern3 = Pattern . compile ( "(\\d*)\\.(\\d*)\\.(\\d*)-(\\d*)" ) ; Matcher matcher3 = pattern3 . matcher ( spec ) ; Pattern pattern4 = Pattern . compile ( "(\\d*)\\.(\\d*)\\.(\\d*)-SNAPSHOT" ) ; Matcher matcher4 = pattern4 . matcher ( spec ) ; Pattern pattern5 = Pattern . compile ( "(\\d*)\\.(\\d*)\\.(\\d*)-(\\d*)\\.(\\d*)" ) ; Matcher matcher5 = pattern5 . matcher ( spec ) ; if ( matcher2 . matches ( ) ) { this . majorVersion = Integer . parseInt ( matcher2 . group ( 1 ) ) ; this . minorVersion = Integer . parseInt ( matcher2 . group ( 2 ) ) ; this . minorSubversion = Integer . parseInt ( matcher2 . group ( 3 ) ) ; this . incrementalRelease = 0 ; } else if ( matcher3 . matches ( ) ) { this . majorVersion = Integer . parseInt ( matcher3 . group ( 1 ) ) ; this . minorVersion = Integer . parseInt ( matcher3 . group ( 2 ) ) ; this . minorSubversion = Integer . parseInt ( matcher3 . group ( 3 ) ) ; this . incrementalRelease = Integer . parseInt ( matcher3 . group ( 4 ) ) ; } else if ( matcher4 . matches ( ) ) { this . majorVersion = Integer . parseInt ( matcher4 . group ( 1 ) ) ; this . minorVersion = Integer . parseInt ( matcher4 . group ( 2 ) ) ; this . minorSubversion = Integer . parseInt ( matcher4 . group ( 3 ) ) ; this . incrementalRelease = 0 ; } else if ( matcher5 . matches ( ) ) { this . majorVersion = Integer . parseInt ( matcher5 . group ( 1 ) ) ; this . minorVersion = Integer . parseInt ( matcher5 . group ( 2 ) ) ; this . minorSubversion = Integer . parseInt ( matcher5 . group ( 3 ) ) ; this . incrementalRelease = Integer . parseInt ( matcher5 . group ( 4 ) ) ; } else { throw new IllegalArgumentException ( "Version should be either of the " + "form a.b.c or a.b.c-d or a.b.c-SNAPSHOT or a.b.c-d.e " + spec ) ; } }
parses string version specs into versions .
