public static AppVersion parse(String versionString){
  if (versionString.equals("dev")) {
    return new AppVersion(-1,-1,"dev");
  }
  int minorSeparator=versionString.indexOf('.');
  int patchSeparator=versionString.indexOf('.',minorSeparator + 1);
  int milestoneSeparator=versionString.indexOf('M',Math.max(minorSeparator,patchSeparator));
  int modifierSeparator=versionString.indexOf('-',Math.max(minorSeparator,milestoneSeparator));
  if (minorSeparator == -1) {
    throw new NumberFormatException("Illegal version string: " + versionString);
  }
  final boolean hasPatch=patchSeparator > -1;
  final boolean hasMilestone=milestoneSeparator > -1;
  final boolean hasModifier=modifierSeparator > -1;
  String major=versionString.substring(0,minorSeparator);
  String minor=null;
  String patch=null;
  String milestone=null;
  String modifier=null;
  if (hasModifier) {
    modifier=versionString.substring(modifierSeparator + 1);
  }
  if (hasMilestone) {
    if (hasModifier) {
      milestone=versionString.substring(milestoneSeparator + 1,modifierSeparator);
    }
 else {
      milestone=versionString.substring(milestoneSeparator + 1);
    }
  }
  if (hasPatch) {
    if (hasMilestone) {
      patch=versionString.substring(patchSeparator + 1,milestoneSeparator);
    }
 else     if (hasModifier) {
      patch=versionString.substring(patchSeparator + 1,modifierSeparator);
    }
 else {
      patch=versionString.substring(patchSeparator + 1);
    }
    minor=versionString.substring(minorSeparator + 1,patchSeparator);
  }
 else {
    if (hasMilestone) {
      minor=versionString.substring(minorSeparator + 1,milestoneSeparator);
    }
 else     if (hasModifier) {
      minor=versionString.substring(minorSeparator + 1,modifierSeparator);
    }
 else {
      minor=versionString.substring(minorSeparator + 1);
    }
  }
  int majorInt=Integer.parseInt(major);
  int minorInt=Integer.parseInt(minor);
  int patchInt=patch == null ? -1 : Integer.parseInt(patch);
  int milestoneInt=milestone == null ? -1 : Integer.parseInt(milestone);
  return new AppVersion(majorInt,minorInt,patchInt,milestoneInt,modifier);
}

public static AppVersion parse ( String versionString ) { if ( versionString . equals ( "dev" ) ) { return new AppVersion ( - 1 , - 1 , "dev" ) ; } int minorSeparator = versionString . indexOf ( '.' ) ; int patchSeparator = versionString . indexOf ( '.' , minorSeparator + 1 ) ; int milestoneSeparator = versionString . indexOf ( 'M' , Math . max ( minorSeparator , patchSeparator ) ) ; int modifierSeparator = versionString . indexOf ( '-' , Math . max ( minorSeparator , milestoneSeparator ) ) ; if ( minorSeparator == - 1 ) { throw new NumberFormatException ( "Illegal version string: " + versionString ) ; } final boolean hasPatch = patchSeparator > - 1 ; final boolean hasMilestone = milestoneSeparator > - 1 ; final boolean hasModifier = modifierSeparator > - 1 ; String major = versionString . substring ( 0 , minorSeparator ) ; String minor = null ; String patch = null ; String milestone = null ; String modifier = null ; if ( hasModifier ) { modifier = versionString . substring ( modifierSeparator + 1 ) ; } if ( hasMilestone ) { if ( hasModifier ) { milestone = versionString . substring ( milestoneSeparator + 1 , modifierSeparator ) ; } else { milestone = versionString . substring ( milestoneSeparator + 1 ) ; } } if ( hasPatch ) { if ( hasMilestone ) { patch = versionString . substring ( patchSeparator + 1 , milestoneSeparator ) ; } else if ( hasModifier ) { patch = versionString . substring ( patchSeparator + 1 , modifierSeparator ) ; } else { patch = versionString . substring ( patchSeparator + 1 ) ; } minor = versionString . substring ( minorSeparator + 1 , patchSeparator ) ; } else { if ( hasMilestone ) { minor = versionString . substring ( minorSeparator + 1 , milestoneSeparator ) ; } else if ( hasModifier ) { minor = versionString . substring ( minorSeparator + 1 , modifierSeparator ) ; } else { minor = versionString . substring ( minorSeparator + 1 ) ; } } int majorInt = Integer . parseInt ( major ) ; int minorInt = Integer . parseInt ( minor ) ; int patchInt = patch == null ? - 1 : Integer . parseInt ( patch ) ; int milestoneInt = milestone == null ? - 1 : Integer . parseInt ( milestone ) ; return new AppVersion ( majorInt , minorInt , patchInt , milestoneInt , modifier ) ; }
parses a version string into a version object .
