PATH |
NSRange
- Inherits from:
- Object
- Implements:
- Cloneable
- Serializable
- Package:
- com.webobjects.foundation
Class Description
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.
Table 0-12 describes the NSRange methods that 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 the receiver from its starting location. |
location | Returns the starting location of the receiver. |
Constants
NSRange provides the following constant as a convenience; you can use it to compare values returned by some NSRange methods:
Constant | Type | Description |
ZeroRange | NSRange | An NSRange set to zero in location and length. |
Interfaces Implemented
- Cloneable
- clone
Method Types
- Constructors
- NSRange
- Accessing range elements
- length
- location
- Manipulating ranges
- rangeByIntersectingRange
- rangeByUnioningRange
- subtractRange
- Testing ranges
- containsLocation
- intersectsRange
- isEmpty
- isEqualToRange
- isSubrangeOfRange
- locationInRange
- maxRange
- Methods inherited from Object
- equals
- hashCode
- toString
- Converting Strings to NSRanges
- fromString
Constructors
NSRange
public NSRange()
ZeroRange
shared instance. See Constants.
public NSRange(NSRange aRange)
public NSRange( int location, int length)
Static Methods
fromString
public static NSRange fromString(String rangeAsString)
See Also: toString
Instance Methods
clone
public Object clone()
containsLocation
public boolean containsLocation(int aLocation)
See Also: intersectsRange, location
equals
public boolean equals(Object otherObject)
See Also: isEqualToRange, isSubrangeOfRange
hashCode
public int hashCode()
intersectsRange
public boolean intersectsRange(NSRange aRange)
See Also: rangeByIntersectingRange
isEmpty
public boolean isEmpty()
See Also: maxRange
isEqualToRange
public boolean isEqualToRange(NSRange aRange)
See Also: equals, isSubrangeOfRange
isSubrangeOfRange
public boolean isSubrangeOfRange(NSRange aRange)
See Also: intersectsRange
length
public int length()
See Also: location
location
public int location()
See Also: length
locationInRange
public boolean locationInRange(int aLocation)
maxRange
public int maxRange()
See Also: isEmpty, length, location
rangeByIntersectingRange
public NSRange rangeByIntersectingRange(NSRange aRange)
See Also: rangeByUnioningRange, subtractRange
rangeByUnioningRange
public NSRange rangeByUnioningRange(NSRange aRange)
See Also: rangeByIntersectingRange, subtractRange
subtractRange
public void subtractRange( NSRange otherRange, NSMutableRange resultRange1, NSMutableRange resultRange2)
See Also: rangeByIntersectingRange, rangeByUnioningRange
toString
public String toString()
See Also: fromString
© 2001 Apple Computer, Inc. (Last Published April 17, 2001)