mapss.dif.attributes
Class IntervalCollection

java.lang.Object
  extended by mapss.dif.attributes.IntervalCollection

public class IntervalCollection
extends java.lang.Object

This class is intented for use with parametrizable attributes. It carries possible values for an interval which could be intervals and/or points.

Version:
$Id: IntervalCollection.java 409 2007-05-13 19:47:16Z plishker $
Author:
Fuat Keceli based on a file by Shahrooz Shahparnia

Constructor Summary
protected IntervalCollection()
           
  IntervalCollection(java.lang.String name)
          Creates an interval collection with a name.
 
Method Summary
 void add(Interval interval)
          Adds an interval to the list of intervals in this collection.
 java.lang.Object clone()
          Clone this IntervalCollection.
static Interval combine(Interval interval1, Interval interval2)
          Combine two intervals if they can be expressed as a single interval.
 boolean equals(java.lang.Object collection)
          Returns true if two collection contains the same mathematical intervals.
 java.util.List getIntervals()
          Returns a list of intervals and defines this collection.
 java.lang.String getName()
          Returns the name of this collection.
 int hashCode()
           
 java.lang.String toString()
          Prints out the collection of intervals and points in this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntervalCollection

protected IntervalCollection()

IntervalCollection

public IntervalCollection(java.lang.String name)
Creates an interval collection with a name. Names are important for parametrizing DIFGraphs. For the DIFWriters to work properly, different parameters should have different names.

Parameters:
name - Name of the parameter.
Method Detail

add

public void add(Interval interval)
Adds an interval to the list of intervals in this collection. Maintains the order while adding.

Parameters:
interval - Interval that will be added to the collection. To add a single point 'a', [a, a] can be used.

clone

public java.lang.Object clone()
Clone this IntervalCollection.

Overrides:
clone in class java.lang.Object
Returns:
The cloned version of this IntervalCollection.

combine

public static Interval combine(Interval interval1,
                               Interval interval2)
Combine two intervals if they can be expressed as a single interval. Return null otherwise.

Returns:
The combined interval. Null if the intervals cannot be combined.

equals

public boolean equals(java.lang.Object collection)
Returns true if two collection contains the same mathematical intervals.

Overrides:
equals in class java.lang.Object
Returns:
True if two interval collections are mathematically the same.

getIntervals

public java.util.List getIntervals()
Returns a list of intervals and defines this collection. Returned list has the minimal property (which means there are no replication of points) and is ordered.

Returns:
A list of Intervals. It is a copy of the original list that defines this collection.

getName

public java.lang.String getName()
Returns the name of this collection.

Returns:
The name.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Prints out the collection of intervals and points in this object. Returned string is cannonical (will always be the same for the same set of intervals).

Overrides:
toString in class java.lang.Object
Returns:
A string compatible with DIF.