|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.foundation.NSRange
public class 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 |
NSRange.length()
,
NSRange.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 NSRange.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
IllegalArgumentException
- if either location or
length of the range is negativepublic NSRange(NSRange range)
range
.
range
- measurement of the linear stream segmentMethod Detail |
---|
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 formattedNSRange.toString()
public int location()
NSRange.length()
public int length()
NSRange.location()
public NSRange rangeByUnioningRange(NSRange otherRange)
otherRange
- range to be united with this NSRange
otherRange
NSRange.rangeByIntersectingRange(com.webobjects.foundation.NSRange)
,
NSRange.subtractRange(com.webobjects.foundation.NSRange, com.webobjects.foundation.NSMutableRange, com.webobjects.foundation.NSMutableRange)
public NSRange rangeByIntersectingRange(NSRange otherRange)
otherRange
- range to be compared with this NSRange
otherRange
and this NSRangeNSRange.rangeByUnioningRange(com.webobjects.foundation.NSRange)
,
NSRange.subtractRange(com.webobjects.foundation.NSRange, com.webobjects.foundation.NSMutableRange, com.webobjects.foundation.NSMutableRange)
,
NSRange.isEmpty()
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 callerNSRange.rangeByIntersectingRange(com.webobjects.foundation.NSRange)
,
NSRange.rangeByUnioningRange(com.webobjects.foundation.NSRange)
public int maxRange()
NSRange.isEmpty()
,
NSRange.length()
,
NSRange.location()
public boolean isEmpty()
true
if this NSRange's length is 0
NSRange.maxRange()
public boolean containsLocation(int location)
location
- location of the linear stream segment
true
if location
is in the range specified
by this NSRangeNSRange.intersectsRange(com.webobjects.foundation.NSRange)
,
NSRange.location()
@Deprecated public boolean locationInRange(int location)
NSRange.containsLocation(int)
location
- location of the linear stream segment
true
if location
is in this NSRangepublic boolean intersectsRange(NSRange otherRange)
otherRange
intersects
this NSRange.
otherRange
- the range to be compared with this NSRange
true
if the ranges have anything in commonNSRange.rangeByIntersectingRange(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 NSRangeNSRange.intersectsRange(com.webobjects.foundation.NSRange)
public boolean isEqualToRange(NSRange otherRange)
otherRange
- range to be compared with this NSRange
true
if the ranges are equalNSRange.equals(java.lang.Object)
,
NSRange.isSubrangeOfRange(com.webobjects.foundation.NSRange)
public boolean equals(Object object)
equals
in class Object
object
- the range being compared to this NSRange
true
if the ranges are identicalNSRange.isEqualToRange(com.webobjects.foundation.NSRange)
,
NSRange.isSubrangeOfRange(com.webobjects.foundation.NSRange)
public int hashCode()
hashCode
in class Object
public Object clone()
clone
in class Object
public String toString()
location
is the starting location of the range
and length
is its length.
toString
in class Object
NSRange.fromString(java.lang.String)
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |