FileDocCategorySizeDatePackage
PrintJobInfo.javaAPI DocAndroid 5.1 API19300Thu Mar 12 22:22:10 GMT 2015android.print

PrintJobInfo

public final class PrintJobInfo extends Object implements android.os.Parcelable
This class represents the description of a print job. The print job state includes properties such as its id, print attributes used for generating the content, and so on. Note that the print jobs state may change over time and this class represents a snapshot of this state.

Fields Summary
public static final int
STATE_ANY
Constant for matching any print job state.
public static final int
STATE_ANY_VISIBLE_TO_CLIENTS
Constant for matching any print job state.
public static final int
STATE_ANY_ACTIVE
Constant for matching any active print job state.
public static final int
STATE_ANY_SCHEDULED
Constant for matching any scheduled, i.e. delivered to a print service, print job state.
public static final int
STATE_CREATED
Print job state: The print job is being created but not yet ready to be printed.

Next valid states: {@link #STATE_QUEUED}

public static final int
STATE_QUEUED
Print job state: The print jobs is created, it is ready to be printed and should be processed.

Next valid states: {@link #STATE_STARTED}, {@link #STATE_FAILED}, {@link #STATE_CANCELED}

public static final int
STATE_STARTED
Print job state: The print job is being printed.

Next valid states: {@link #STATE_COMPLETED}, {@link #STATE_FAILED}, {@link #STATE_CANCELED}, {@link #STATE_BLOCKED}

public static final int
STATE_BLOCKED
Print job state: The print job is blocked.

Next valid states: {@link #STATE_FAILED}, {@link #STATE_CANCELED}, {@link #STATE_STARTED}

public static final int
STATE_COMPLETED
Print job state: The print job is successfully printed. This is a terminal state.

Next valid states: None

public static final int
STATE_FAILED
Print job state: The print job was printing but printing failed.

Next valid states: {@link #STATE_CANCELED}, {@link #STATE_STARTED}

public static final int
STATE_CANCELED
Print job state: The print job is canceled. This is a terminal state.

Next valid states: None

private PrintJobId
mId
The unique print job id.
private String
mLabel
The human readable print job label.
private PrinterId
mPrinterId
The unique id of the printer.
private String
mPrinterName
The name of the printer - internally used
private int
mState
The state of the print job.
private int
mAppId
The id of the app that created the job.
private String
mTag
Optional tag assigned by a print service.
private long
mCreationTime
The wall time when the print job was created.
private int
mCopies
How many copies to print.
private String
mStateReason
Reason for the print job being in its current state.
private PageRange[]
mPageRanges
The pages to print
private PrintAttributes
mAttributes
The print job attributes size.
private PrintDocumentInfo
mDocumentInfo
Information about the printed document.
private android.os.Bundle
mAdvancedOptions
Advanced printer specific options.
private boolean
mCanceling
Whether we are trying to cancel this print job.
public static final Parcelable.Creator
CREATOR
Constructors Summary
public PrintJobInfo()

hide


     
      
        /* do nothing */
    
public PrintJobInfo(PrintJobInfo other)

hide

        mId = other.mId;
        mLabel = other.mLabel;
        mPrinterId = other.mPrinterId;
        mPrinterName = other.mPrinterName;
        mState = other.mState;
        mAppId = other.mAppId;
        mTag = other.mTag;
        mCreationTime = other.mCreationTime;
        mCopies = other.mCopies;
        mStateReason = other.mStateReason;
        mPageRanges = other.mPageRanges;
        mAttributes = other.mAttributes;
        mDocumentInfo = other.mDocumentInfo;
        mCanceling = other.mCanceling;
        mAdvancedOptions = other.mAdvancedOptions;
    
private PrintJobInfo(android.os.Parcel parcel)

        mId = parcel.readParcelable(null);
        mLabel = parcel.readString();
        mPrinterId = parcel.readParcelable(null);
        mPrinterName = parcel.readString();
        mState = parcel.readInt();
        mAppId = parcel.readInt();
        mTag = parcel.readString();
        mCreationTime = parcel.readLong();
        mCopies = parcel.readInt();
        mStateReason = parcel.readString();
        Parcelable[] parcelables = parcel.readParcelableArray(null);
        if (parcelables != null) {
            mPageRanges = new PageRange[parcelables.length];
            for (int i = 0; i < parcelables.length; i++) {
                mPageRanges[i] = (PageRange) parcelables[i];
            }
        }
        mAttributes = (PrintAttributes) parcel.readParcelable(null);
        mDocumentInfo = (PrintDocumentInfo) parcel.readParcelable(null);
        mCanceling = (parcel.readInt() == 1);
        mAdvancedOptions = parcel.readBundle();
    
Methods Summary
public intdescribeContents()

        return 0;
    
public intgetAdvancedIntOption(java.lang.String key)
Gets the value of an advanced (printer specific) print option.

param
key The option key.
return
The option value.
hide

        if (mAdvancedOptions != null) {
            return mAdvancedOptions.getInt(key);
        }
        return 0;
    
public android.os.BundlegetAdvancedOptions()
Gets the advanced options.

return
The advanced options.
hide

        return mAdvancedOptions;
    
public java.lang.StringgetAdvancedStringOption(java.lang.String key)
Gets the value of an advanced (printer specific) print option.

param
key The option key.
return
The option value.
hide

        if (mAdvancedOptions != null) {
            return mAdvancedOptions.getString(key);
        }
        return null;
    
public intgetAppId()
Sets the owning application id.

return
The owning app id.
hide

        return mAppId;
    
public PrintAttributesgetAttributes()
Gets the print job attributes.

return
The attributes.

        return mAttributes;
    
public intgetCopies()
Gets the number of copies.

return
The number of copies or zero if not set.

        return mCopies;
    
public longgetCreationTime()
Gets the wall time in millisecond when this print job was created.

return
The creation time in milliseconds.

        return mCreationTime;
    
public PrintDocumentInfogetDocumentInfo()
Gets the info describing the printed document.

return
The document info.
hide

        return mDocumentInfo;
    
public PrintJobIdgetId()
Gets the unique print job id.

return
The id.

        return mId;
    
public java.lang.StringgetLabel()
Gets the human readable job label.

return
The label.

        return mLabel;
    
public PageRange[]getPages()
Gets the included pages.

return
The included pages or null if not set.

        return mPageRanges;
    
public PrinterIdgetPrinterId()
Gets the unique target printer id.

return
The target printer id.

        return mPrinterId;
    
public java.lang.StringgetPrinterName()
Gets the name of the target printer.

return
The printer name.
hide

        return mPrinterName;
    
public intgetState()
Gets the current job state.

return
The job state.
see
#STATE_CREATED
see
#STATE_QUEUED
see
#STATE_STARTED
see
#STATE_COMPLETED
see
#STATE_BLOCKED
see
#STATE_FAILED
see
#STATE_CANCELED

        return mState;
    
public java.lang.StringgetStateReason()
Gets the reason for the print job being in the current state.

return
The reason, or null if there is no reason or the reason is unknown.
hide

        return mStateReason;
    
public java.lang.StringgetTag()
Gets the optional tag assigned by a print service.

return
The tag.
hide

        return mTag;
    
public booleanhasAdvancedOption(java.lang.String key)
Gets whether this job has a given advanced (printer specific) print option.

param
key The option key.
return
Whether the option is present.
hide

        return mAdvancedOptions != null && mAdvancedOptions.containsKey(key);
    
public booleanisCancelling()
Gets whether this print is being cancelled.

return
True if the print job is being cancelled.
hide

        return mCanceling;
    
public voidsetAdvancedOptions(android.os.Bundle options)
Sets the advanced options.

param
options The advanced options.
hide

        mAdvancedOptions = options;
    
public voidsetAppId(int appId)
Sets the owning application id.

param
appId The owning app id.
hide

        mAppId = appId;
    
public voidsetAttributes(PrintAttributes attributes)
Sets the print job attributes.

param
attributes The attributes.
hide

        mAttributes = attributes;
    
public voidsetCancelling(boolean cancelling)
Sets whether this print is being cancelled.

param
cancelling True if the print job is being cancelled.
hide

        mCanceling = cancelling;
    
public voidsetCopies(int copyCount)
Sets the number of copies.

param
copyCount The number of copies.
hide

        if (copyCount < 1) {
            throw new IllegalArgumentException("Copies must be more than one.");
        }
        mCopies = copyCount;
    
public voidsetCreationTime(long creationTime)
Sets the wall time in milliseconds when this print job was created.

param
creationTime The creation time in milliseconds.
hide

        if (creationTime < 0) {
            throw new IllegalArgumentException("creationTime must be non-negative.");
        }
        mCreationTime = creationTime;
    
public voidsetDocumentInfo(PrintDocumentInfo info)
Sets the info describing the printed document.

param
info The document info.
hide

        mDocumentInfo = info;
    
public voidsetId(PrintJobId id)
Sets the unique print job id.

param
The job id.
hide

        this.mId = id;
    
public voidsetLabel(java.lang.String label)
Sets the human readable job label.

param
label The label.
hide

        mLabel = label;
    
public voidsetPages(PageRange[] pageRanges)
Sets the included pages.

param
pageRanges The included pages.
hide

        mPageRanges = pageRanges;
    
public voidsetPrinterId(PrinterId printerId)
Sets the unique target pritner id.

param
printerId The target printer id.
hide

        mPrinterId = printerId;
    
public voidsetPrinterName(java.lang.String printerName)
Sets the name of the target printer.

param
printerName The printer name.
hide

        mPrinterName = printerName;
    
public voidsetState(int state)
Sets the current job state.

param
state The job state.
hide

        mState = state;
    
public voidsetStateReason(java.lang.String stateReason)
Sets the reason for the print job being in the current state.

param
stateReason The reason, or null if there is no reason or the reason is unknown.
hide

        mStateReason = stateReason;
    
public voidsetTag(java.lang.String tag)
Sets the optional tag assigned by a print service.

param
tag The tag.
hide

        mTag = tag;
    
public static java.lang.StringstateToString(int state)

hide

        switch (state) {
            case STATE_CREATED: {
                return "STATE_CREATED";
            }
            case STATE_QUEUED: {
                return "STATE_QUEUED";
            }
            case STATE_STARTED: {
                return "STATE_STARTED";
            }
            case STATE_BLOCKED: {
                return "STATE_BLOCKED";
            }
            case STATE_FAILED: {
                return "STATE_FAILED";
            }
            case STATE_COMPLETED: {
                return "STATE_COMPLETED";
            }
            case STATE_CANCELED: {
                return "STATE_CANCELED";
            }
            default: {
                return "STATE_UNKNOWN";
            }
        }
    
public java.lang.StringtoString()

        StringBuilder builder = new StringBuilder();
        builder.append("PrintJobInfo{");
        builder.append("label: ").append(mLabel);
        builder.append(", id: ").append(mId);
        builder.append(", state: ").append(stateToString(mState));
        builder.append(", printer: " + mPrinterId);
        builder.append(", tag: ").append(mTag);
        builder.append(", creationTime: " + mCreationTime);
        builder.append(", copies: ").append(mCopies);
        builder.append(", attributes: " + (mAttributes != null
                ? mAttributes.toString() : null));
        builder.append(", documentInfo: " + (mDocumentInfo != null
                ? mDocumentInfo.toString() : null));
        builder.append(", cancelling: " + mCanceling);
        builder.append(", pages: " + (mPageRanges != null
                ? Arrays.toString(mPageRanges) : null));
        builder.append(", hasAdvancedOptions: " + (mAdvancedOptions != null));
        builder.append("}");
        return builder.toString();
    
public voidwriteToParcel(android.os.Parcel parcel, int flags)

        parcel.writeParcelable(mId, flags);
        parcel.writeString(mLabel);
        parcel.writeParcelable(mPrinterId, flags);
        parcel.writeString(mPrinterName);
        parcel.writeInt(mState);
        parcel.writeInt(mAppId);
        parcel.writeString(mTag);
        parcel.writeLong(mCreationTime);
        parcel.writeInt(mCopies);
        parcel.writeString(mStateReason);
        parcel.writeParcelableArray(mPageRanges, flags);
        parcel.writeParcelable(mAttributes, flags);
        parcel.writeParcelable(mDocumentInfo, 0);
        parcel.writeInt(mCanceling ? 1 : 0);
        parcel.writeBundle(mAdvancedOptions);