Top Description Inners Fields Constructors Methods
org.jboss.modules

public final Class Version

extends Object
implements Comparable<Version>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Comparable
Imports
java.io.Serializable, java.math.BigInteger, java.text.Normalizer, java.util.NoSuchElementException

A version for a module. Versions are series of letters and digits, optionally divided by separator characters, which include ., -, +, and _. The transition between letter and digit (or vice-versa) is also considered to be an invisible separator.

Versions may be compared, sorted, used as hash keys, and iterated.

Author
David M. Lloyd

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
Version.Iterator

An iterator over the parts of a version.

pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private static final int
private final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv int
comparePart(long cookie, Version other, long otherCookie)

pack-priv static int
compareSep(int sep1, int sep2)

public int

Returns:

A negative integer, zero, or a positive integer as this module version is less than, equal to, or greater than the given module version
compareTo
(Version
The module version to compare
that
)

Implements java.lang.Comparable.compareTo.

Compares this module version to another module version.
pack-priv static int

Returns:

the end character index in the version string
cookieToEndIndex
(long
the cookie
cookie
)

Get the token end index from the cookie.

pack-priv static int

Returns:

the start character index in the version string
cookieToStartIndex
(long
the cookie
cookie
)

Get the token start index from the cookie.

pack-priv static int

Returns:

the token value
cookieToToken
(long
the cookie
cookie
)

Get the token type from the cookie.

public boolean

Returns:

true if, and only if, the given object is a module reference that is equal to this module reference
equals
(Object
the object to which this object is to be compared
ob
)

Overrides java.lang.Object.equals.

Tests this module version for equality with the given object.
public int

Returns:

The hash-code value for this module version
hashCode
()

Overrides java.lang.Object.hashCode.

Computes a hash code for this module version.
pack-priv boolean
hasNext(long cookie)

pack-priv static boolean
isValidAlphaPart(int codePoint)

pack-priv static boolean
isValidNumberPart(int codePoint)

pack-priv static boolean
isValidSeparator(int codePoint)

public Version.Iterator

Returns:

the iterator
iterator
()

Construct a new iterator over the parts of this version string.

pack-priv long

Returns:

the next cookie value in the token sequence
next
(long
the cookie (0L indicates start of search)
cookie
)

Go to the next token.

public static Version

Returns:

The resulting Version
parse
(String
The string to parse
v
)

Parses the given string as a version string.

pack-priv static int
sepMagnitude(int codePoint)

public String

Returns:

The normalized string.
toString
()

Overrides java.lang.Object.toString.

Returns the normalized string representation of this version.
pack-priv Object
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

TOK_INITIALback to summary
private static final int TOK_INITIAL
TOK_PART_ALPHAback to summary
private static final int TOK_PART_ALPHA
TOK_PART_NUMBERback to summary
private static final int TOK_PART_NUMBER
TOK_SEPback to summary
private static final int TOK_SEP
TOK_SEP_EMPTYback to summary
private static final int TOK_SEP_EMPTY
versionback to summary
private final String version

Constructor Detail

Versionback to summary
private Version(String v)

Method Detail

comparePartback to summary
pack-priv int comparePart(long cookie, Version other, long otherCookie)
compareSepback to summary
pack-priv static int compareSep(int sep1, int sep2)
compareToback to summary
public int compareTo(Version that)

Implements java.lang.Comparable.compareTo.

Compares this module version to another module version. Module versions are compared as described in the class description.

Parameters
that:Version

The module version to compare

Returns:int

A negative integer, zero, or a positive integer as this module version is less than, equal to, or greater than the given module version

Annotations
@Override
cookieToEndIndexback to summary
pack-priv static int cookieToEndIndex(long cookie)

Get the token end index from the cookie. The end index is stored in the second 28 bits (bits 28-55) of the cookie.

Parameters
cookie:long

the cookie

Returns:int

the end character index in the version string

cookieToStartIndexback to summary
pack-priv static int cookieToStartIndex(long cookie)

Get the token start index from the cookie. The start index is stored in the lowest 28 bits (bits 0-27) of the cookie.

Parameters
cookie:long

the cookie

Returns:int

the start character index in the version string

cookieToTokenback to summary
pack-priv static int cookieToToken(long cookie)

Get the token type from the cookie. The token type is stored in bits 56 and up in the cookie. The value will be one of:

Parameters
cookie:long

the cookie

Returns:int

the token value

equalsback to summary
public boolean equals(Object ob)

Overrides java.lang.Object.equals.

Tests this module version for equality with the given object.

If the given object is not a Version then this method returns false. Two module version are equal if their corresponding components are equal.

This method satisfies the general contract of the Object.equals method.

Parameters
ob:Object

the object to which this object is to be compared

Returns:boolean

true if, and only if, the given object is a module reference that is equal to this module reference

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Computes a hash code for this module version.

The hash code is based upon the components of the version and satisfies the general contract of the Object.hashCode method.

Returns:int

The hash-code value for this module version

Annotations
@Override
hasNextback to summary
pack-priv boolean hasNext(long cookie)
isValidAlphaPartback to summary
pack-priv static boolean isValidAlphaPart(int codePoint)
isValidNumberPartback to summary
pack-priv static boolean isValidNumberPart(int codePoint)
isValidSeparatorback to summary
pack-priv static boolean isValidSeparator(int codePoint)
iteratorback to summary
public Version.Iterator iterator()

Construct a new iterator over the parts of this version string.

Returns:Version.Iterator

the iterator

nextback to summary
pack-priv long next(long cookie) throws IllegalArgumentException

Go to the next token.

Parameters
cookie:long

the cookie (0L indicates start of search)

Returns:long

the next cookie value in the token sequence

Exceptions
IllegalArgumentException:
if the next token is not a valid token or the string is too long
parseback to summary
public static Version parse(String v)

Parses the given string as a version string.

Parameters
v:String

The string to parse

Returns:Version

The resulting Version

Exceptions
IllegalArgumentException:
If v is null, an empty string, or cannot be parsed as a version string
sepMagnitudeback to summary
pack-priv static int sepMagnitude(int codePoint)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the normalized string representation of this version.

Returns:String

The normalized string.

Annotations
@Override
writeReplaceback to summary
pack-priv Object writeReplace()
org.jboss.modules back to summary

public Class Version.Iterator

extends Object
Class Inheritance

An iterator over the parts of a version.

Field Summary

Modifier and TypeField and Description
pack-priv long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the current alphabetical part
getAlphaPart
()

Get the current alphabetical part.

public 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 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 another 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 boolean

Returns:

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

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

public 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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cookieback to summary
pack-priv long cookie

Constructor Detail

Iteratorback to summary
pack-priv Iterator()

Method Detail

getAlphaPartback to summary
public String getAlphaPart()

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 BigInteger getNumberPartAsBigInteger()

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()

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()

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 String getNumberPartAsString()

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.

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 another 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.

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 boolean isPart()

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

Returns:boolean

true if the token is a separator, false otherwise

isSeparatorback to summary
public 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()

Move to the next token.

Exceptions
NoSuchElementException:
if there are no more tokens to iterate
org.jboss.modules back to summary

pack-priv final Class Version.Serialized

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
private static final long
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
Serialized(final String string)

Method Summary

Modifier and TypeMethod and Description
pack-priv Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID
stringback to summary
private final String string

Constructor Detail

Serializedback to summary
pack-priv Serialized(final String string)

Method Detail

readResolveback to summary
pack-priv Object readResolve()