All Packages Class Hierarchy This Package Previous Next Index
Class net.strandberg.util.IntInterval
java.lang.Object
|
+----net.strandberg.util.IntInterval
- public class IntInterval
- extends Object
Class IntInterval represents an interval between an upper and a lower limit.
- Version:
- $Revision: 0.0 $
- Author:
- Mats Strandberg
-
IntInterval()
- Constructs an "empty" IntInterval.
-
IntInterval(int)
- Constructs an IntInterval representing a single int.
-
IntInterval(int, int)
- Constructs an IntInterval ranging from a lower limit to an upper limit.
-
create(String)
- Creates an IntInterval by parsing the string given as input.
-
includes(int)
-
Checks if the given integer is inside the interval.
-
main(String[])
- Tests the class.
-
toString()
- Returns a string representation of the object.
IntInterval
public IntInterval()
- Constructs an "empty" IntInterval.
IntInterval
public IntInterval(int i)
- Constructs an IntInterval representing a single int.
- Parameters:
- i - integer to be inserted
IntInterval
public IntInterval(int lower,
int upper)
- Constructs an IntInterval ranging from a lower limit to an upper limit.
- Parameters:
- lower - lower limit for the interval (inclusive)
- upper - upper limit for the interval (inclusive)
main
public static void main(String args[])
- Tests the class.
create
public static IntInterval create(String s)
- Creates an IntInterval by parsing the string given as input.
The string should be on the form integer or
the form integer
-
integer. Examples
of valid input strings are then:
125
7-125
There's no support for parsing negative values
- Parameters:
- s - the string to be parsed
- Returns:
- an IntInterval or null if the string couldn't be parsed
includes
public boolean includes(int i)
- Checks if the given integer is inside the interval.
- Parameters:
- i - the integer to check against the interval
- Returns:
- true if the integer is inside the interval
toString
public String toString()
- Returns a string representation of the object.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index