FileDocCategorySizeDatePackage
PageRange.javaAPI DocAndroid 5.1 API4480Thu Mar 12 22:22:10 GMT 2015android.print

PageRange

public final class PageRange extends Object implements android.os.Parcelable
Represents a range of pages. The start and end page indices of the range are zero based and inclusive.

Fields Summary
public static final PageRange
ALL_PAGES
Constant for specifying all pages.
private final int
mStart
private final int
mEnd
public static final Parcelable.Creator
CREATOR
Constructors Summary
public PageRange(int start, int end)
Creates a new instance.

param
start The start page index (zero based and inclusive).
param
end The end page index (zero based and inclusive).
throws
IllegalArgumentException If start is less than zero or end is less than zero or start greater than end.


                                                    
         
        if (start < 0) {
            throw new IllegalArgumentException("start cannot be less than zero.");
        }
        if (end < 0) {
            throw new IllegalArgumentException("end cannot be less than zero.");
        }
        if (start > end) {
            throw new IllegalArgumentException("start must be lesser than end.");
        }
        mStart = start;
        mEnd = end;
    
private PageRange(android.os.Parcel parcel)

        this(parcel.readInt(), parcel.readInt());
    
Methods Summary
public booleancontains(int pageIndex)
Gets whether a page range contains a a given page.

param
pageIndex The page index.
return
True if the page is within this range.
hide

        return (pageIndex >= mStart) && (pageIndex <= mEnd);
    
public intdescribeContents()

        return 0;
    
public booleanequals(java.lang.Object obj)

        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        PageRange other = (PageRange) obj;
        if (mEnd != other.mEnd) {
            return false;
        }
        if (mStart != other.mStart) {
            return false;
        }
        return true;
    
public intgetEnd()
Gets the end page index (zero based and inclusive).

return
The end page index.

        return mEnd;
    
public intgetSize()
Get the size of this range which is the number of pages it contains.

return
The size of the range.
hide

        return mEnd - mStart + 1;
    
public intgetStart()
Gets the start page index (zero based and inclusive).

return
The start page index.

        return mStart;
    
public inthashCode()

        final int prime = 31;
        int result = 1;
        result = prime * result + mEnd;
        result = prime * result + mStart;
        return result;
    
public java.lang.StringtoString()

        if (mStart == 0 && mEnd == Integer.MAX_VALUE) {
            return "PageRange[<all pages>]";
        }
        StringBuilder builder = new StringBuilder();
        builder.append("PageRange[")
            .append(mStart)
            .append(" - ")
            .append(mEnd)
            .append("]");
        return builder.toString();
    
public voidwriteToParcel(android.os.Parcel parcel, int flags)

        parcel.writeInt(mStart);
        parcel.writeInt(mEnd);