Project JXTA

net.jxta.impl.document
Class LiteXMLElement.charRange

java.lang.Object
  |
  +--net.jxta.impl.document.LiteXMLElement.charRange
Enclosing class:
LiteXMLElement

protected class LiteXMLElement.charRange
extends java.lang.Object

A charRange defines a range of characters, probably within a string. The range is deemed to be invalid if 'start' is -1. A zero length range is, by convention, described by an 'end' value of 'start' - 1.


Field Summary
 int end
          Contains the end position of this range.
 int start
          Contains the start position of this range.
 
Constructor Summary
LiteXMLElement.charRange()
          Constructor for a null charRange.
LiteXMLElement.charRange(int start, int end)
          Constructor for which the bounds are specified.
 
Method Summary
 int compareTo(java.lang.Object aRange)
          Compares two ranges for equality.
 boolean contains(int someLoc)
          Returns true if the location specified is contained in this range.
 boolean contains(LiteXMLElement.charRange someRange)
          Returns true if the charRange specified by someRange is contained within this range.
 boolean equals(java.lang.Object aRange)
          Compares two ranges for equality.
 boolean isValid()
          Returns true if the range is both non-null and has a length of greater than or equal to zero.
 int length()
          Returns the length of this range.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start

public int start
Contains the start position of this range.

end

public int end
Contains the end position of this range. one weird thing: if end == start -1, then the item is of zero length begining at start.
Constructor Detail

LiteXMLElement.charRange

public LiteXMLElement.charRange()
Constructor for a null charRange.

LiteXMLElement.charRange

public LiteXMLElement.charRange(int start,
                                int end)
Constructor for which the bounds are specified.
Method Detail

length

public int length()
Returns the length of this range.
Returns:
The length of the range or -1 if the range is null.

isValid

public boolean isValid()
Returns true if the range is both non-null and has a length of greater than or equal to zero.
Returns:
true if the range is a valid one, otherwise false.

equals

public boolean equals(java.lang.Object aRange)
Compares two ranges for equality.
Overrides:
equals in class java.lang.Object
Parameters:
someRange - The range against which this range will be compared.
Returns:
true if the two ranges are equal, otherwise false.

compareTo

public int compareTo(java.lang.Object aRange)
              throws java.lang.ClassCastException
Compares two ranges for equality.
Parameters:
someRange - The range against which this range will be compared.
Returns:
true if the two ranges are equal, otherwise false.

contains

public boolean contains(LiteXMLElement.charRange someRange)
Returns true if the charRange specified by someRange is contained within this range.
Parameters:
someRange - The range which must be contained within this range.
Returns:
true if the specified range is contained with this range otherwise false.

contains

public boolean contains(int someLoc)
Returns true if the location specified is contained in this range.
Parameters:
someLoc - the location which is to be tested.
Returns:
true if the location is in this range, otherwise false.

Project JXTA