1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.wotonomy.foundation;
20
21 /***
22 * A pure java implementation of NSMutableRange.
23 * An NSMutableRange is a modifiable NSRange.
24 *
25 * @author michael@mpowers.net
26 * @author $Author: cgruber $
27 * @version $Revision: 893 $
28 */
29 public class NSMutableRange extends NSRange
30 {
31 /***
32 * Default constructor produces an empty range.
33 */
34 public NSMutableRange ()
35 {
36 super();
37 }
38
39 /***
40 * Produces a range that has the same location and length as
41 * the specified range.
42 */
43 public NSMutableRange (NSRange aRange)
44 {
45 super( aRange );
46 }
47
48 /***
49 * Produces a range with the specified location and length.
50 */
51 public NSMutableRange (int location, int length)
52 {
53 super( location, length );
54 }
55
56 /***
57 * Sets the location of this range.
58 */
59 public void setLocation (int location)
60 {
61 loc = location;
62 }
63
64 /***
65 * Sets the length of this range.
66 */
67 public void setLength (int length)
68 {
69 len = length;
70 }
71
72 /***
73 * Modifies this range to be the union of this
74 * range and the specified range.
75 */
76 public void unionRange (NSRange aRange)
77 {
78 NSRange range = rangeByUnioningRange( aRange );
79 setLocation( range.location() );
80 setLength( range.length() );
81 }
82
83 /***
84 * Modifies this range to be the intersection of this
85 * range and the specified range.
86 */
87 public void intersectRange (NSRange aRange)
88 {
89 NSRange range = rangeByIntersectingRange( aRange );
90 setLocation( range.location() );
91 setLength( range.length() );
92 }
93
94 /***
95 * Returns a copy of this range.
96 */
97 public Object clone ()
98 {
99 return new NSMutableRange( location(), length() );
100 }
101 }
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116