pivot.wtk
Class Span

java.lang.Object
  extended by pivot.wtk.Span

public class Span
extends java.lang.Object

Class representing a range of integer values. The range includes all values in the interval [start, end]. Values may be negative, but the value of start must be less than or equal to the value of end.

Author:
gbrown

Field Summary
static java.lang.String END_KEY
           
static java.lang.String START_KEY
           
 
Constructor Summary
Span()
           
Span(Dictionary<java.lang.String,?> span)
           
Span(int start, int end)
           
Span(Span span)
           
 
Method Summary
 boolean contains(Span span)
          Determines whether this span contains another span.
 Span createIntersection(Span span)
          Determines the intersection of this span and another span.
 Span createUnion(Span span)
          Determines the union of this span and another span.
 boolean equals(java.lang.Object o)
           
 int getEnd()
          Returns the last value in the span.
 long getLength()
          Returns the length of the span.
 int getStart()
          Returns the first value in the span.
 boolean intersects(Span span)
          Determines whether this span intersects with another span.
 void setEnd(int end)
          Sets the last value in the span.
 void setRange(int start, int end)
          Sets the range of the span.
 void setStart(int start)
          Sets the first value in the span.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

START_KEY

public static final java.lang.String START_KEY
See Also:
Constant Field Values

END_KEY

public static final java.lang.String END_KEY
See Also:
Constant Field Values
Constructor Detail

Span

public Span()

Span

public Span(Dictionary<java.lang.String,?> span)

Span

public Span(Span span)

Span

public Span(int start,
            int end)
Method Detail

getStart

public int getStart()
Returns the first value in the span.


setStart

public void setStart(int start)
Sets the first value in the span.

Parameters:
start - The first value in the span. Must be less than or equal to the end value.

getEnd

public int getEnd()
Returns the last value in the span.


setEnd

public void setEnd(int end)
Sets the last value in the span.

Parameters:
end - The last value in the span. Must be greater than or equal to the start value.

getLength

public long getLength()
Returns the length of the span.

Returns:
The length of the span (end minus start + 1).

setRange

public void setRange(int start,
                     int end)
Sets the range of the span.

Parameters:
start - The first value in the span. Must be less than or equal to end.
end - The last value in the span. Must be greater than or equal to start.

contains

public boolean contains(Span span)
Determines whether this span contains another span.

Parameters:
span - The span to test for containment.
Returns:
true if this span contains span; false, otherwise.

intersects

public boolean intersects(Span span)
Determines whether this span intersects with another span.

Parameters:
span - The span to test for intersection.
Returns:
true if this span intersects with span; false, otherwise.

createIntersection

public Span createIntersection(Span span)
Determines the intersection of this span and another span.

Parameters:
span - The span to intersect with this span.
Returns:
A new Span instance representing the intersection of this span and span, or null if the spans do not intersect.

createUnion

public Span createUnion(Span span)
Determines the union of this span and another span.

Parameters:
span - The span to union with this span.
Returns:
A new Span instance representing the union of this span and span.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object