A set of attributes which control a print job.

Instances of this class control the number of copies, default selection, destination, print dialog, file and printer names, page ranges, multiple document handling (including collation), and multi-page imposition (such as duplex) of every print job which uses the instance. Attribute names are compliant with the Internet Printing Protocol (IPP) 1.1 where possible. Attribute values are partially compliant where possible.

To use a method which takes an inner class type, pass a reference to one of the constant fields of the inner class. Client code cannot create new instances of the inner class types because none of those classes has a public constructor. For example, to set the print dialog type to the cross-platform, pure Java print dialog, use the following code:

 import java.awt.JobAttributes;

 public class PureJavaPrintDialogExample {
     public void setPureJavaPrintDialog(JobAttributes jobAttributes) {
         jobAttributes.setDialog(JobAttributes.DialogType.COMMON);
     }
 }
 

Every IPP attribute which supports an attributeName-default value has a corresponding setattributeNameToDefault method. Default value fields are not provided.

@version
1.9, 12/19/03
@author
David Mendenhall
Constructs a JobAttributes instance with default values for every attribute. The dialog defaults to DialogType.NATIVE. Min page defaults to 1. Max page defaults to Integer.MAX_VALUE. Destination defaults to DestinationType.PRINTER. Selection defaults to DefaultSelectionType.ALL. Number of copies defaults to 1. Multiple document handling defaults to MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES. Sides defaults to SidesType.ONE_SIDED. File name defaults to null.
Constructs a JobAttributes instance which is a copy of the supplied JobAttributes.
Parameters
objthe JobAttributes to copy
Constructs a JobAttributes instance with the specified values for every attribute.
Parameters
copiesan integer greater than 0
defaultSelectionDefaultSelectionType.ALL, DefaultSelectionType.RANGE, or DefaultSelectionType.SELECTION
destinationDesintationType.FILE or DesintationType.PRINTER
dialogDialogType.COMMON, DialogType.NATIVE, or DialogType.NONE
fileNamethe possibly null file name
maxPagean integer greater than zero and greater than or equal to minPage
minPagean integer greater than zero and less than or equal to maxPage
multipleDocumentHandling MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES or MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES
pageRangesan array of integer arrays of two elements; an array is interpreted as a range spanning all pages including and between the specified pages; ranges must be in ascending order and must not overlap; specified page numbers cannot be less than minPage nor greater than maxPage; for example:
		(new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 },
		               new int[] { 15, 19 } }),
          
specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19. Note that (new int[][] { new int[] { 1, 1 }, new int[] { 1, 2 } }), is an invalid set of page ranges because the two ranges overlap
printerthe possibly null printer name
sidesSidesType.ONE_SIDED, SidesType.TWO_SIDED_LONG_EDGE, or SidesType.TWO_SIDED_SHORT_EDGE
Throws
IllegalArgumentExceptionif one or more of the above conditions is violated
Creates and returns a copy of this JobAttributes.
Return
the newly created copy; it is safe to cast this Object into a JobAttributes
Determines whether two JobAttributes are equal to each other.

Two JobAttributes are equal if and only if each of their attributes are equal. Attributes of enumeration type are equal if and only if the fields refer to the same unique enumeration object. A set of page ranges is equal if and only if the sets are of equal length, each range enumerates the same pages, and the ranges are in the same order.

Parameters
objthe object whose equality will be checked.
Return
whether obj is equal to this JobAttribute according to the above criteria.
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
Returns the number of copies the application should render for jobs using these attributes. This attribute is updated to the value chosen by the user.
Return
an integer greater than 0.
Specifies whether, for jobs using these attributes, the application should print all pages, the range specified by the return value of getPageRanges, or the current selection. This attribute is updated to the value chosen by the user.
Return
DefaultSelectionType.ALL, DefaultSelectionType.RANGE, or DefaultSelectionType.SELECTION
Specifies whether output will be to a printer or a file for jobs using these attributes. This attribute is updated to the value chosen by the user.
Return
DesintationType.FILE or DesintationType.PRINTER
Returns whether, for jobs using these attributes, the user should see a print dialog in which to modify the print settings, and which type of print dialog should be displayed. DialogType.COMMON denotes a cross- platform, pure Java print dialog. DialogType.NATIVE denotes the platform's native print dialog. If a platform does not support a native print dialog, the pure Java print dialog is displayed instead. DialogType.NONE specifies no print dialog (i.e., background printing). This attribute cannot be modified by, and is not subject to any limitations of, the implementation or the target printer.
Return
DialogType.COMMON, DialogType.NATIVE, or DialogType.NONE
Specifies the file name for the output file for jobs using these attributes. This attribute is updated to the value chosen by the user.
Return
the possibly null file name
Returns, for jobs using these attributes, the first page to be printed, if a range of pages is to be printed. This attribute is updated to the value chosen by the user. An application should ignore this attribute on output, unless the return value of the getDefaultSelection method is DefaultSelectionType.RANGE. An application should honor the return value of getPageRanges over the return value of this method, if possible.
Return
an integer greater than zero and less than or equal to toPage and greater than or equal to minPage and less than or equal to maxPage.
Specifies the maximum value the user can specify as the last page to be printed for jobs using these attributes. This attribute cannot be modified by, and is not subject to any limitations of, the implementation or the target printer.
Return
an integer greater than zero and greater than or equal to minPage.
Specifies the minimum value the user can specify as the first page to be printed for jobs using these attributes. This attribute cannot be modified by, and is not subject to any limitations of, the implementation or the target printer.
Return
an integer greater than zero and less than or equal to maxPage.
Specifies the handling of multiple copies, including collation, for jobs using these attributes. This attribute is updated to the value chosen by the user.
Return
MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES or MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES.
Specifies, for jobs using these attributes, the ranges of pages to be printed, if a range of pages is to be printed. All range numbers are inclusive. This attribute is updated to the value chosen by the user. An application should ignore this attribute on output, unless the return value of the getDefaultSelection method is DefaultSelectionType.RANGE.
Return
an array of integer arrays of 2 elements. An array is interpreted as a range spanning all pages including and between the specified pages. Ranges must be in ascending order and must not overlap. Specified page numbers cannot be less than minPage nor greater than maxPage. For example: (new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 }, new int[] { 15, 19 } }), specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19.
Returns the destination printer for jobs using these attributes. This attribute is updated to the value chosen by the user.
Return
the possibly null printer name.
Returns how consecutive pages should be imposed upon the sides of the print medium for jobs using these attributes. SidesType.ONE_SIDED imposes each consecutive page upon the same side of consecutive media sheets. This imposition is sometimes called simplex. SidesType.TWO_SIDED_LONG_EDGE imposes each consecutive pair of pages upon front and back sides of consecutive media sheets, such that the orientation of each pair of pages on the medium would be correct for the reader as if for binding on the long edge. This imposition is sometimes called duplex. SidesType.TWO_SIDED_SHORT_EDGE imposes each consecutive pair of pages upon front and back sides of consecutive media sheets, such that the orientation of each pair of pages on the medium would be correct for the reader as if for binding on the short edge. This imposition is sometimes called tumble. This attribute is updated to the value chosen by the user.
Return
SidesType.ONE_SIDED, SidesType.TWO_SIDED_LONG_EDGE, or SidesType.TWO_SIDED_SHORT_EDGE.
Returns, for jobs using these attributes, the last page (inclusive) to be printed, if a range of pages is to be printed. This attribute is updated to the value chosen by the user. An application should ignore this attribute on output, unless the return value of the getDefaultSelection method is DefaultSelectionType.RANGE. An application should honor the return value of getPageRanges over the return value of this method, if possible.
Return
an integer greater than zero and greater than or equal to toPage and greater than or equal to minPage and less than or equal to maxPage.
Returns a hash code value for this JobAttributes.
Return
the hash code.
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Sets all of the attributes of this JobAttributes to the same values as the attributes of obj.
Parameters
objthe JobAttributes to copy
Specifies the number of copies the application should render for jobs using these attributes. Not specifying this attribute is equivalent to specifying 1.
Parameters
copiesan integer greater than 0
Throws
IllegalArgumentExceptionif copies is less than or equal to 0
Sets the number of copies the application should render for jobs using these attributes to the default. The default number of copies is 1.
Specifies whether, for jobs using these attributes, the application should print all pages, the range specified by the return value of getPageRanges, or the current selection. Not specifying this attribute is equivalent to specifying DefaultSelectionType.ALL.
Parameters
defaultSelectionDefaultSelectionType.ALL, DefaultSelectionType.RANGE, or DefaultSelectionType.SELECTION.
Throws
IllegalArgumentExceptionif defaultSelection is null
Specifies whether output will be to a printer or a file for jobs using these attributes. Not specifying this attribute is equivalent to specifying DesintationType.PRINTER.
Parameters
destinationDesintationType.FILE or DesintationType.PRINTER.
Throws
IllegalArgumentExceptionif destination is null.
Specifies whether, for jobs using these attributes, the user should see a print dialog in which to modify the print settings, and which type of print dialog should be displayed. DialogType.COMMON denotes a cross- platform, pure Java print dialog. DialogType.NATIVE denotes the platform's native print dialog. If a platform does not support a native print dialog, the pure Java print dialog is displayed instead. DialogType.NONE specifies no print dialog (i.e., background printing). Not specifying this attribute is equivalent to specifying DialogType.NATIVE.
Parameters
dialogDialogType.COMMON, DialogType.NATIVE, or DialogType.NONE.
Throws
IllegalArgumentExceptionif dialog is null.
Specifies the file name for the output file for jobs using these attributes. Default is platform-dependent and implementation-defined.
Parameters
fileNamethe possibly null file name.
Specifies, for jobs using these attributes, the first page to be printed, if a range of pages is to be printed. If this attribute is not specified, then the values from the pageRanges attribute are used. If pageRanges and either or both of fromPage and toPage are specified, pageRanges takes precedence. Specifying none of pageRanges, fromPage, or toPage is equivalent to calling setPageRanges(new int[][] { new int[] { minPage } });
Parameters
fromPagean integer greater than zero and less than or equal to toPage and greater than or equal to minPage and less than or equal to maxPage.
Throws
IllegalArgumentExceptionif one or more of the above conditions is violated.
Specifies the maximum value the user can specify as the last page to be printed for jobs using these attributes. Not specifying this attribute is equivalent to specifying Integer.MAX_VALUE.
Parameters
maxPagean integer greater than zero and greater than or equal to minPage
Throws
IllegalArgumentExceptionif one or more of the above conditions is violated
Specifies the minimum value the user can specify as the first page to be printed for jobs using these attributes. Not specifying this attribute is equivalent to specifying 1.
Parameters
minPagean integer greater than zero and less than or equal to maxPage.
Throws
IllegalArgumentExceptionif one or more of the above conditions is violated.
Specifies the handling of multiple copies, including collation, for jobs using these attributes. Not specifying this attribute is equivalent to specifying MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES.
Parameters
multipleDocumentHandling MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES or MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES.
Throws
IllegalArgumentExceptionif multipleDocumentHandling is null.
Sets the handling of multiple copies, including collation, for jobs using these attributes to the default. The default handling is MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES.
Specifies, for jobs using these attributes, the ranges of pages to be printed, if a range of pages is to be printed. All range numbers are inclusive. If this attribute is not specified, then the values from the fromPage and toPages attributes are used. If pageRanges and either or both of fromPage and toPage are specified, pageRanges takes precedence. Specifying none of pageRanges, fromPage, or toPage is equivalent to calling setPageRanges(new int[][] { new int[] { minPage, minPage } });
Parameters
pageRangesan array of integer arrays of 2 elements. An array is interpreted as a range spanning all pages including and between the specified pages. Ranges must be in ascending order and must not overlap. Specified page numbers cannot be less than minPage nor greater than maxPage. For example: (new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 }, new int[] { 15, 19 } }), specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19. Note that (new int[][] { new int[] { 1, 1 }, new int[] { 1, 2 } }), is an invalid set of page ranges because the two ranges overlap.
Throws
IllegalArgumentExceptionif one or more of the above conditions is violated.
Specifies the destination printer for jobs using these attributes. Default is platform-dependent and implementation-defined.
Parameters
printerthe possibly null printer name.
Specifies how consecutive pages should be imposed upon the sides of the print medium for jobs using these attributes. SidesType.ONE_SIDED imposes each consecutive page upon the same side of consecutive media sheets. This imposition is sometimes called simplex. SidesType.TWO_SIDED_LONG_EDGE imposes each consecutive pair of pages upon front and back sides of consecutive media sheets, such that the orientation of each pair of pages on the medium would be correct for the reader as if for binding on the long edge. This imposition is sometimes called duplex. SidesType.TWO_SIDED_SHORT_EDGE imposes each consecutive pair of pages upon front and back sides of consecutive media sheets, such that the orientation of each pair of pages on the medium would be correct for the reader as if for binding on the short edge. This imposition is sometimes called tumble. Not specifying this attribute is equivalent to specifying SidesType.ONE_SIDED.
Parameters
sidesSidesType.ONE_SIDED, SidesType.TWO_SIDED_LONG_EDGE, or SidesType.TWO_SIDED_SHORT_EDGE.
Throws
IllegalArgumentExceptionif sides is null.
Sets how consecutive pages should be imposed upon the sides of the print medium for jobs using these attributes to the default. The default imposition is SidesType.ONE_SIDED.
Specifies, for jobs using these attributes, the last page (inclusive) to be printed, if a range of pages is to be printed. If this attribute is not specified, then the values from the pageRanges attribute are used. If pageRanges and either or both of fromPage and toPage are specified, pageRanges takes precedence. Specifying none of pageRanges, fromPage, or toPage is equivalent to calling setPageRanges(new int[][] { new int[] { minPage } });
Parameters
toPagean integer greater than zero and greater than or equal to fromPage and greater than or equal to minPage and less than or equal to maxPage.
Throws
IllegalArgumentExceptionif one or more of the above conditions is violated.
Returns a string representation of this JobAttributes.
Return
the string representation.
Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait();
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Throws
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

  • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
  • Some other thread invokes the notifyAll method for this object.
  • Some other thread interrupts thread T.
  • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout);
         ... // Perform action appropriate to condition
     }
 
(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Parameters
timeoutthe maximum time to wait in milliseconds.
Throws
IllegalArgumentExceptionif the value of timeout is negative.
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

 1000000*timeout+nanos

In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

  • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
  • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout, nanos);
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Parameters
timeoutthe maximum time to wait in milliseconds.
nanosadditional time, in nanoseconds range 0-999999.
Throws
IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.