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

Constructor Index

 o IntInterval()
Constructs an "empty" IntInterval.
 o IntInterval(int)
Constructs an IntInterval representing a single int.
 o IntInterval(int, int)
Constructs an IntInterval ranging from a lower limit to an upper limit.

Method Index

 o create(String)
Creates an IntInterval by parsing the string given as input.
 o includes(int)
Checks if the given integer is inside the interval.
 o main(String[])
Tests the class.
 o toString()
Returns a string representation of the object.

Constructors

 o IntInterval
 public IntInterval()
Constructs an "empty" IntInterval.

 o IntInterval
 public IntInterval(int i)
Constructs an IntInterval representing a single int.

Parameters:
i - integer to be inserted
 o 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)

Methods

 o main
 public static void main(String args[])
Tests the class.

 o 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
 o 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
 o 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