edu.northwestern.at.utils.intcollections
Class IntRange

java.lang.Object
  extended by edu.northwestern.at.utils.intcollections.IntRange
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class IntRange
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A range of integers.

See Also:
Serialized Form

Field Summary
 int first
          The first integer in the range.
 int last
          The last integer in the range + 1.
 
Constructor Summary
IntRange(int first, int last)
          Constructs a new integer range.
IntRange(java.lang.String str)
          Constructs a new integer range from a string.
 
Method Summary
 java.lang.Object clone()
          Returns a copy of the range.
 java.lang.String toString()
          Returns a string representation of the range.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

first

public int first
The first integer in the range.


last

public int last
The last integer in the range + 1.

Constructor Detail

IntRange

public IntRange(int first,
                int last)
Constructs a new integer range.

Parameters:
first - The first integer in the range.
last - The last integer in the range + 1.
Throws:
java.lang.IllegalArgumentException - If first >= last.

IntRange

public IntRange(java.lang.String str)
Constructs a new integer range from a string.

Parameters:
str - The string.
Throws:
java.lang.IllegalArgumentException - If syntax error in string.
Method Detail

toString

public java.lang.String toString()
Returns a string representation of the range.

If last = first+1: "first".

If last > first+1: "first-xxx" where "xxx"is last-1.

Overrides:
toString in class java.lang.Object
Returns:
The integer range as a string.

clone

public java.lang.Object clone()
Returns a copy of the range.

Overrides:
clone in class java.lang.Object
Returns:
The copy.