private Version convertVersion(ProductInfo wasProperties) throws VersionParsingException {
        // Get the version for this product
        String versionString = wasProperties.getVersion();

        /*
         * Product versions are stored as d1.d2.d3.d4 all of which are ints which is therefore slightly different to OSGi spec and also the way that they are stored in the meta
         * data XML where they are 3 digits following the rule:
         *
         * d1.d2.d3*1000+d4
         *
         * convert now
         */
        Pattern versionPattern = Pattern.compile("([0-9]*\\.[0-9]*\\.)([0-9]*)\\.([0-9]*)");
        Matcher matcher = versionPattern.matcher(versionString);
        if (matcher.matches()) {
            // If it doesn't match then we can't convert so leave it as it is
            int d3 = Integer.parseInt(matcher.group(2));
            int d4 = Integer.parseInt(matcher.group(3));
            versionString = matcher.group(1) + Integer.toString(d3 * 1000 + d4);
        } else {
            throw new VersionParsingException(getMessage("compare.version.incompatible", versionString));
        }

        // The version is a "must have" property so don't need to do null check
        Version version;
        try {
            version = Version.parseVersion(versionString);
        } catch (IllegalArgumentException e) {
            // I'm pretty sure this is impossible as we matched the pattern.  Better not risk it though so re-throw the error
            throw new VersionParsingException(getMessage("compare.unable.to.parse.version", versionString, e.getMessage()));
        }
        return version;
    }
private Version convertVersion ( ProductInfo wasProperties ) throws VersionParsingException { String versionString = wasProperties . getVersion ( ) ; Pattern versionPattern = Pattern . compile ( "([0-9]*\\.[0-9]*\\.)([0-9]*)\\.([0-9]*)" ) ; Matcher matcher = versionPattern . matcher ( versionString ) ; if ( matcher . matches ( ) ) { int d3 = Integer . parseInt ( matcher . group ( 2 ) ) ; int d4 = Integer . parseInt ( matcher . group ( 3 ) ) ; versionString = matcher . group ( 1 ) + Integer . toString ( d3 * 1000 + d4 ) ; } else { throw new VersionParsingException ( getMessage ( "compare.version.incompatible" , versionString ) ) ; } Version version ; try { version = Version . parseVersion ( versionString ) ; } catch ( IllegalArgumentException e ) { throw new VersionParsingException ( getMessage ( "compare.unable.to.parse.version" , versionString , e . getMessage ( ) ) ) ; } return version ; }
@param wasProperties
@return
@throws VersionParsingException