edu.northwestern.at.wordhoard.model.text
Class TextRange

java.lang.Object
  extended by edu.northwestern.at.wordhoard.model.text.TextRange
All Implemented Interfaces:
java.io.Serializable

public class TextRange
extends java.lang.Object
implements java.io.Serializable

A text range.

See Also:
Serialized Form

Constructor Summary
TextRange()
          Creates a new empty range.
TextRange(TextLocation loc)
          Creates a new text range containing a single location.
TextRange(TextLocation start, TextLocation end)
          Creates a new text range.
 
Method Summary
 boolean contains(TextLocation loc)
          Returns true if this range contains a location.
 boolean equals(java.lang.Object o)
          Returns true if this range equals another range.
 TextLocation getEnd()
          Gets the end of the range.
 TextLocation getStart()
          Gets the start of the range.
 boolean isEmpty()
          Returns true if the range is empty.
 void setEnd(TextLocation end)
          Sets the end of the range.
 void setStart(TextLocation start)
          Sets the start of the range.
 java.lang.String toString()
          Returns a string representation of the range.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextRange

public TextRange()
Creates a new empty range.


TextRange

public TextRange(TextLocation start,
                 TextLocation end)
Creates a new text range.

Parameters:
start - Start of range.
end - End of range.

TextRange

public TextRange(TextLocation loc)
Creates a new text range containing a single location.

Parameters:
loc - Start and end location.
Method Detail

getStart

public TextLocation getStart()
Gets the start of the range.

Returns:
Start of range.

setStart

public void setStart(TextLocation start)
Sets the start of the range.

Parameters:
start - Start of range.

getEnd

public TextLocation getEnd()
Gets the end of the range.

Returns:
End of range.

setEnd

public void setEnd(TextLocation end)
Sets the end of the range.

Parameters:
end - End of range.

isEmpty

public boolean isEmpty()
Returns true if the range is empty.

The range is empty if the start location is greater than or equal to the end location.

Returns:
True if range is empty.

equals

public boolean equals(java.lang.Object o)
Returns true if this range equals another range.

Overrides:
equals in class java.lang.Object
Parameters:
o - The other range.
Returns:
True if the range equals the other range.

contains

public boolean contains(TextLocation loc)
Returns true if this range contains a location.

Parameters:
loc - Location.
Returns:
True if range contains location.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
The string representation.