org.knopflerfish.framework
Class VersionRange

java.lang.Object
  extended by org.knopflerfish.framework.VersionRange
All Implemented Interfaces:
java.lang.Comparable

public class VersionRange
extends java.lang.Object
implements java.lang.Comparable

Class representing OSGi version ranges.


Field Summary
static VersionRange defaultVersionRange
          The empty version range "[0.0.0,inf)".
 
Constructor Summary
protected VersionRange()
          Construct the default VersionRange object.
  VersionRange(java.lang.String vr)
          Construct a VersionRange object.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compare object to another VersionRange.
 boolean equals(java.lang.Object obj)
          Check if object is equal to this object.
 int hashCode()
          Hash code for this package entry.
 boolean isSpecified()
           
 java.lang.String toString()
          String with version number.
 boolean withinRange(Version ver)
          Check if specified version is within our range.
 boolean withinRange(VersionRange range)
          Check if objects range is within another VersionRange.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultVersionRange

public static final VersionRange defaultVersionRange
The empty version range "[0.0.0,inf)".

Constructor Detail

VersionRange

public VersionRange(java.lang.String vr)
             throws java.lang.NumberFormatException
Construct a VersionRange object. Format for a range: ( "(" | "[" ) LOW_VERSION "," HIGH_VERSION ( ")" | "]" ) Format for at least a version: VERSION

Parameters:
vr - Input string.
Throws:
java.lang.NumberFormatException

VersionRange

protected VersionRange()
Construct the default VersionRange object.

Method Detail

isSpecified

public boolean isSpecified()

withinRange

public boolean withinRange(Version ver)
Check if specified version is within our range.

Parameters:
ver - Version to compare to.
Returns:
Return true if within range, otherwise false.

withinRange

public boolean withinRange(VersionRange range)
Check if objects range is within another VersionRange.

Parameters:
range - VersionRange to compare to.
Returns:
Return true if within range, otherwise false.

compareTo

public int compareTo(java.lang.Object obj)
              throws java.lang.ClassCastException
Compare object to another VersionRange. VersionRanges are compared on the lower bound.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - VersionRange to compare to.
Returns:
Return 0 if equals, negative if this object is less than obj and positive if this object is larger then obj.
Throws:
java.lang.ClassCastException - if object is not a VersionRange object.

toString

public java.lang.String toString()
String with version number. If version is not specified return an empty string.

Overrides:
toString in class java.lang.Object
Returns:
String.

equals

public boolean equals(java.lang.Object obj)
               throws java.lang.ClassCastException
Check if object is equal to this object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Package entry to compare to.
Returns:
true if equal, otherwise false.
Throws:
java.lang.ClassCastException

hashCode

public int hashCode()
Hash code for this package entry.

Overrides:
hashCode in class java.lang.Object
Returns:
int value.