类 VersionRange
- java.lang.Object
-
- org.osgi.framework.VersionRange
-
public class VersionRange extends java.lang.ObjectVersion range. A version range is an interval describing a set ofversions.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).
VersionRangeobjects are immutable.- 从以下版本开始:
- 1.7
- 作者:
- $Id: 1f5fa660a1a42e83371fe0d2c61ae79ce1cb1710 $
-
-
字段概要
字段 修饰符和类型 字段 说明 static charLEFT_CLOSEDThe left endpoint is closed and is included in the range.static charLEFT_OPENThe left endpoint is open and is excluded from the range.static charRIGHT_CLOSEDThe right endpoint is closed and is included in the range.static charRIGHT_OPENThe right endpoint is open and is excluded from the range.
-
构造器概要
构造器 构造器 说明 VersionRange(char leftType, Version leftEndpoint, Version rightEndpoint, char rightType)Creates a version range from the specified versions.VersionRange(java.lang.String range)Creates a version range from the specified string.
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 booleanequals(java.lang.Object object)Compares thisVersionRangeobject to another object.VersiongetLeft()Returns the left endpoint of this version range.chargetLeftType()Returns the type of the left endpoint of this version range.VersiongetRight()Returns the right endpoint of this version range.chargetRightType()Returns the type of the right endpoint of this version range.inthashCode()Returns a hash code value for the object.booleanincludes(Version version)Returns whether this version range includes the specified version.VersionRangeintersection(VersionRange... ranges)Returns the intersection of this version range with the specified version ranges.booleanisEmpty()Returns whether this version range is empty.booleanisExact()Returns whether this version range contains only a single version.java.lang.StringtoFilterString(java.lang.String attributeName)Returns the filter string for this version range using the specified attribute name.java.lang.StringtoString()Returns the string representation of this version range.static VersionRangevalueOf(java.lang.String range)Returns aVersionRangeobject holding the version range in the specifiedString.
-
-
-
字段详细资料
-
LEFT_OPEN
public static final char LEFT_OPEN
The left endpoint is open and is excluded from the range.The value of
LEFT_OPENis'('.- 另请参阅:
- 常量字段值
-
LEFT_CLOSED
public static final char LEFT_CLOSED
The left endpoint is closed and is included in the range.The value of
LEFT_CLOSEDis'['.- 另请参阅:
- 常量字段值
-
RIGHT_OPEN
public static final char RIGHT_OPEN
The right endpoint is open and is excluded from the range.The value of
RIGHT_OPENis')'.- 另请参阅:
- 常量字段值
-
RIGHT_CLOSED
public static final char RIGHT_CLOSED
The right endpoint is closed and is included in the range.The value of
RIGHT_CLOSEDis']'.- 另请参阅:
- 常量字段值
-
-
构造器详细资料
-
VersionRange
public VersionRange(char leftType, Version leftEndpoint, Version rightEndpoint, char rightType)Creates a version range from the specified versions.- 参数:
leftType- Must be eitherLEFT_CLOSEDorLEFT_OPEN.leftEndpoint- Left endpoint of range. Must not benull.rightEndpoint- Right endpoint of range. May benullto indicate the right endpoint is Infinity.rightType- Must be eitherRIGHT_CLOSEDorRIGHT_OPEN.- 抛出:
java.lang.IllegalArgumentException- If the arguments are invalid.
-
VersionRange
public VersionRange(java.lang.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- 参数:
range- 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 benull.- 抛出:
java.lang.IllegalArgumentException- Ifrangeis improperly formatted.
-
-
方法详细资料
-
getLeft
public Version getLeft()
Returns the left endpoint of this version range.- 返回:
- The left endpoint.
-
getRight
public Version getRight()
Returns the right endpoint of this version range.- 返回:
- The right endpoint. May be
nullwhich indicates the right endpoint is Infinity.
-
getLeftType
public char getLeftType()
Returns the type of the left endpoint of this version range.- 返回:
LEFT_CLOSEDif the left endpoint is closed orLEFT_OPENif the left endpoint is open.
-
getRightType
public char getRightType()
Returns the type of the right endpoint of this version range.- 返回:
RIGHT_CLOSEDif the right endpoint is closed orRIGHT_OPENif the right endpoint is open.
-
includes
public boolean includes(Version version)
Returns whether this version range includes the specified version.- 参数:
version- The version to test for inclusion in this version range.- 返回:
trueif the specified version is included in this version range;falseotherwise.
-
intersection
public VersionRange intersection(VersionRange... ranges)
Returns the intersection of this version range with the specified version ranges.- 参数:
ranges- The version ranges to intersect with this version range.- 返回:
- 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.
-
isEmpty
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.- 返回:
trueif this version range is empty;falseotherwise.
-
isExact
public boolean isExact()
Returns whether this version range contains only a single version.- 返回:
trueif this version range contains only a single version;falseotherwise.
-
toString
public java.lang.String 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.- 覆盖:
toString在类中java.lang.Object- 返回:
- The string representation of this version range.
-
hashCode
public int hashCode()
Returns a hash code value for the object.- 覆盖:
hashCode在类中java.lang.Object- 返回:
- An integer which is a hash code value for this object.
-
equals
public boolean equals(java.lang.Object object)
Compares thisVersionRangeobject 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.- 覆盖:
equals在类中java.lang.Object- 参数:
object- TheVersionRangeobject to be compared.- 返回:
trueifobjectis aVersionRangeand is equal to this object;falseotherwise.
-
toFilterString
public java.lang.String toFilterString(java.lang.String attributeName)
Returns the filter string for this version range using the specified attribute name.- 参数:
attributeName- The attribute name to use in the returned filter string.- 返回:
- A filter string for this version range using the specified attribute name.
- 抛出:
java.lang.IllegalArgumentException- If the specified attribute name is not a valid attribute name.- 另请参阅:
- "Core Specification, Filters, for a description of the filter string syntax."
-
valueOf
public static VersionRange valueOf(java.lang.String range)
Returns aVersionRangeobject holding the version range in the specifiedString.See
VersionRange(String)for the format of the version range string.- 参数:
range- 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 benull.- 返回:
- A
VersionRangeobject representing the version range. - 抛出:
java.lang.IllegalArgumentException- Ifrangeis improperly formatted.- 从以下版本开始:
- 1.8
-
-