Package ca.solostudios.strata.parser
Class VersionRangeParser
- java.lang.Object
-
- ca.solostudios.strata.parser.VersionRangeParser
-
public class VersionRangeParser extends java.lang.ObjectA parser for strings representing a valid version range. Constructed with the string to parse,parse()must be invoked to parse the version range. This method returns the parsed version range.
Version ranges must match the following specification:Version Ranges
Ranges must fit into one of the two categories- Glob ranges
- Version ranges
Glob Ranges
Glob ranges are represented as follows:+:
This will match any version.-
major.+
This matches any version which begins withmajor., meaning: any version betweenmajor.0.0inclusively and{major+1}.0.0exclusively.
Example: The glob range1.+will match1.0.0,1.2.3, and1.99.99but not2.0.0 -
major.minor.+
This matches any version which begins withmajor.minor, meaning: any version betweenmajor.minor.0inclusively andmajor.{minor+1}.0exclusively.
Example: The glob range1.2.+will match1.2.0,1.2.3, and1.2.99but not1.3.0 -
major.minor.patch
This matches only versionmajor.minor.patch,
Example: The glob range1.2.+will match1.2.0,1.2.3, and1.2.99but not1.3.0
Version Ranges
Version ranges are represented by 2 versions surrounded by either brackets ("[]") or braces ("()").They must fit the following format:
Where("[" or "(")VersionOne,VersionTwo("]" or ")")VersionOneandVersionTwoare validVersions.Note: Both
VersionOneandVersionTwoare optional.Here is a list of example versions and what they match
Table of version examples Version Description [1.0.0,2.0.0] all versions greater or equal to 1.0.0 and lower or equal to 2.0.0 (1.0.0,2.0.0) all versions greater or equal to 1.0.0 and lower than 2.0.0 (1.0.0,2.0.0] all versions greater than 1.0.0 and lower or equal to 2.0.0 (1.0,2.0) all versions greater than 1.0.0 and lower than 2.0.0 [1.0.0,) all versions greater or equal to 1.0.0 (1.0.0,) all versions greater than 1.0.0 (,2.0.0] all versions lower or equal to 2.0.0 (,2.0) all versions lower than 2.0.0 - See Also:
VersionParser
-
-
Constructor Summary
Constructors Constructor Description VersionRangeParser(java.lang.String versionRangeString)Constructs a new version range parser with the provided string to parse.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull VersionRangeparse()Parses the provided version range string to aVersionRange.
-
-
-
Method Detail
-
parse
@NotNull @Contract(value="-> new", pure=true) public @NotNull VersionRange parse() throws ParseExceptionParses the provided version range string to aVersionRange.- Returns:
- The
Versionparsed from the string this object was instantated with. - Throws:
ParseException- If an exception occurred during the parsing of the version. If taking user input, the message from this exception is highly useful and should be returned to the user.
-
-