/** * Parse the given version number as a constant or dot based version. * <p>This method allows to use {@code "SENTRY_X_Y"} constant names, * or version numbers in the format {@code "x.y.z"}. * * @lucene.internal */ public static Version parseLeniently(String version) throws ParseException { String versionOrig = version; version = version.toUpperCase(Locale.ROOT); switch (version) { default: version = version .replaceFirst("^SENTRY_(\\d+)_(\\d+)_(\\d+)$", "$1.$2.$3") .replaceFirst("^SENTRY_(\\d+)_(\\d+)$", "$1.$2.0") .replaceFirst("^SENTRY_(\\d)(\\d)$", "$1.$2.0"); try { return parse(version); } catch (ParseException pe) { ParseException pe2 = new ParseException( "failed to parse lenient version string \"" + versionOrig + "\": " + pe.getMessage(), 0); pe2.initCause(pe); throw pe2; } } }