Top Description Fields Constructors Methods
org.osgi.framework

public Class VersionRange

extends Object
Class Inheritance
Imports
java.util.NoSuchElementException, .StringTokenizer

Version range. A version range is an interval describing a set of versions.

A range has a left (lower) endpoint and a right (upper) endpoint. Each endpoint can be open (excluded from the set) or closed (included in the set).

VersionRange objects are immutable.

Author
$Id: 1f5fa660a1a42e83371fe0d2c61ae79ce1cb1710 $
Since
1.7

Field Summary

Modifier and TypeField and Description
private final boolean
private static final String
private transient int
private final Version
public static final char
LEFT_CLOSED

The left endpoint is closed and is included in the range.

private static final String
private static final String
public static final char
LEFT_OPEN

The left endpoint is open and is excluded from the range.

private static final String
private final boolean
private final Version
public static final char
RIGHT_CLOSED

The right endpoint is closed and is included in the range.

private static final String
private static final String
public static final char
RIGHT_OPEN

The right endpoint is open and is excluded from the range.

private static final String
private final boolean
private transient String

Constructor Summary

AccessConstructor and Description
public
VersionRange(char
Must be either LEFT_CLOSED or LEFT_OPEN .
leftType
,
Version
Left endpoint of range. Must not be null.
leftEndpoint
,
Version
Right endpoint of range. May be null to indicate the right endpoint is Infinity.
rightEndpoint
,
char
Must be either RIGHT_CLOSED or RIGHT_OPEN.
rightType
)

Creates a version range from the specified versions.

public
VersionRange(String
String representation of the version range. The versions in the range must contain no whitespace. Other whitespace in the range string is ignored. Must not be null.
range
)

Creates a version range from the specified string.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if object is a VersionRange and is equal to this object; false otherwise.
equals
(Object
The VersionRange object to be compared.
object
)

Overrides java.lang.Object.equals.

Compares this VersionRange object to another object.

public Version

Returns:

The left endpoint.
getLeft
()

Returns the left endpoint of this version range.

public char

Returns:

LEFT_CLOSED if the left endpoint is closed or LEFT_OPEN if the left endpoint is open.
getLeftType
()

Returns the type of the left endpoint of this version range.

public Version

Returns:

The right endpoint. May be null which indicates the right endpoint is Infinity.
getRight
()

Returns the right endpoint of this version range.

public char

Returns:

RIGHT_CLOSED if the right endpoint is closed or RIGHT_OPEN if the right endpoint is open.
getRightType
()

Returns the type of the right endpoint of this version range.

public int

Returns:

An integer which is a hash code value for this object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.

public boolean

Returns:

true if the specified version is included in this version range; false otherwise.
includes
(Version
The version to test for inclusion in this version range.
version
)

Returns whether this version range includes the specified version.

public VersionRange

Returns:

A version range representing the intersection of this version range and the specified version ranges. If no version ranges are specified, then this version range is returned.
intersection
(VersionRange...
The version ranges to intersect with this version range.
ranges
)

Returns the intersection of this version range with the specified version ranges.

public boolean

Returns:

true if this version range is empty; false otherwise.
isEmpty
()

Returns whether this version range is empty.

private boolean

Returns:

true if this version range is empty; false otherwise.
isEmpty0
()

Internal isEmpty behavior.

public boolean

Returns:

true if this version range contains only a single version; false otherwise.
isExact
()

Returns whether this version range contains only a single version.

private static Version

Returns:

Version
parseVersion
(String
version component string
version
,
String
Complete range string for exception message, if any
range
)

Parse version component into a Version.

public String

Returns:

A filter string for this version range using the specified attribute name.
toFilterString
(String
The attribute name to use in the returned filter string.
attributeName
)

Returns the filter string for this version range using the specified attribute name.

public String

Returns:

The string representation of this version range.
toString
()

Overrides java.lang.Object.toString.

Returns the string representation of this version range.

public static VersionRange

Returns:

A VersionRange object representing the version range.
valueOf
(String
String representation of the version range. The versions in the range must contain no whitespace. Other whitespace in the range string is ignored. Must not be null.
range
)

Returns a VersionRange object holding the version range in the specified String.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

emptyback to summary
private final boolean empty
ENDPOINT_DELIMITERback to summary
private static final String ENDPOINT_DELIMITER
hashback to summary
private transient int hash
leftback to summary
private final Version left
LEFT_CLOSEDback to summary
public static final char LEFT_CLOSED

The left endpoint is closed and is included in the range.

The value of LEFT_CLOSED is '['.

LEFT_CLOSED_DELIMITERback to summary
private static final String LEFT_CLOSED_DELIMITER
LEFT_DELIMITERSback to summary
private static final String LEFT_DELIMITERS
LEFT_OPENback to summary
public static final char LEFT_OPEN

The left endpoint is open and is excluded from the range.

The value of LEFT_OPEN is '('.

LEFT_OPEN_DELIMITERback to summary
private static final String LEFT_OPEN_DELIMITER
leftClosedback to summary
private final boolean leftClosed
RIGHT_CLOSEDback to summary
public static final char RIGHT_CLOSED

The right endpoint is closed and is included in the range.

The value of RIGHT_CLOSED is ']'.

RIGHT_CLOSED_DELIMITERback to summary
private static final String RIGHT_CLOSED_DELIMITER
RIGHT_DELIMITERSback to summary
private static final String RIGHT_DELIMITERS
RIGHT_OPENback to summary
public static final char RIGHT_OPEN

The right endpoint is open and is excluded from the range.

The value of RIGHT_OPEN is ')'.

RIGHT_OPEN_DELIMITERback to summary
private static final String RIGHT_OPEN_DELIMITER
rightClosedback to summary
private final boolean rightClosed
versionRangeStringback to summary
private transient String versionRangeString

Constructor Detail

VersionRangeback to summary
public VersionRange(char leftType, Version leftEndpoint, Version rightEndpoint, char rightType)

Creates a version range from the specified versions.

Parameters
leftType:char

Must be either LEFT_CLOSED or LEFT_OPEN .

leftEndpoint:Version

Left endpoint of range. Must not be null.

rightEndpoint:Version

Right endpoint of range. May be null to indicate the right endpoint is Infinity.

rightType:char

Must be either RIGHT_CLOSED or RIGHT_OPEN.

Exceptions
IllegalArgumentException:
If the arguments are invalid.
VersionRangeback to summary
public VersionRange(String range)

Creates a version range from the specified string.

Version range string grammar:

range ::= interval | atleast
interval ::= ( '[' | '(' ) left ',' right ( ']' | ')' )
left ::= version
right ::= version
atleast ::= version
Parameters
range:String

String representation of the version range. The versions in the range must contain no whitespace. Other whitespace in the range string is ignored. Must not be null.

Exceptions
IllegalArgumentException:
If range is improperly formatted.

Method Detail

equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Compares this VersionRange object to another object.

A version range is considered to be equal to another version range if both the endpoints and their types are equal or if both version ranges are empty.

Parameters
object:Object

The VersionRange object to be compared.

Returns:boolean

true if object is a VersionRange and is equal to this object; false otherwise.

Annotations
@Override
getLeftback to summary
public Version getLeft()

Returns the left endpoint of this version range.

Returns:Version

The left endpoint.

getLeftTypeback to summary
public char getLeftType()

Returns the type of the left endpoint of this version range.

Returns:char

LEFT_CLOSED if the left endpoint is closed or LEFT_OPEN if the left endpoint is open.

getRightback to summary
public Version getRight()

Returns the right endpoint of this version range.

Returns:Version

The right endpoint. May be null which indicates the right endpoint is Infinity.

getRightTypeback to summary
public char getRightType()

Returns the type of the right endpoint of this version range.

Returns:char

RIGHT_CLOSED if the right endpoint is closed or RIGHT_OPEN if the right endpoint is open.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.

Returns:int

An integer which is a hash code value for this object.

Annotations
@Override
includesback to summary
public boolean includes(Version version)

Returns whether this version range includes the specified version.

Parameters
version:Version

The version to test for inclusion in this version range.

Returns:boolean

true if the specified version is included in this version range; false otherwise.

intersectionback to summary
public VersionRange intersection(VersionRange... ranges)

Returns the intersection of this version range with the specified version ranges.

Parameters
ranges:VersionRange[]

The version ranges to intersect with this version range.

Returns:VersionRange

A version range representing the intersection of this version range and the specified version ranges. If no version ranges are specified, then this version range is returned.

isEmptyback to summary
public boolean isEmpty()

Returns whether this version range is empty. A version range is empty if the set of versions defined by the interval is empty.

Returns:boolean

true if this version range is empty; false otherwise.

isEmpty0back to summary
private boolean isEmpty0()

Internal isEmpty behavior.

Returns:boolean

true if this version range is empty; false otherwise.

isExactback to summary
public boolean isExact()

Returns whether this version range contains only a single version.

Returns:boolean

true if this version range contains only a single version; false otherwise.

parseVersionback to summary
private static Version parseVersion(String version, String range)

Parse version component into a Version.

Parameters
version:String

version component string

range:String

Complete range string for exception message, if any

Returns:Version

Version

toFilterStringback to summary
public String toFilterString(String attributeName)

Returns the filter string for this version range using the specified attribute name.

Parameters
attributeName:String

The attribute name to use in the returned filter string.

Returns:String

A filter string for this version range using the specified attribute name.

Exceptions
IllegalArgumentException:
If the specified attribute name is not a valid attribute name.
See Also
Core Specification, Filters, for a description of the filter string syntax.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the string representation of this version range.

The format of the version range string will be a version string if the right end point is Infinity (null) or an interval string.

Returns:String

The string representation of this version range.

Annotations
@Override
valueOfback to summary
public static VersionRange valueOf(String range)

Returns a VersionRange object holding the version range in the specified String.

See VersionRange(String) for the format of the version range string.

Parameters
range:String

String representation of the version range. The versions in the range must contain no whitespace. Other whitespace in the range string is ignored. Must not be null.

Returns:VersionRange

A VersionRange object representing the version range.

Exceptions
IllegalArgumentException:
If range is improperly formatted.
Since
1.8