public boolean isCompatibleWith(String desiredVersion) throws NumberFormatException {
  if (jar != null) {
    init();
  }
  if (specVersion == null || specVersion.length() == 0) {
    throw new NumberFormatException("No specification version defined for the package");
  }
  if (!specVersion.matches("[\\p{javaDigit}]+(.[\\p{javaDigit}]+)*")) {
    throw new NumberFormatException("Package specification version is not of the correct dotted form : " + specVersion);
  }
  if (desiredVersion == null || desiredVersion.length() == 0) {
    throw new NumberFormatException("Empty version to check");
  }
  if (!desiredVersion.matches("[\\p{javaDigit}]+(.[\\p{javaDigit}]+)*")) {
    throw new NumberFormatException("Desired version is not of the correct dotted form : " + desiredVersion);
  }
  StringTokenizer specVersionTokens=new StringTokenizer(specVersion,".");
  StringTokenizer desiredVersionTokens=new StringTokenizer(desiredVersion,".");
  try {
    while (specVersionTokens.hasMoreElements()) {
      int desiredVer=Integer.parseInt(desiredVersionTokens.nextToken());
      int specVer=Integer.parseInt(specVersionTokens.nextToken());
      if (specVer != desiredVer) {
        return specVer > desiredVer;
      }
    }
  }
 catch (  NoSuchElementException e) {
  }
  while (desiredVersionTokens.hasMoreTokens()) {
    if (0 != Integer.parseInt(desiredVersionTokens.nextToken())) {
      return false;
    }
  }
  return true;
}

public boolean isCompatibleWith ( String desiredVersion ) throws NumberFormatException { if ( jar != null ) { init ( ) ; } if ( specVersion == null || specVersion . length ( ) == 0 ) { throw new NumberFormatException ( "No specification version defined for the package" ) ; } if ( ! specVersion . matches ( "[\\p{javaDigit}]+(.[\\p{javaDigit}]+)*" ) ) { throw new NumberFormatException ( "Package specification version is not of the correct dotted form : " + specVersion ) ; } if ( desiredVersion == null || desiredVersion . length ( ) == 0 ) { throw new NumberFormatException ( "Empty version to check" ) ; } if ( ! desiredVersion . matches ( "[\\p{javaDigit}]+(.[\\p{javaDigit}]+)*" ) ) { throw new NumberFormatException ( "Desired version is not of the correct dotted form : " + desiredVersion ) ; } StringTokenizer specVersionTokens = new StringTokenizer ( specVersion , "." ) ; StringTokenizer desiredVersionTokens = new StringTokenizer ( desiredVersion , "." ) ; try { while ( specVersionTokens . hasMoreElements ( ) ) { int desiredVer = Integer . parseInt ( desiredVersionTokens . nextToken ( ) ) ; int specVer = Integer . parseInt ( specVersionTokens . nextToken ( ) ) ; if ( specVer != desiredVer ) { return specVer > desiredVer ; } } } catch ( NoSuchElementException e ) { } while ( desiredVersionTokens . hasMoreTokens ( ) ) { if ( 0 != Integer . parseInt ( desiredVersionTokens . nextToken ( ) ) ) { return false ; } } return true ; }
return true if this package ' s specification version is compatible with the specified version string . version strings are compared by comparing each dot separated part of the version as an integer .
