Top Description Methods
io.smallrye.common.version

public Interface VersionIterator

Known Direct Implementers
io.smallrye.common.version.AbstractVersionIterator
Imports
java.math.BigInteger, java.util.NoSuchElementException

An iterator over the parts of a version. The iterator starts off in the "initial" position. Use the hasNext() and next() methods to move the cursor to each segment of the version string in turn.

Method Summary

Modifier and TypeMethod and Description
public default boolean

Returns:

true if the segment matches the given string; false otherwise
alphaPartEquals
(String
the string to compare (must not be null)
str
,
boolean
true to perform a case-insensitive comparison, or false to perform a case-sensitive comparison
ignoreCase
)

Determine whether the current alphabetical part is equal to the given test string.

public default boolean

Returns:

true if the segment matches the given string; false otherwise
alphaPartEquals
(String
the string to compare (must not be null)
str
,
int
the offset into the string to compare
offs
,
int
the length to compare
len
,
boolean
true to perform a case-insensitive comparison, or false to perform a case-sensitive comparison
ignoreCase
)

Determine whether the current alphabetical part is equal to the given test string.

public StringBuilder

Returns:

the current alphabetical part
appendAlphaPartTo
(StringBuilder
the StringBuilder to append
target
)

Append the current alphabetical part to the given string builder.

public StringBuilder

Returns:

the current numeric part as a String
appendNumberPartTo
(StringBuilder
the StringBuilder to append
target
)

Get the current numeric part, appending it to the given builder.

public StringBuilder

Returns:

the same string builder (not null)
appendPartTo
(StringBuilder
the string builder (must not be null)
b
)

Append this version part to the given string builder.

public default int

Returns:

-1, 0, or 1 if this segment is less than, equal to, or greater than the given string
compareAlphaPart
(String
the string to compare against (must not be null)
str
,
boolean
true to perform a case-insensitive comparison, or false to perform a case-sensitive comparison
ignoreCase
)

Compare two alphabetical parts lexicographically.

public int

Returns:

-1, 0, or 1 if this segment is less than, equal to, or greater than the given string
compareAlphaPart
(String
the string to compare against (must not be null)
str
,
int
the offset into the string to compare
offs
,
int
the length to compare
len
,
boolean
true to perform a case-insensitive comparison, or false to perform a case-sensitive comparison
ignoreCase
)

Compare two alphabetical parts lexicographically.

public int

Returns:

-1, 0, or 1 if this segment is less than, equal to, or greater than the other iterator's part
compareAlphaPart
(VersionIterator
the other iterator (must not be null)
other
,
boolean
a boolean to ignore case in the compare
ignoreCase
)

Compare two alphabetical parts lexicographically.

public int

Returns:

-1, 0, or 1 if this segment is less than, equal to, or greater than the given value
compareNumberPart
(int
the number to compare against
value
)

Compare two numerical parts (using an unsigned comparison).

public int

Returns:

-1, 0, or 1 if this segment is less than, equal to, or greater than the given value
compareNumberPart
(long
the number to compare against
value
)

Compare two numerical parts (using an unsigned comparison).

public default int

Returns:

-1, 0, or 1 if this segment is less than, equal to, or greater than the given value
compareNumberPart
(String
the number to compare against
value
)

Compare two numerical parts (using an unsigned comparison).

public int

Returns:

-1, 0, or 1 if this segment is less than, equal to, or greater than the given value
compareNumberPart
(String
the number to compare against
value
,
int
the offset into the string to compare
offs
,
int
the length to compare
len
)

Compare two numerical parts (using an unsigned comparison).

public int

Returns:

-1, 0, or 1 if this segment is less than, equal to, or greater than the other iterator's part
compareNumberPart
(VersionIterator
the other iterator (must not be null)
other
)

Compare two numerical parts (using an unsigned comparison).

public String

Returns:

the current alphabetical part
getAlphaPart
()

Get the current alphabetical part.

public default BigInteger

Returns:

the current numeric part as a BigInteger
getNumberPartAsBigInteger
()

Get the current numeric part, as a BigInteger.

public int

Returns:

the current numeric part as an int
getNumberPartAsInt
()

Get the current numeric part, as an int.

public long

Returns:

the current numeric part as a long
getNumberPartAsLong
()

Get the current numeric part, as a long.

public default String

Returns:

the current numeric part as a String
getNumberPartAsString
()

Get the current numeric part, as a String.

public int

Returns:

the code point of the current separator
getSeparatorCodePoint
()

Get the code point of the current separator.

public boolean

Returns:

true if more tokens remain, false otherwise
hasNext
()

Determine whether a subsequent token exists in this version.

public boolean

Returns:

true if the token is an alphabetical part, false otherwise
isAlphaPart
()

Determine if the current token is an alphabetical part.

public boolean

Returns:

true if the token is an empty separator, false otherwise
isEmptySeparator
()

Determine if the current token is an empty (or zero-length alphabetical-to-numeric or numeric-to-alphabetical) separator.

public boolean

Returns:

true if the token is a non-empty separator, false otherwise
isNonEmptySeparator
()

Determine if the current token is a non-empty separator.

public boolean

Returns:

true if the token is a numeric part, false otherwise
isNumberPart
()

Determine if the current token is a numeric part.

public default boolean

Returns:

true if the token is a part, false otherwise
isPart
()

Determine if the current token is some kind of part (alphabetical or numeric).

public default boolean

Returns:

true if the token is a separator, false otherwise
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).

public int

Returns:

the length of the current token
length
()

Get the length of the current token.

public void
next()

Move to the next token.

public default boolean

Returns:

true if the values are equal, or false otherwise
numberPartEquals
(int
the unsigned value
value
)

Determine whether the current numeric part equals the given value (which is treated as unsigned).

public default boolean

Returns:

true if the values are equal, or false otherwise
numberPartEquals
(long
the unsigned value
value
)

Determine whether the current numeric part equals the given value (which is treated as unsigned).

Method Detail

alphaPartEqualsback to summary
public 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() returns false), then an exception is thrown.

Parameters
str:String

the string to compare (must not be null)

ignoreCase:boolean

true to perform a case-insensitive comparison, or false to perform a case-sensitive comparison

Returns:boolean

true if the segment matches the given string; false otherwise

Exceptions
IllegalStateException:
if the current token is not an alphabetical part
alphaPartEqualsback to summary
public 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() returns false), then an exception is thrown.

Parameters
str:String

the string to compare (must not be null)

offs:int

the offset into the string to compare

len:int

the length to compare

ignoreCase:boolean

true to perform a case-insensitive comparison, or false to perform a case-sensitive comparison

Returns:boolean

true if the segment matches the given string; false otherwise

Exceptions
IllegalStateException:
if the current token is not an alphabetical part
StringIndexOutOfBoundsException:
if the given offset or length fall outside of the string
appendAlphaPartToback to summary
public 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() returns false), then an exception is thrown.

Parameters
target:StringBuilder

the StringBuilder to append

Returns:StringBuilder

the current alphabetical part

Exceptions
IllegalStateException:
if the current token is not an alphabetical part
appendNumberPartToback to summary
public 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() returns false), then an exception is thrown. Any redundant leading zeros are removed.

Parameters
target:StringBuilder

the StringBuilder to append

Returns:StringBuilder

the current numeric part as a String

Exceptions
IllegalStateException:
if the current token is not a numeric part
appendPartToback to summary
public 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:StringBuilder

the string builder (must not be null)

Returns:StringBuilder

the same string builder (not null)

compareAlphaPartback to summary
public 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:String

the string to compare against (must not be null)

ignoreCase:boolean

true to perform a case-insensitive comparison, or false to perform a case-sensitive comparison

Returns:int

-1, 0, or 1 if this segment is less than, equal to, or greater than the given string

Exceptions
IllegalStateException:
if this iterator is not positioned on an alphabetical part
compareAlphaPartback to summary
public 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:String

the string to compare against (must not be null)

offs:int

the offset into the string to compare

len:int

the length to compare

ignoreCase:boolean

true to perform a case-insensitive comparison, or false to perform a case-sensitive comparison

Returns:int

-1, 0, or 1 if this segment is less than, equal to, or greater than the given string

Exceptions
IllegalStateException:
if this iterator is not positioned on an alphabetical part
StringIndexOutOfBoundsException:
if the given offset or length fall outside of the string
compareAlphaPartback to summary
public 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:VersionIterator

the other iterator (must not be null)

ignoreCase:boolean

a boolean to ignore case in the compare

Returns:int

-1, 0, or 1 if this segment is less than, equal to, or greater than the other iterator's part

Exceptions
IllegalStateException:
if this or the other iterator are not positioned on an alphabetical part
compareNumberPartback to summary
public int compareNumberPart(int 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.

Parameters
value:int

the number to compare against

Returns:int

-1, 0, or 1 if this segment is less than, equal to, or greater than the given value

Exceptions
IllegalStateException:
if this iterator is not positioned on a numeric part
compareNumberPartback to summary
public int compareNumberPart(long 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.

Parameters
value:long

the number to compare against

Returns:int

-1, 0, or 1 if this segment is less than, equal to, or greater than the given value

Exceptions
IllegalStateException:
if this iterator is not positioned on a numeric part
compareNumberPartback to summary
public 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:String

the number to compare against

Returns:int

-1, 0, or 1 if this segment is less than, equal to, or greater than the given value

Exceptions
IllegalStateException:
if this iterator is not positioned on a numeric part
IllegalArgumentException:
if the given string is not numeric according to the rules of this iterator
compareNumberPartback to summary
public 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:String

the number to compare against

offs:int

the offset into the string to compare

len:int

the length to compare

Returns:int

-1, 0, or 1 if this segment is less than, equal to, or greater than the given value

Exceptions
IllegalStateException:
if this iterator is not positioned on a numeric part
IllegalArgumentException:
if the given string is not numeric according to the rules of this iterator
compareNumberPartback to summary
public 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:VersionIterator

the other iterator (must not be null)

Returns:int

-1, 0, or 1 if this segment is less than, equal to, or greater than the other iterator's part

Exceptions
IllegalStateException:
if this or the other iterator are not positioned on an numerical part
getAlphaPartback to summary
public String getAlphaPart() throws IllegalStateException

Get the current alphabetical part. If the iterator is not positioned on an alphabetical part (i.e. isAlphaPart() returns false), then an exception is thrown.

Returns:String

the current alphabetical part

Exceptions
IllegalStateException:
if the current token is not an alphabetical part
getNumberPartAsBigIntegerback to summary
public default BigInteger getNumberPartAsBigInteger() throws IllegalStateException

Get the current numeric part, as a BigInteger. If the iterator is not positioned on a numeric part (i.e. isNumberPart() returns false), then an exception is thrown.

Returns:BigInteger

the current numeric part as a BigInteger

Exceptions
IllegalStateException:
if the current token is not a numeric part
getNumberPartAsIntback to summary
public int getNumberPartAsInt() throws IllegalStateException

Get the current numeric part, as an int. If the iterator is not positioned on a numeric part (i.e. isNumberPart() returns false), then an exception is thrown. If the value overflows the maximum value for an int, then only the low-order 32 bits of the version number value are returned.

Returns:int

the current numeric part as an int

Exceptions
IllegalStateException:
if the current token is not a numeric part
getNumberPartAsLongback to summary
public long getNumberPartAsLong() throws IllegalStateException

Get the current numeric part, as a long. If the iterator is not positioned on a numeric part (i.e. isNumberPart() returns false), then an exception is thrown. If the value overflows the maximum value for a long, then only the low-order 64 bits of the version number value are returned.

Returns:long

the current numeric part as a long

Exceptions
IllegalStateException:
if the current token is not a numeric part
getNumberPartAsStringback to summary
public default String getNumberPartAsString() throws IllegalStateException

Get the current numeric part, as a String. If the iterator is not positioned on a numeric part (i.e. isNumberPart() returns false), then an exception is thrown. Any redundant leading zeros are removed.

Returns:String

the current numeric part as a String

Exceptions
IllegalStateException:
if the current token is not a numeric part
getSeparatorCodePointback to summary
public int getSeparatorCodePoint()

Get the code point of the current separator. If the iterator is not positioned on a non-empty separator (i.e. isNonEmptySeparator() returns false), then an exception is thrown.

Returns:int

the code point of the current separator

Exceptions
IllegalStateException:
if the current token is not a non-empty separator
hasNextback to summary
public boolean hasNext()

Determine whether a subsequent token exists in this version.

Returns:boolean

true if more tokens remain, false otherwise

isAlphaPartback to summary
public boolean isAlphaPart()

Determine if the current token is an alphabetical part.

Returns:boolean

true if the token is an alphabetical part, false otherwise

isEmptySeparatorback to summary
public 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:boolean

true if the token is an empty separator, false otherwise

isNonEmptySeparatorback to summary
public boolean isNonEmptySeparator()

Determine if the current token is a non-empty separator.

Returns:boolean

true if the token is a non-empty separator, false otherwise

isNumberPartback to summary
public boolean isNumberPart()

Determine if the current token is a numeric part.

Returns:boolean

true if the token is a numeric part, false otherwise

isPartback to summary
public default boolean isPart()

Determine if the current token is some kind of part (alphabetical or numeric).

Returns:boolean

true if the token is a part, false otherwise

isSeparatorback to summary
public 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:boolean

true if the token is a separator, false otherwise

lengthback to summary
public int length()

Get the length of the current token. If there is no current token, zero is returned.

Returns:int

the length of the current token

nextback to summary
public void next() throws NoSuchElementException, VersionSyntaxException

Move to the next token.

Exceptions
NoSuchElementException:
if there are no more tokens to iterate
numberPartEqualsback to summary
public default boolean numberPartEquals(int value) throws IllegalStateException

Determine whether the current numeric part equals the given value (which is treated as unsigned).

Parameters
value:int

the unsigned value

Returns:boolean

true if the values are equal, or false otherwise

Exceptions
IllegalStateException:
if the current token is not a numeric part
numberPartEqualsback to summary
public default boolean numberPartEquals(long value) throws IllegalStateException

Determine whether the current numeric part equals the given value (which is treated as unsigned).

Parameters
value:long

the unsigned value

Returns:boolean

true if the values are equal, or false otherwise

Exceptions
IllegalStateException:
if the current token is not a numeric part