Package io.smallrye.common.version
Interface VersionIterator
-
- All Known Implementing Classes:
AbstractVersionIterator
public interface VersionIterator
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanalphaPartEquals(String str, boolean ignoreCase)Determine whether the current alphabetical part is equal to the given test string.default booleanalphaPartEquals(String str, int offs, int len, boolean ignoreCase)Determine whether the current alphabetical part is equal to the given test string.StringBuilderappendAlphaPartTo(StringBuilder target)Append the current alphabetical part to the given string builder.StringBuilderappendNumberPartTo(StringBuilder target)Get the current numeric part, appending it to the given builder.StringBuilderappendPartTo(StringBuilder b)Append this version part to the given string builder.intcompareAlphaPart(VersionIterator other, boolean ignoreCase)Compare two alphabetical parts lexicographically.default intcompareAlphaPart(String str, boolean ignoreCase)Compare two alphabetical parts lexicographically.intcompareAlphaPart(String str, int offs, int len, boolean ignoreCase)Compare two alphabetical parts lexicographically.intcompareNumberPart(int value)Compare two numerical parts (using an unsigned comparison).intcompareNumberPart(long value)Compare two numerical parts (using an unsigned comparison).intcompareNumberPart(VersionIterator other)Compare two numerical parts (using an unsigned comparison).default intcompareNumberPart(String value)Compare two numerical parts (using an unsigned comparison).intcompareNumberPart(String value, int offs, int len)Compare two numerical parts (using an unsigned comparison).StringgetAlphaPart()Get the current alphabetical part.default BigIntegergetNumberPartAsBigInteger()Get the current numeric part, as aBigInteger.intgetNumberPartAsInt()Get the current numeric part, as anint.longgetNumberPartAsLong()Get the current numeric part, as along.default StringgetNumberPartAsString()Get the current numeric part, as aString.intgetSeparatorCodePoint()Get the code point of the current separator.booleanhasNext()Determine whether a subsequent token exists in this version.booleanisAlphaPart()Determine if the current token is an alphabetical part.booleanisEmptySeparator()Determine if the current token is an empty (or zero-length alphabetical-to-numeric or numeric-to-alphabetical) separator.booleanisNonEmptySeparator()Determine if the current token is a non-empty separator.booleanisNumberPart()Determine if the current token is a numeric part.default booleanisPart()Determine if the current token is some kind of part (alphabetical or numeric).default booleanisSeparator()Determine if the current token is some kind of separator (a character or a zero-length alphabetical-to-numeric or numeric-to-alphabetical transition).intlength()Get the length of the current token.voidnext()Move to the next token.default booleannumberPartEquals(int value)Determine whether the current numeric part equals the given value (which is treated as unsigned).default booleannumberPartEquals(long value)Determine whether the current numeric part equals the given value (which is treated as unsigned).
-
-
-
Method Detail
-
hasNext
boolean hasNext()
Determine whether a subsequent token exists in this version.- Returns:
trueif more tokens remain,falseotherwise
-
next
void next() throws NoSuchElementException, VersionSyntaxException
Move to the next token.- Throws:
NoSuchElementException- if there are no more tokens to iterateVersionSyntaxException
-
length
int length()
Get the length of the current token. If there is no current token, zero is returned.- Returns:
- the length of the current token
-
isSeparator
default boolean isSeparator()
Determine if the current token is some kind of separator (a character or a zero-length alphabetical-to-numeric or numeric-to-alphabetical transition).- Returns:
trueif the token is a separator,falseotherwise
-
isPart
default boolean isPart()
Determine if the current token is some kind of part (alphabetical or numeric).- Returns:
trueif the token is a part,falseotherwise
-
isEmptySeparator
boolean isEmptySeparator()
Determine if the current token is an empty (or zero-length alphabetical-to-numeric or numeric-to-alphabetical) separator. Note that some version schemes do not have empty separators.- Returns:
trueif the token is an empty separator,falseotherwise
-
isNonEmptySeparator
boolean isNonEmptySeparator()
Determine if the current token is a non-empty separator.- Returns:
trueif the token is a non-empty separator,falseotherwise
-
getSeparatorCodePoint
int getSeparatorCodePoint()
Get the code point of the current separator. If the iterator is not positioned on a non-empty separator (i.e.isNonEmptySeparator()returnsfalse), then an exception is thrown.- Returns:
- the code point of the current separator
- Throws:
IllegalStateException- if the current token is not a non-empty separator
-
isAlphaPart
boolean isAlphaPart()
Determine if the current token is an alphabetical part.- Returns:
trueif the token is an alphabetical part,falseotherwise
-
isNumberPart
boolean isNumberPart()
Determine if the current token is a numeric part.- Returns:
trueif the token is a numeric part,falseotherwise
-
getAlphaPart
String getAlphaPart() throws IllegalStateException
Get the current alphabetical part. If the iterator is not positioned on an alphabetical part (i.e.isAlphaPart()returnsfalse), then an exception is thrown.- Returns:
- the current alphabetical part
- Throws:
IllegalStateException- if the current token is not an alphabetical part
-
appendAlphaPartTo
StringBuilder appendAlphaPartTo(StringBuilder target) throws IllegalStateException
Append the current alphabetical part to the given string builder. If the iterator is not positioned on an alphabetical part (i.e.isAlphaPart()returnsfalse), then an exception is thrown.- Parameters:
target- the StringBuilder to append- Returns:
- the current alphabetical part
- Throws:
IllegalStateException- if the current token is not an alphabetical part
-
alphaPartEquals
default boolean alphaPartEquals(String str, boolean ignoreCase) throws IllegalStateException
Determine whether the current alphabetical part is equal to the given test string. If the iterator is not positioned on an alphabetical part (i.e.isAlphaPart()returnsfalse), then an exception is thrown.- Parameters:
str- the string to compare (must not benull)ignoreCase-trueto perform a case-insensitive comparison, orfalseto perform a case-sensitive comparison- Returns:
trueif the segment matches the given string;falseotherwise- Throws:
IllegalStateException- if the current token is not an alphabetical part
-
alphaPartEquals
default boolean alphaPartEquals(String str, int offs, int len, boolean ignoreCase) throws IllegalStateException, StringIndexOutOfBoundsException
Determine whether the current alphabetical part is equal to the given test string. If the iterator is not positioned on an alphabetical part (i.e.isAlphaPart()returnsfalse), then an exception is thrown.- Parameters:
str- the string to compare (must not benull)offs- the offset into the string to comparelen- the length to compareignoreCase-trueto perform a case-insensitive comparison, orfalseto perform a case-sensitive comparison- Returns:
trueif the segment matches the given string;falseotherwise- Throws:
IllegalStateException- if the current token is not an alphabetical partStringIndexOutOfBoundsException- if the given offset or length fall outside of the string
-
compareAlphaPart
default int compareAlphaPart(String str, boolean ignoreCase) throws IllegalStateException
Compare two alphabetical parts lexicographically. This iterator must be positioned at an alphabetical part or an exception is thrown.- Parameters:
str- the string to compare against (must not benull)ignoreCase-trueto perform a case-insensitive comparison, orfalseto perform a case-sensitive comparison- Returns:
-1,0, or1if this segment is less than, equal to, or greater than the given string- Throws:
IllegalStateException- if this iterator is not positioned on an alphabetical part
-
compareAlphaPart
int compareAlphaPart(String str, int offs, int len, boolean ignoreCase) throws IllegalStateException, StringIndexOutOfBoundsException
Compare two alphabetical parts lexicographically. This iterator must be positioned at an alphabetical part or an exception is thrown.- Parameters:
str- the string to compare against (must not benull)offs- the offset into the string to comparelen- the length to compareignoreCase-trueto perform a case-insensitive comparison, orfalseto perform a case-sensitive comparison- Returns:
-1,0, or1if this segment is less than, equal to, or greater than the given string- Throws:
IllegalStateException- if this iterator is not positioned on an alphabetical partStringIndexOutOfBoundsException- if the given offset or length fall outside of the string
-
compareAlphaPart
int compareAlphaPart(VersionIterator other, boolean ignoreCase) throws IllegalStateException
Compare two alphabetical parts lexicographically. Both this and the other iterator must be positioned at alphabetical parts or an exception is thrown.- Parameters:
other- the other iterator (must not benull)ignoreCase- a boolean to ignore case in the compare- Returns:
-1,0, or1if this segment is less than, equal to, or greater than the other iterator's part- Throws:
IllegalStateException- if this or the other iterator are not positioned on an alphabetical part
-
getNumberPartAsString
default String getNumberPartAsString() throws IllegalStateException
Get the current numeric part, as aString. If the iterator is not positioned on a numeric part (i.e.isNumberPart()returnsfalse), then an exception is thrown. Any redundant leading zeros are removed.- Returns:
- the current numeric part as a
String - Throws:
IllegalStateException- if the current token is not a numeric part
-
appendNumberPartTo
StringBuilder appendNumberPartTo(StringBuilder target) throws IllegalStateException
Get the current numeric part, appending it to the given builder. If the iterator is not positioned on a numeric part (i.e.isNumberPart()returnsfalse), then an exception is thrown. Any redundant leading zeros are removed.- Parameters:
target- the StringBuilder to append- Returns:
- the current numeric part as a
String - Throws:
IllegalStateException- if the current token is not a numeric part
-
getNumberPartAsLong
long getNumberPartAsLong() throws IllegalStateExceptionGet the current numeric part, as along. If the iterator is not positioned on a numeric part (i.e.isNumberPart()returnsfalse), then an exception is thrown. If the value overflows the maximum value for along, then only the low-order 64 bits of the version number value are returned.- Returns:
- the current numeric part as a
long - Throws:
IllegalStateException- if the current token is not a numeric part
-
getNumberPartAsInt
int getNumberPartAsInt() throws IllegalStateExceptionGet the current numeric part, as anint. If the iterator is not positioned on a numeric part (i.e.isNumberPart()returnsfalse), then an exception is thrown. If the value overflows the maximum value for anint, then only the low-order 32 bits of the version number value are returned.- Returns:
- the current numeric part as an
int - Throws:
IllegalStateException- if the current token is not a numeric part
-
getNumberPartAsBigInteger
default BigInteger getNumberPartAsBigInteger() throws IllegalStateException
Get the current numeric part, as aBigInteger. If the iterator is not positioned on a numeric part (i.e.isNumberPart()returnsfalse), then an exception is thrown.- Returns:
- the current numeric part as a
BigInteger - Throws:
IllegalStateException- if the current token is not a numeric part
-
numberPartEquals
default boolean numberPartEquals(int value) throws IllegalStateExceptionDetermine whether the current numeric part equals the given value (which is treated as unsigned).- Parameters:
value- the unsigned value- Returns:
trueif the values are equal, orfalseotherwise- Throws:
IllegalStateException- if the current token is not a numeric part
-
numberPartEquals
default boolean numberPartEquals(long value) throws IllegalStateExceptionDetermine whether the current numeric part equals the given value (which is treated as unsigned).- Parameters:
value- the unsigned value- Returns:
trueif the values are equal, orfalseotherwise- Throws:
IllegalStateException- if the current token is not a numeric part
-
compareNumberPart
int compareNumberPart(int value) throws IllegalStateExceptionCompare two numerical parts (using an unsigned comparison). This iterator must be positioned at a numerical part or an exception is thrown.- Parameters:
value- the number to compare against- Returns:
-1,0, or1if this segment is less than, equal to, or greater than the given value- Throws:
IllegalStateException- if this iterator is not positioned on a numeric part
-
compareNumberPart
int compareNumberPart(long value) throws IllegalStateExceptionCompare two numerical parts (using an unsigned comparison). This iterator must be positioned at a numerical part or an exception is thrown.- Parameters:
value- the number to compare against- Returns:
-1,0, or1if this segment is less than, equal to, or greater than the given value- Throws:
IllegalStateException- if this iterator is not positioned on a numeric part
-
compareNumberPart
default int compareNumberPart(String value) throws IllegalStateException
Compare two numerical parts (using an unsigned comparison). This iterator must be positioned at a numerical part or an exception is thrown. The given string must be numeric according to the rules of this iterator or an exception is thrown.- Parameters:
value- the number to compare against- Returns:
-1,0, or1if this segment is less than, equal to, or greater than the given value- Throws:
IllegalStateException- if this iterator is not positioned on a numeric partIllegalArgumentException- if the given string is not numeric according to the rules of this iterator
-
compareNumberPart
int compareNumberPart(String value, int offs, int len) throws IllegalStateException
Compare two numerical parts (using an unsigned comparison). This iterator must be positioned at a numerical part or an exception is thrown. The given string must be numeric according to the rules of this iterator or an exception is thrown.- Parameters:
value- the number to compare againstoffs- the offset into the string to comparelen- the length to compare- Returns:
-1,0, or1if this segment is less than, equal to, or greater than the given value- Throws:
IllegalStateException- if this iterator is not positioned on a numeric partIllegalArgumentException- if the given string is not numeric according to the rules of this iterator
-
compareNumberPart
int compareNumberPart(VersionIterator other)
Compare two numerical parts (using an unsigned comparison). Both iterators must be positioned at a numerical part or an exception is thrown.- Parameters:
other- the other iterator (must not benull)- Returns:
-1,0, or1if this segment is less than, equal to, or greater than the other iterator's part- Throws:
IllegalStateException- if this or the other iterator are not positioned on an numerical part
-
appendPartTo
StringBuilder appendPartTo(StringBuilder b)
Append this version part to the given string builder. This is used to produce a canonical representation of an input string.- Parameters:
b- the string builder (must not benull)- Returns:
- the same string builder (not
null)
-
-