aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java/com/libmailcore/Range.java
blob: 3e508f9b8a4c36c6df81c350e50241a05ec04ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.libmailcore;

/** Range of integer values. */
public class Range {
    /** Location. */
    public long location;
    /** Length of the range. A length of 0 is a range with only one item: the location. */
    public long length;

    /** When using RangeMax as the length of the range, it means that the range is infinite. */
    static public long RangeMax = 1 >> 63 - 1;

    /** Constructor for a range starting at 0 and of length 0. */
    public Range() {}
    /** Constructor */
    public Range(long aLocation, long aLength)
    {
        location = aLocation;
        length = aLength;
    }
    
    /** Subtract otherRange from this range and returns the resulting set of indexes. */
    public native IndexSet removeRange(Range otherRange);
    /** Union of otherRange and this range and returns the resulting set of indexes. */
    public native IndexSet union(Range otherRange);
    /** Returns the range resulting from the intersection. */
    public native Range intersection(Range otherRange);
    /** Returns whether the intersection is non-empty. */
    public native boolean hasIntersection(Range otherRange);
    /** Returns the included left bound of the range. */
    public native long leftBound();
    /** Returns the included right bound of the range. */
    public native long rightBound();
    /** Returns a string representation of range. */
    public native String toString();
    
    /** Create a range using a string representation. */
    public static native Range rangeWithString(String rangeString);

    static {
        MainThreadUtils.singleton();
    }
}