List of usage examples for org.apache.maven.artifact.versioning Restriction EVERYTHING
Restriction EVERYTHING
To view the source code for org.apache.maven.artifact.versioning Restriction EVERYTHING.
Click Source Link
From source file:org.commonjava.emb.component.vscheme.SchemeAwareVersionRange.java
License:Apache License
@SuppressWarnings("unchecked") public static SchemeAwareVersionRange createFromVersionSpec(final String spec, final VersionScheme scheme) throws InvalidVersionSpecificationException { if (spec == null) { return null; }/*ww w. ja va 2 s. c o m*/ final List<Restriction> restrictions = new ArrayList<Restriction>(); String process = spec; ArtifactVersion version = null; ArtifactVersion upperBound = null; ArtifactVersion lowerBound = null; while (process.startsWith("[") || process.startsWith("(")) { final int index1 = process.indexOf(")"); final int index2 = process.indexOf("]"); int index = index2; if (index2 < 0 || index1 < index2) { if (index1 >= 0) { index = index1; } } if (index < 0) { throw new InvalidVersionSpecificationException("Unbounded range: " + spec); } final Restriction restriction = parseRestriction(process.substring(0, index + 1), scheme); if (lowerBound == null) { lowerBound = restriction.getLowerBound(); } if (upperBound != null) { if (restriction.getLowerBound() == null || restriction.getLowerBound().compareTo(upperBound) < 0) { throw new InvalidVersionSpecificationException("Ranges overlap: " + spec); } } restrictions.add(restriction); upperBound = restriction.getUpperBound(); process = process.substring(index + 1).trim(); if (process.length() > 0 && process.startsWith(",")) { process = process.substring(1).trim(); } } if (process.length() > 0) { if (restrictions.size() > 0) { throw new InvalidVersionSpecificationException( "Only fully-qualified sets allowed in multiple set scenario: " + spec); } else { version = new SchemeAwareArtifactVersion(process, scheme); restrictions.add(Restriction.EVERYTHING); } } return new SchemeAwareVersionRange(version, restrictions, scheme); }