|
WebObjects 5.2.3 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.foundation.NSRange
An NSRange represents a range, a measurement of a segment of something linear, such as a byte stream. An NSRange has two primary values, a location and a length. The methods of NSRange give access to these values, convert between NSRanges and their string representations, test and compare ranges, and create ranges based on operations involving the union, intersection, and subtraction of two ranges.
The NSRange methods described below provide the basis for all NSRange's other methods; that is, all other methods are implemented in terms of these two. If you create a subclass of NSRange, you need only ensure that these base methods work properly. Having done so, you can be sure that all your subclass's inherited methods operate properly.
Method | Description |
length | returns the length of this NSRange from its starting location |
location | returns the starting location of this NSRange |
length()
,
location()
,
Serialized FormField Summary | |
static NSRange |
ZeroRange
An NSRange set to zero in location and length. |
Constructor Summary | |
NSRange()
Creates an NSRange with zero location and length. |
|
NSRange(int location,
int length)
Creates a NSRange with the range elements of location
and length . |
|
NSRange(NSRange range)
Creates an NSRange with the location and length values of range . |
Method Summary | |
Object |
clone()
Simply returns this NSRange. |
boolean |
containsLocation(int location)
Indicates whether a location falls within the limits specified by this NSRange. |
boolean |
equals(Object object)
Indicates whether an object is an NSRange whose location and length are equal to this range's location and length. |
static NSRange |
fromString(String string)
Creates an NSRange from a string. |
int |
hashCode()
Provides an appropriate hash code useful for storing this NSRange in a hash-based data structure. |
boolean |
intersectsRange(NSRange otherRange)
Indicates whether the range otherRange intersects
this NSRange. |
boolean |
isEmpty()
|
boolean |
isEqualToRange(NSRange otherRange)
Indicates whether the range's location and length are equal to this NSRange's location and length. |
boolean |
isSubrangeOfRange(NSRange otherRange)
Indicates whether this NSRange's end points match or fall within those of another range. |
int |
length()
|
int |
location()
|
boolean |
locationInRange(int location)
Deprecated. Use containsLocation(int) |
int |
maxRange()
Returns the extent of this NSRange (its starting location plus its length). |
NSRange |
rangeByIntersectingRange(NSRange otherRange)
Returns an NSRange that is the intersection of a range and this NSRange. |
NSRange |
rangeByUnioningRange(NSRange otherRange)
Returns an NSRange that is the union of a range and this NSRange (a range constructed from the lowest starting location and the highest ending location of both NSRanges). |
void |
subtractRange(NSRange otherRange,
NSMutableRange resultRange1,
NSMutableRange resultRange2)
Subtracts a range from this NSRange and stores the result in one or two NSMutableRanges. |
String |
toString()
Returns a string representing this NSRange. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final NSRange ZeroRange
Constructor Detail |
public NSRange()
ZeroRange
shared instance.
public NSRange(int location, int length)
location
and length
.
location
- location of the current rangelength
- length of the current range
a
- java.lang.IllegalArgumentException if either location or
length of the range is negativepublic NSRange(NSRange range)
range
.
range
- measurement of the linear stream segmentMethod Detail |
public Object clone()
public boolean containsLocation(int location)
location
- location of the linear stream segment
true
if location
is in the range specified
by this NSRangeintersectsRange(com.webobjects.foundation.NSRange)
,
location()
public boolean equals(Object object)
object
- the range being compared to this NSRange
true
if the ranges are identicalisEqualToRange(com.webobjects.foundation.NSRange)
,
isSubrangeOfRange(com.webobjects.foundation.NSRange)
public static NSRange fromString(String string)
location
is a number
representing the starting location of the range and length
is the range's
length.
string
- the range definition; must be in the form "{location,length}"
string
IllegalArgumentException
- string
is
improperly formattedtoString()
public int hashCode()
public boolean intersectsRange(NSRange otherRange)
otherRange
intersects
this NSRange.
otherRange
- the range to be compared with this NSRange
true
if the ranges have anything in commonrangeByIntersectingRange(com.webobjects.foundation.NSRange)
public boolean isEmpty()
true
if this NSRange's length is 0
maxRange()
public boolean isEqualToRange(NSRange otherRange)
otherRange
- range to be compared with this NSRange
true
if the ranges are equalequals(java.lang.Object)
,
isSubrangeOfRange(com.webobjects.foundation.NSRange)
public boolean isSubrangeOfRange(NSRange otherRange)
otherRange
- the range to be compared with this NSRange
true
if otherRange
is a subset of this NSRangeintersectsRange(com.webobjects.foundation.NSRange)
public int length()
location()
public int location()
length()
public boolean locationInRange(int location)
containsLocation(int)
location
- location of the linear stream segment
true
if location
is in this NSRangepublic int maxRange()
isEmpty()
,
length()
,
location()
public NSRange rangeByIntersectingRange(NSRange otherRange)
otherRange
- range to be compared with this NSRange
otherRange
and this NSRangerangeByUnioningRange(com.webobjects.foundation.NSRange)
,
subtractRange(com.webobjects.foundation.NSRange, com.webobjects.foundation.NSMutableRange, com.webobjects.foundation.NSMutableRange)
,
isEmpty()
public NSRange rangeByUnioningRange(NSRange otherRange)
otherRange
- range to be united with this NSRange
otherRange
rangeByIntersectingRange(com.webobjects.foundation.NSRange)
,
subtractRange(com.webobjects.foundation.NSRange, com.webobjects.foundation.NSMutableRange, com.webobjects.foundation.NSMutableRange)
public void subtractRange(NSRange otherRange, NSMutableRange resultRange1, NSMutableRange resultRange2)
otherRange
- range to be subtracted from this NSRangeresultRange1
- mutable range provided by callerresultRange2
- mutable range provided by callerrangeByIntersectingRange(com.webobjects.foundation.NSRange)
,
rangeByUnioningRange(com.webobjects.foundation.NSRange)
public String toString()
location
is the starting location of the range
and length
is its length.
fromString(java.lang.String)
|
Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |