- All Implemented Interfaces:
- Cloneable
public final class JobAttributes extends Object implements Cloneable
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.
- Since:
- 1.3
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classJobAttributes.DefaultSelectionTypeA type-safe enumeration of possible default selection states.static classJobAttributes.DestinationTypeA type-safe enumeration of possible job destinations.static classJobAttributes.DialogTypeA type-safe enumeration of possible dialogs to display to the user.static classJobAttributes.MultipleDocumentHandlingTypeA type-safe enumeration of possible multiple copy handling states.static classJobAttributes.SidesTypeA type-safe enumeration of possible multi-page impositions.
- 
Constructor SummaryConstructors Constructor Description JobAttributes()Constructs aJobAttributesinstance with default values for every attribute.JobAttributes(int copies, JobAttributes.DefaultSelectionType defaultSelection, JobAttributes.DestinationType destination, JobAttributes.DialogType dialog, String fileName, int maxPage, int minPage, JobAttributes.MultipleDocumentHandlingType multipleDocumentHandling, int[][] pageRanges, String printer, JobAttributes.SidesType sides)Constructs aJobAttributesinstance with the specified values for every attribute.JobAttributes(JobAttributes obj)Constructs aJobAttributesinstance which is a copy of the suppliedJobAttributes.
- 
Method SummaryModifier and Type Method Description Objectclone()Creates and returns a copy of thisJobAttributes.booleanequals(Object obj)Determines whether two JobAttributes are equal to each other.intgetCopies()Returns the number of copies the application should render for jobs using these attributes.JobAttributes.DefaultSelectionTypegetDefaultSelection()Specifies whether, for jobs using these attributes, the application should print all pages, the range specified by the return value ofgetPageRanges, or the current selection.JobAttributes.DestinationTypegetDestination()Specifies whether output will be to a printer or a file for jobs using these attributes.JobAttributes.DialogTypegetDialog()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.StringgetFileName()Specifies the file name for the output file for jobs using these attributes.intgetFromPage()Returns, for jobs using these attributes, the first page to be printed, if a range of pages is to be printed.intgetMaxPage()Specifies the maximum value the user can specify as the last page to be printed for jobs using these attributes.intgetMinPage()Specifies the minimum value the user can specify as the first page to be printed for jobs using these attributes.JobAttributes.MultipleDocumentHandlingTypegetMultipleDocumentHandling()Specifies the handling of multiple copies, including collation, for jobs using these attributes.int[][]getPageRanges()Specifies, for jobs using these attributes, the ranges of pages to be printed, if a range of pages is to be printed.StringgetPrinter()Returns the destination printer for jobs using these attributes.JobAttributes.SidesTypegetSides()Returns how consecutive pages should be imposed upon the sides of the print medium for jobs using these attributes.intgetToPage()Returns, for jobs using these attributes, the last page (inclusive) to be printed, if a range of pages is to be printed.inthashCode()Returns a hash code value for this JobAttributes.voidset(JobAttributes obj)Sets all of the attributes of thisJobAttributesto the same values as the attributes of obj.voidsetCopies(int copies)Specifies the number of copies the application should render for jobs using these attributes.voidsetCopiesToDefault()Sets the number of copies the application should render for jobs using these attributes to the default.voidsetDefaultSelection(JobAttributes.DefaultSelectionType defaultSelection)Specifies whether, for jobs using these attributes, the application should print all pages, the range specified by the return value ofgetPageRanges, or the current selection.voidsetDestination(JobAttributes.DestinationType destination)Specifies whether output will be to a printer or a file for jobs using these attributes.voidsetDialog(JobAttributes.DialogType dialog)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.voidsetFileName(String fileName)Specifies the file name for the output file for jobs using these attributes.voidsetFromPage(int fromPage)Specifies, for jobs using these attributes, the first page to be printed, if a range of pages is to be printed.voidsetMaxPage(int maxPage)Specifies the maximum value the user can specify as the last page to be printed for jobs using these attributes.voidsetMinPage(int minPage)Specifies the minimum value the user can specify as the first page to be printed for jobs using these attributes.voidsetMultipleDocumentHandling(JobAttributes.MultipleDocumentHandlingType multipleDocumentHandling)Specifies the handling of multiple copies, including collation, for jobs using these attributes.voidsetMultipleDocumentHandlingToDefault()Sets the handling of multiple copies, including collation, for jobs using these attributes to the default.voidsetPageRanges(int[][] pageRanges)Specifies, for jobs using these attributes, the ranges of pages to be printed, if a range of pages is to be printed.voidsetPrinter(String printer)Specifies the destination printer for jobs using these attributes.voidsetSides(JobAttributes.SidesType sides)Specifies how consecutive pages should be imposed upon the sides of the print medium for jobs using these attributes.voidsetSidesToDefault()Sets how consecutive pages should be imposed upon the sides of the print medium for jobs using these attributes to the default.voidsetToPage(int toPage)Specifies, for jobs using these attributes, the last page (inclusive) to be printed, if a range of pages is to be printed.StringtoString()Returns a string representation of this JobAttributes.
- 
Constructor Details- 
JobAttributespublic JobAttributes()Constructs aJobAttributesinstance with default values for every attribute. The dialog defaults toDialogType.NATIVE. Min page defaults to1. Max page defaults toInteger.MAX_VALUE. Destination defaults toDestinationType.PRINTER. Selection defaults toDefaultSelectionType.ALL. Number of copies defaults to1. Multiple document handling defaults toMultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES. Sides defaults toSidesType.ONE_SIDED. File name defaults tonull.
- 
JobAttributesConstructs aJobAttributesinstance which is a copy of the suppliedJobAttributes.- Parameters:
- obj- the- JobAttributesto copy
 
- 
JobAttributespublic JobAttributes(int copies, JobAttributes.DefaultSelectionType defaultSelection, JobAttributes.DestinationType destination, JobAttributes.DialogType dialog, String fileName, int maxPage, int minPage, JobAttributes.MultipleDocumentHandlingType multipleDocumentHandling, int[][] pageRanges, String printer, JobAttributes.SidesType sides)Constructs aJobAttributesinstance with the specified values for every attribute.- Parameters:
- copies- an integer greater than 0
- defaultSelection-- DefaultSelectionType.ALL,- DefaultSelectionType.RANGE, or- DefaultSelectionType.SELECTION
- destination-- DestinationType.FILEor- DestinationType.PRINTER
- dialog-- DialogType.COMMON,- DialogType.NATIVE, or- DialogType.NONE
- fileName- the possibly- nullfile name
- maxPage- an integer greater than zero and greater than or equal to minPage
- minPage- an integer greater than zero and less than or equal to maxPage
- multipleDocumentHandling-- MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIESor- MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES
- pageRanges- an 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
- printer- the possibly- nullprinter name
- sides-- SidesType.ONE_SIDED,- SidesType.TWO_SIDED_LONG_EDGE, or- SidesType.TWO_SIDED_SHORT_EDGE
- Throws:
- IllegalArgumentException- if one or more of the above conditions is violated
 
 
- 
- 
Method Details- 
cloneCreates and returns a copy of thisJobAttributes.
- 
setSets all of the attributes of thisJobAttributesto the same values as the attributes of obj.- Parameters:
- obj- the- JobAttributesto copy
 
- 
getCopiespublic int getCopies()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.- Returns:
- an integer greater than 0.
 
- 
setCopiespublic void setCopies(int copies)Specifies the number of copies the application should render for jobs using these attributes. Not specifying this attribute is equivalent to specifying1.- Parameters:
- copies- an integer greater than 0
- Throws:
- IllegalArgumentException- if- copiesis less than or equal to 0
 
- 
setCopiesToDefaultpublic void setCopiesToDefault()Sets the number of copies the application should render for jobs using these attributes to the default. The default number of copies is 1.
- 
getDefaultSelectionSpecifies whether, for jobs using these attributes, the application should print all pages, the range specified by the return value ofgetPageRanges, or the current selection. This attribute is updated to the value chosen by the user.- Returns:
- DefaultSelectionType.ALL, DefaultSelectionType.RANGE, or DefaultSelectionType.SELECTION
 
- 
setDefaultSelectionSpecifies whether, for jobs using these attributes, the application should print all pages, the range specified by the return value ofgetPageRanges, or the current selection. Not specifying this attribute is equivalent to specifying DefaultSelectionType.ALL.- Parameters:
- defaultSelection- DefaultSelectionType.ALL, DefaultSelectionType.RANGE, or DefaultSelectionType.SELECTION.
- Throws:
- IllegalArgumentException- if defaultSelection is- null
 
- 
getDestinationSpecifies 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.- Returns:
- DestinationType.FILE or DestinationType.PRINTER
 
- 
setDestinationSpecifies whether output will be to a printer or a file for jobs using these attributes. Not specifying this attribute is equivalent to specifying DestinationType.PRINTER.- Parameters:
- destination- DestinationType.FILE or DestinationType.PRINTER.
- Throws:
- IllegalArgumentException- if destination is null.
 
- 
getDialogReturns 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.- Returns:
- DialogType.COMMON,- DialogType.NATIVE, or- DialogType.NONE
 
- 
setDialogSpecifies 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:
- dialog- DialogType.COMMON, DialogType.NATIVE, or DialogType.NONE.
- Throws:
- IllegalArgumentException- if dialog is null.
 
- 
getFileNameSpecifies the file name for the output file for jobs using these attributes. This attribute is updated to the value chosen by the user.- Returns:
- the possibly nullfile name
 
- 
setFileNameSpecifies the file name for the output file for jobs using these attributes. Default is platform-dependent and implementation-defined.- Parameters:
- fileName- the possibly null file name.
 
- 
getFromPagepublic int getFromPage()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 thegetDefaultSelectionmethod is DefaultSelectionType.RANGE. An application should honor the return value ofgetPageRangesover the return value of this method, if possible.- Returns:
- 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.
 
- 
setFromPagepublic void setFromPage(int fromPage)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:
- fromPage- 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.
- Throws:
- IllegalArgumentException- if one or more of the above conditions is violated.
 
- 
getMaxPagepublic int getMaxPage()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.- Returns:
- an integer greater than zero and greater than or equal to minPage.
 
- 
setMaxPagepublic void setMaxPage(int maxPage)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 specifyingInteger.MAX_VALUE.- Parameters:
- maxPage- an integer greater than zero and greater than or equal to minPage
- Throws:
- IllegalArgumentException- if one or more of the above conditions is violated
 
- 
getMinPagepublic int getMinPage()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.- Returns:
- an integer greater than zero and less than or equal to maxPage.
 
- 
setMinPagepublic void setMinPage(int minPage)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 specifying1.- Parameters:
- minPage- an integer greater than zero and less than or equal to maxPage.
- Throws:
- IllegalArgumentException- if one or more of the above conditions is violated.
 
- 
getMultipleDocumentHandlingSpecifies the handling of multiple copies, including collation, for jobs using these attributes. This attribute is updated to the value chosen by the user.- Returns:
- MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES or MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES.
 
- 
setMultipleDocumentHandlingpublic void setMultipleDocumentHandling(JobAttributes.MultipleDocumentHandlingType multipleDocumentHandling)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:
- IllegalArgumentException- if multipleDocumentHandling is null.
 
- 
setMultipleDocumentHandlingToDefaultpublic void setMultipleDocumentHandlingToDefault()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.
- 
getPageRangespublic int[][] getPageRanges()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 thegetDefaultSelectionmethod is DefaultSelectionType.RANGE.- Returns:
- 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.
 
- 
setPageRangespublic void setPageRanges(int[][] pageRanges)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:
- pageRanges- 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. 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:
- IllegalArgumentException- if one or more of the above conditions is violated.
 
- 
getPrinterReturns the destination printer for jobs using these attributes. This attribute is updated to the value chosen by the user.- Returns:
- the possibly null printer name.
 
- 
setPrinterSpecifies the destination printer for jobs using these attributes. Default is platform-dependent and implementation-defined.- Parameters:
- printer- the possibly null printer name.
 
- 
getSidesReturns 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.- Returns:
- SidesType.ONE_SIDED, SidesType.TWO_SIDED_LONG_EDGE, or SidesType.TWO_SIDED_SHORT_EDGE.
 
- 
setSidesSpecifies 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:
- sides- SidesType.ONE_SIDED, SidesType.TWO_SIDED_LONG_EDGE, or SidesType.TWO_SIDED_SHORT_EDGE.
- Throws:
- IllegalArgumentException- if sides is null.
 
- 
setSidesToDefaultpublic void setSidesToDefault()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.
- 
getToPagepublic int getToPage()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 thegetDefaultSelectionmethod is DefaultSelectionType.RANGE. An application should honor the return value ofgetPageRangesover the return value of this method, if possible.- Returns:
- 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.
 
- 
setToPagepublic void setToPage(int toPage)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:
- toPage- an 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:
- IllegalArgumentException- if one or more of the above conditions is violated.
 
- 
equalsDetermines 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. - Overrides:
- equalsin class- Object
- Parameters:
- obj- the object whose equality will be checked.
- Returns:
- whether obj is equal to this JobAttribute according to the above criteria.
- See Also:
- Object.hashCode(),- HashMap
 
- 
hashCodepublic int hashCode()Returns a hash code value for this JobAttributes.- Overrides:
- hashCodein class- Object
- Returns:
- the hash code.
- See Also:
- Object.equals(java.lang.Object),- System.identityHashCode(java.lang.Object)
 
- 
toStringReturns a string representation of this JobAttributes.
 
-