PATH
Mac OS X Documentation >
Foundation Reference: Java
[Previous] [Class List] [Next]
Inherits
from: NSRange : Object
Implements: Cloneable
(inherited from NSRange
Package: com.apple.yellow.foundation
Class Description
An NSMutableRange is an object representing
a range that can be changed. A range is a measurement of a segment
of something linear, such as a byte stream. You can change an NSMutableRange's
two primary values, its location and its length. The methods of NSMutableRange
also enable you to alter an NSMutableRange based on its union or intersection
with another NSRange object.
The main purpose for NSMutableRanges is to provide away for
methods to return range values in an "out" parameter. A client
creates and passes in one or more NSMutableRanges to a method and
gets back changed objects when the method returns. NSMutableRanges
are also useful for performance reasons; instead of creating multiple NSRanges
in a loop, you can create just one NSMutableRange and reuse it.
Method Types
- Accessing and setting
range elements
- length
- setLength
- location
- setLocation
- Transforming mutable ranges
- intersectRange
- unionRange
Constructors
NSMutableRange
public NSMutableRange()
Initializes the object to an empty NSRange.
public NSMutableRange(int location,
int length)
Initializes the NSRange with the range elements
of location and length;
it throws an IllegalArgumentException if either integer is negative.
public NSMutableRange(NSRange
aRange)
The third constructor initializes the new NSRange
with the location and length values of aRange;
this constructor is used in cloning the receiver.
Instance Methods
protected void finalize()
This method performs implementation-specific
cleanup tasks. If you override this class in a subclass, be sure
to invoke super's implementation.
public void intersectRange(NSRange aRange)
Changes the receiver to the range resulting
from the intersection of aRange and
the receiver before the operation. Sets the receiver to an empty
range if they do not intersect.See Also: unionRange
public ing length()
Returns the length of the receiver, its distance
from its starting location. NSMutableRange overrides this method
because of internal implementation requirements.See
Also: location
public int location()
Returns the starting location of the receiver.
NSMutableRange overrides this method because of internal implementation
requirements.See Also: length
public void setLength(int newLength)
Sets the length of the receiver to newLength.
Throws an IllegalArgumentException if newLength is
a negative value.See Also: setLocation
public void setLocation(int newLocation)
Sets the length of the receiver to newLocation.
Throws an IllegalArgumentException if newLocation is
a negative value.See Also: setLength
public void unionRange(NSRange aRange)
Changes the receiver to the range resulting
from the union of aRange and the
receiver before the operation. This is the lowest starting location
and the highest ending location of the two NSRanges.See
Also: intersectRange
[Previous] [Next]