Creates a new version descriptor based on its string presentation.

@param version string presentation of a version.
@return version descriptor.
@throws RuntimeException if error occurs while parsing the version.

@since v1.1.0
183798
public static Version parse(String version) {
        if (version == null) {
            throw new NullPointerException("version is null");
        }
        Version result = new Version();
        String[] numbers = version.split(".");
        for (int i = 0; i < numbers.length; i++) {
            String parts[] = numbers[i].split("-");
            int number = Integer.parseInt(parts[0]);
            StringBuilder label = new StringBuilder();
            for (int j = 1; j < parts.length; j++) {
                if ((i < numbers.length - 1) && (j < parts.length - 1)){
                    label.append('-').append(parts[j]);
                } else {
                    result.setSnapshot(parts[j].equalsIgnoreCase("SNAPSHOT"));
                }
            }
            result.append(number, label.toString());
        }
        return result;
    }
842575
protected static String formatApiVersion(String version) {
        if (StringUtils.isBlank(version)) {
            return VERSION;
        } else {
            final Matcher matcher = VERSION_PATTERN.matcher(version);
            if (matcher.matches()) {
                return String.format("%s.%s", matcher.group(1), matcher.group(2));
            } else {
                return VERSION;
            }
        }
    }
75451
public static String fixVersion(String version)
    {
        if (version != null)
            if (version.length() > 0)
        {
            version = version.toUpperCase();
            if (Character.isLetter(version.charAt(0)))
                version = version.substring(1, version.length()) + version.substring(0, 1); // Move letter to start
        }
        return version;
    }
1317342
public Object makeObjectFromClassName(String className, String version, boolean bErrorIfNotFound) throws RuntimeException
    {
        if (className == null)
            return null;
        className = ClassServiceUtility.getFullClassName(className);

        Class<?> clazz = null;
        try {
            clazz = Class.forName(className);
        } catch (ClassNotFoundException e) {
            if (this.getClassFinder(null) != null)
                clazz = this.getClassFinder(null).findClass(className, version);	// Try to find this class in the obr repos
            if (clazz == null)
                if (bErrorIfNotFound)
                    throw new RuntimeException(e.getMessage());
        }

        Object object = null;
        try {
            if (clazz != null)
                object = clazz.newInstance();
        } catch (InstantiationException e)   {
            if (bErrorIfNotFound)
                throw new RuntimeException(e.getMessage());
        } catch (IllegalAccessException e)   {
            if (bErrorIfNotFound)
                throw new RuntimeException(e.getMessage());
        } catch (Exception e) {
            if (bErrorIfNotFound)
                throw new RuntimeException(e.getMessage());
        }
        return object;
    }
448918
public void setCompileVersion(String version) {
        if (StringUtils.isNotEmpty(version)
                && !version.equals(ClassUtils.getJavaVersion())) {
            options.add("-target");
            options.add(version);
            lintOptions.add("-target");
            lintOptions.add(version);
        }
    }
732347
public static String getJavaVersion() {
        String[] sysPropParms = new String[] {"java.runtime.version", "java.version"};
        for (int i = 0; i < sysPropParms.length; i++) {
            String val = System.getProperty(sysPropParms[i]);
            if (!StringUtil.isEmpty(val)) {
                return val;
            }
        }
        return null;
    }
571001
private String acceptBuilder(String version) {
        String acceptValue = "application/json";
        if(version == "2.1") acceptValue += ";version=" + version;

        return acceptValue;
    }
890887
public void checkVersion(String version) throws ConnectionException {
        MetaModel meta = createMetaModel();
        meta.getAssetType("Member");

        if ((version != null) && (version.length() > 0)
                && ((meta.getVersion() == null) || (meta.getVersion()
                .compareTo(new Version(version)) < 0))) {
            throw new ConnectionException(MessageFormat.format(
                    "VersionOne Release {0} or above is required (found {1}).",
                    version, meta.getVersion()));
        }
    }
338910
public MockitoBundlesOption version( final String version )
    {
        ( (MavenArtifactUrlReference) ( (WrappedUrlProvisionOption) getDelegate() ).getUrlReference() ).version(
            version
        );
        return this;
    }
517513
public static final ClientVersionNotFoundException clientVersionNotFoundException(String clientId, String version) {
        return new ClientVersionNotFoundException(Messages.i18n.format("clientVersionDoesNotExist", clientId, version)); //$NON-NLS-1$
    }
1225452
public static final ApiVersionAlreadyExistsException apiVersionAlreadyExistsException(String apiName, String version) {
        return new ApiVersionAlreadyExistsException(Messages.i18n.format("ApiVersionAlreadyExists", apiName, version)); //$NON-NLS-1$
    }
236228
public void setVersion(final String version) {
        if (version == null && this.version == null) {
            return;
        } else if (version == null) {
            removeChild(this.version);
            this.version = null;
        } else if (this.version == null) {
            this.version = new KeyValueNode<String>(CommonConstants.CS_VERSION_TITLE, version);
            appendChild(this.version, false);
        } else {
            this.version.setValue(version);
        }
    }
299200
public static void setVersion(Object object, int version) {
		try {
			Field versionField = object.getClass().getField("version");
			versionField.set(object, version);
		} catch (NoSuchFieldException | SecurityException | IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}
422240
public static Version toVersion(String version, final Version defaultValue) {
	// remove extension if there is any
	final int rIndex = version.lastIndexOf(".lco");
	if (rIndex != -1) version = version.substring(0, rIndex);

	try {
	    return Version.parseVersion(version);
	}
	catch (final IllegalArgumentException iae) {
	    return defaultValue;
	}
    }
934583
public String getNamespaceFromVersion(String version)
    {
        MessageVersion recMessageVersion = this.getMessageVersion(version);
        String namespace = this.getField(MessageControl.BASE_NAMESPACE).toString();
        if (namespace == null)
            namespace = DBConstants.BLANK;
        if ((recMessageVersion != null) && (!recMessageVersion.getField(MessageVersion.NAMESPACE).isNull()))
                namespace += recMessageVersion.getField(MessageVersion.NAMESPACE).toString();
        return namespace;
    }
1053722
public static ESVersion fromString(String version) {
        String lVersion = version;
        final boolean snapshot = lVersion.endsWith("-SNAPSHOT");
        if (snapshot) {
            lVersion = lVersion.substring(0, lVersion.length() - 9);
        }
        String[] parts = lVersion.split("[.-]");
        if (parts.length < 3 || parts.length > 4) {
            throw new IllegalArgumentException(
                    "the lVersion needs to contain major, minor, and revision, and optionally the build: " + lVersion);
        }

        try {
            final int rawMajor = Integer.parseInt(parts[0]);
            if (rawMajor >= 5 && snapshot) { // we don't support snapshot as part of the lVersion here anymore
                throw new IllegalArgumentException("illegal lVersion format - snapshots are only supported until lVersion 2.x");
            }
            final int betaOffset = rawMajor < 5 ? 0 : 25;
            //we reverse the lVersion id calculation based on some assumption as we can't reliably reverse the modulo
            final int major = rawMajor * 1000000;
            final int minor = Integer.parseInt(parts[1]) * 10000;
            final int revision = Integer.parseInt(parts[2]) * 100;


            int build = 99;
            if (parts.length == 4) {
                String buildStr = parts[3];
                if (buildStr.startsWith("alpha")) {
                    assert rawMajor >= 5 : "major must be >= 5 but was " + major;
                    build = Integer.parseInt(buildStr.substring(5));
                    assert build < 25 : "expected a beta build but " + build + " >= 25";
                } else if (buildStr.startsWith("Beta") || buildStr.startsWith("beta")) {
                    build = betaOffset + Integer.parseInt(buildStr.substring(4));
                    assert build < 50 : "expected a beta build but " + build + " >= 50";
                } else if (buildStr.startsWith("RC") || buildStr.startsWith("rc")) {
                    build = Integer.parseInt(buildStr.substring(2)) + 50;
                } else {
                    throw new IllegalArgumentException("unable to parse lVersion " + lVersion);
                }
            }

            return new ESVersion(major + minor + revision + build);

        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("unable to parse lVersion " + lVersion, e);
        }
    }
171919
public static String cleanupVersion(String version) {
        StringBuilder result = new StringBuilder();
        Matcher m = FUZZY_VERSION.matcher(version);
        if (m.matches()) {
            String major = m.group(1);
            String minor = m.group(3);
            String micro = m.group(5);
            String qualifier = m.group(7);

            if (major != null) {
                result.append(major);
                if (minor != null) {
                    result.append(".");
                    result.append(minor);
                    if (micro != null) {
                        result.append(".");
                        result.append(micro);
                        if (qualifier != null) {
                            result.append(".");
                            cleanupModifier(result, qualifier);
                        }
                    } else if (qualifier != null) {
                        result.append(".0.");
                        cleanupModifier(result, qualifier);
                    } else {
                        result.append(".0");
                    }
                } else if (qualifier != null) {
                    result.append(".0.0.");
                    cleanupModifier(result, qualifier);
                } else {
                    result.append(".0.0");
                }
            }
        } else {
            result.append("0.0.0.");
            cleanupModifier(result, version);
        }
        return result.toString();
    }