jdk/src/share/classes/java/awt/JobAttributes.java
author sherman
Tue, 30 Aug 2011 11:53:11 -0700
changeset 10419 12c063b39232
parent 5506 202f599c92aa
child 23010 6dadb192ad81
permissions -rw-r--r--
7084245: Update usages of InternalError to use exception chaining Summary: to use new InternalError constructor with cause chainning Reviewed-by: alanb, ksrini, xuelei, neugens Contributed-by: sebastian.sickelmann@gmx.de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * A set of attributes which control a print job.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Instances of this class control the number of copies, default selection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * destination, print dialog, file and printer names, page ranges, multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * document handling (including collation), and multi-page imposition (such
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * as duplex) of every print job which uses the instance. Attribute names are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * compliant with the Internet Printing Protocol (IPP) 1.1 where possible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Attribute values are partially compliant where possible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * To use a method which takes an inner class type, pass a reference to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * one of the constant fields of the inner class. Client code cannot create
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * new instances of the inner class types because none of those classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * has a public constructor. For example, to set the print dialog type to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * the cross-platform, pure Java print dialog, use the following code:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * import java.awt.JobAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * public class PureJavaPrintDialogExample {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *     public void setPureJavaPrintDialog(JobAttributes jobAttributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *         jobAttributes.setDialog(JobAttributes.DialogType.COMMON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * Every IPP attribute which supports an <i>attributeName</i>-default value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * has a corresponding <code>set<i>attributeName</i>ToDefault</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * Default value fields are not provided.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @author      David Mendenhall
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
public final class JobAttributes implements Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * A type-safe enumeration of possible default selection states.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public static final class DefaultSelectionType extends AttributeValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        private static final int I_ALL = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        private static final int I_RANGE = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        private static final int I_SELECTION = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        private static final String NAMES[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            "all", "range", "selection"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
         * The <code>DefaultSelectionType</code> instance to use for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
         * specifying that all pages of the job should be printed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        public static final DefaultSelectionType ALL =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
           new DefaultSelectionType(I_ALL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
         * The <code>DefaultSelectionType</code> instance to use for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
         * specifying that a range of pages of the job should be printed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        public static final DefaultSelectionType RANGE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
           new DefaultSelectionType(I_RANGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
         * The <code>DefaultSelectionType</code> instance to use for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
         * specifying that the current selection should be printed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        public static final DefaultSelectionType SELECTION =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
           new DefaultSelectionType(I_SELECTION);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        private DefaultSelectionType(int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            super(type, NAMES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * A type-safe enumeration of possible job destinations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public static final class DestinationType extends AttributeValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        private static final int I_FILE = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        private static final int I_PRINTER = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        private static final String NAMES[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            "file", "printer"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
         * The <code>DestinationType</code> instance to use for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
         * specifying print to file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        public static final DestinationType FILE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            new DestinationType(I_FILE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
         * The <code>DestinationType</code> instance to use for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
         * specifying print to printer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        public static final DestinationType PRINTER =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            new DestinationType(I_PRINTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        private DestinationType(int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            super(type, NAMES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * A type-safe enumeration of possible dialogs to display to the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public static final class DialogType extends AttributeValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        private static final int I_COMMON = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        private static final int I_NATIVE = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        private static final int I_NONE = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        private static final String NAMES[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            "common", "native", "none"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
         * The <code>DialogType</code> instance to use for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
         * specifying the cross-platform, pure Java print dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        public static final DialogType COMMON = new DialogType(I_COMMON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
         * The <code>DialogType</code> instance to use for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
         * specifying the platform's native print dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        public static final DialogType NATIVE = new DialogType(I_NATIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
         * The <code>DialogType</code> instance to use for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
         * specifying no print dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        public static final DialogType NONE = new DialogType(I_NONE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        private DialogType(int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            super(type, NAMES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * A type-safe enumeration of possible multiple copy handling states.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * It is used to control how the sheets of multiple copies of a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * document are collated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    public static final class MultipleDocumentHandlingType extends
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                                               AttributeValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        private static final int I_SEPARATE_DOCUMENTS_COLLATED_COPIES = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        private static final int I_SEPARATE_DOCUMENTS_UNCOLLATED_COPIES = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        private static final String NAMES[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            "separate-documents-collated-copies",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            "separate-documents-uncollated-copies"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
         * The <code>MultipleDocumentHandlingType</code> instance to use for specifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
         * that the job should be divided into separate, collated copies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        public static final MultipleDocumentHandlingType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            SEPARATE_DOCUMENTS_COLLATED_COPIES =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                new MultipleDocumentHandlingType(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                    I_SEPARATE_DOCUMENTS_COLLATED_COPIES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
         * The <code>MultipleDocumentHandlingType</code> instance to use for specifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
         * that the job should be divided into separate, uncollated copies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        public static final MultipleDocumentHandlingType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            SEPARATE_DOCUMENTS_UNCOLLATED_COPIES =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                new MultipleDocumentHandlingType(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    I_SEPARATE_DOCUMENTS_UNCOLLATED_COPIES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        private MultipleDocumentHandlingType(int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            super(type, NAMES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * A type-safe enumeration of possible multi-page impositions. These
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * impositions are in compliance with IPP 1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public static final class SidesType extends AttributeValue {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        private static final int I_ONE_SIDED = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        private static final int I_TWO_SIDED_LONG_EDGE = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        private static final int I_TWO_SIDED_SHORT_EDGE = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        private static final String NAMES[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            "one-sided", "two-sided-long-edge", "two-sided-short-edge"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
         * The <code>SidesType</code> instance to use for specifying that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
         * consecutive job pages should be printed upon the same side of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
         * consecutive media sheets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        public static final SidesType ONE_SIDED = new SidesType(I_ONE_SIDED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
         * The <code>SidesType</code> instance to use for specifying that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
         * consecutive job pages should be printed upon front and back sides
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
         * of consecutive media sheets, such that the orientation of each pair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
         * of pages on the medium would be correct for the reader as if for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
         * binding on the long edge.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        public static final SidesType TWO_SIDED_LONG_EDGE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            new SidesType(I_TWO_SIDED_LONG_EDGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
         * The <code>SidesType</code> instance to use for specifying that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
         * consecutive job pages should be printed upon front and back sides
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
         * of consecutive media sheets, such that the orientation of each pair
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
         * of pages on the medium would be correct for the reader as if for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
         * binding on the short edge.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        public static final SidesType TWO_SIDED_SHORT_EDGE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            new SidesType(I_TWO_SIDED_SHORT_EDGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        private SidesType(int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            super(type, NAMES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    private int copies;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    private DefaultSelectionType defaultSelection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    private DestinationType destination;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    private DialogType dialog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    private String fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    private int fromPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    private int maxPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    private int minPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    private MultipleDocumentHandlingType multipleDocumentHandling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    private int[][] pageRanges;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    private int prFirst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    private int prLast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    private String printer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    private SidesType sides;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    private int toPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * Constructs a <code>JobAttributes</code> instance with default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * values for every attribute.  The dialog defaults to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * <code>DialogType.NATIVE</code>.  Min page defaults to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * <code>1</code>.  Max page defaults to <code>Integer.MAX_VALUE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Destination defaults to <code>DestinationType.PRINTER</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Selection defaults to <code>DefaultSelectionType.ALL</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * Number of copies defaults to <code>1</code>. Multiple document handling defaults
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * to <code>MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * Sides defaults to <code>SidesType.ONE_SIDED</code>. File name defaults
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * to <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public JobAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        setCopiesToDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        setDefaultSelection(DefaultSelectionType.ALL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        setDestination(DestinationType.PRINTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        setDialog(DialogType.NATIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        setMaxPage(Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        setMinPage(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        setMultipleDocumentHandlingToDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        setSidesToDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * Constructs a <code>JobAttributes</code> instance which is a copy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * of the supplied <code>JobAttributes</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @param   obj the <code>JobAttributes</code> to copy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    public JobAttributes(JobAttributes obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        set(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * Constructs a <code>JobAttributes</code> instance with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * specified values for every attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * @param   copies an integer greater than 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @param   defaultSelection <code>DefaultSelectionType.ALL</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *          <code>DefaultSelectionType.RANGE</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     *          <code>DefaultSelectionType.SELECTION</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @param   destination <code>DesintationType.FILE</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *          <code>DesintationType.PRINTER</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @param   dialog <code>DialogType.COMMON</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *          <code>DialogType.NATIVE</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *          <code>DialogType.NONE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @param   fileName the possibly <code>null</code> file name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param   maxPage an integer greater than zero and greater than or equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *          to <i>minPage</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @param   minPage an integer greater than zero and less than or equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     *          to <i>maxPage</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @param   multipleDocumentHandling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *     <code>MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     *     <code>MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @param   pageRanges an array of integer arrays of two elements; an array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     *          is interpreted as a range spanning all pages including and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *          between the specified pages; ranges must be in ascending
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *          order and must not overlap; specified page numbers cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *          less than <i>minPage</i> nor greater than <i>maxPage</i>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *          for example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     *          <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *          (new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *                         new int[] { 15, 19 } }),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *          </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *          specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19. Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     *          (<code>new int[][] { new int[] { 1, 1 }, new int[] { 1, 2 } }</code>),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *          is an invalid set of page ranges because the two ranges
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *          overlap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @param   printer the possibly <code>null</code> printer name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @param   sides <code>SidesType.ONE_SIDED</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *          <code>SidesType.TWO_SIDED_LONG_EDGE</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *          <code>SidesType.TWO_SIDED_SHORT_EDGE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @throws  IllegalArgumentException if one or more of the above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *          conditions is violated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    public JobAttributes(int copies, DefaultSelectionType defaultSelection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                         DestinationType destination, DialogType dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                         String fileName, int maxPage, int minPage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                         MultipleDocumentHandlingType multipleDocumentHandling,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                         int[][] pageRanges, String printer, SidesType sides) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        setCopies(copies);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        setDefaultSelection(defaultSelection);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        setDestination(destination);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        setDialog(dialog);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        setFileName(fileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        setMaxPage(maxPage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        setMinPage(minPage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        setMultipleDocumentHandling(multipleDocumentHandling);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        setPageRanges(pageRanges);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        setPrinter(printer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        setSides(sides);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * Creates and returns a copy of this <code>JobAttributes</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @return  the newly created copy; it is safe to cast this Object into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *          a <code>JobAttributes</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            return super.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        } catch (CloneNotSupportedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            // Since we implement Cloneable, this should never happen
10419
12c063b39232 7084245: Update usages of InternalError to use exception chaining
sherman
parents: 5506
diff changeset
   364
            throw new InternalError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * Sets all of the attributes of this <code>JobAttributes</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * the same values as the attributes of obj.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @param   obj the <code>JobAttributes</code> to copy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    public void set(JobAttributes obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        copies = obj.copies;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        defaultSelection = obj.defaultSelection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        destination = obj.destination;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        dialog = obj.dialog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        fileName = obj.fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        fromPage = obj.fromPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        maxPage = obj.maxPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        minPage = obj.minPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        multipleDocumentHandling = obj.multipleDocumentHandling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        // okay because we never modify the contents of pageRanges
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        pageRanges = obj.pageRanges;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        prFirst = obj.prFirst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        prLast = obj.prLast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        printer = obj.printer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        sides = obj.sides;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        toPage = obj.toPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * Returns the number of copies the application should render for jobs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * using these attributes. This attribute is updated to the value chosen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @return  an integer greater than 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    public int getCopies() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        return copies;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * Specifies the number of copies the application should render for jobs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * using these attributes. Not specifying this attribute is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * specifying <code>1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * @param   copies an integer greater than 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * @throws  IllegalArgumentException if <code>copies</code> is less than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *      or equal to 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    public void setCopies(int copies) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        if (copies <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                                               "copies");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        this.copies = copies;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * Sets the number of copies the application should render for jobs using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * these attributes to the default. The default number of copies is 1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    public void setCopiesToDefault() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        setCopies(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * Specifies whether, for jobs using these attributes, the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * should print all pages, the range specified by the return value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * <code>getPageRanges</code>, or the current selection. This attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * is updated to the value chosen by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @return  DefaultSelectionType.ALL, DefaultSelectionType.RANGE, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     *          DefaultSelectionType.SELECTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public DefaultSelectionType getDefaultSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        return defaultSelection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * Specifies whether, for jobs using these attributes, the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * should print all pages, the range specified by the return value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * <code>getPageRanges</code>, or the current selection. Not specifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * this attribute is equivalent to specifying DefaultSelectionType.ALL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * @param   defaultSelection DefaultSelectionType.ALL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     *          DefaultSelectionType.RANGE, or DefaultSelectionType.SELECTION.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * @throws  IllegalArgumentException if defaultSelection is <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    public void setDefaultSelection(DefaultSelectionType defaultSelection) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        if (defaultSelection == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                               "defaultSelection");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        this.defaultSelection = defaultSelection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * Specifies whether output will be to a printer or a file for jobs using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * these attributes. This attribute is updated to the value chosen by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @return  DesintationType.FILE or DesintationType.PRINTER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    public DestinationType getDestination() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        return destination;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * Specifies whether output will be to a printer or a file for jobs using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * these attributes. Not specifying this attribute is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * specifying DesintationType.PRINTER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * @param   destination DesintationType.FILE or DesintationType.PRINTER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * @throws  IllegalArgumentException if destination is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    public void setDestination(DestinationType destination) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        if (destination == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                                               "destination");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        this.destination = destination;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * Returns whether, for jobs using these attributes, the user should see
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * a print dialog in which to modify the print settings, and which type of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * print dialog should be displayed. DialogType.COMMON denotes a cross-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * platform, pure Java print dialog. DialogType.NATIVE denotes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * platform's native print dialog. If a platform does not support a native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * print dialog, the pure Java print dialog is displayed instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * DialogType.NONE specifies no print dialog (i.e., background printing).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * This attribute cannot be modified by, and is not subject to any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * limitations of, the implementation or the target printer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * @return  <code>DialogType.COMMON</code>, <code>DialogType.NATIVE</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     *          <code>DialogType.NONE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    public DialogType getDialog() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        return dialog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * Specifies whether, for jobs using these attributes, the user should see
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * a print dialog in which to modify the print settings, and which type of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * print dialog should be displayed. DialogType.COMMON denotes a cross-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * platform, pure Java print dialog. DialogType.NATIVE denotes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * platform's native print dialog. If a platform does not support a native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * print dialog, the pure Java print dialog is displayed instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * DialogType.NONE specifies no print dialog (i.e., background printing).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * Not specifying this attribute is equivalent to specifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * DialogType.NATIVE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @param   dialog DialogType.COMMON, DialogType.NATIVE, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     *          DialogType.NONE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @throws  IllegalArgumentException if dialog is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    public void setDialog(DialogType dialog) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        if (dialog == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                                               "dialog");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        this.dialog = dialog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * Specifies the file name for the output file for jobs using these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * attributes. This attribute is updated to the value chosen by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @return  the possibly <code>null</code> file name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    public String getFileName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        return fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * Specifies the file name for the output file for jobs using these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * attributes. Default is platform-dependent and implementation-defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * @param   fileName the possibly null file name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    public void setFileName(String fileName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        this.fileName = fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * Returns, for jobs using these attributes, the first page to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * printed, if a range of pages is to be printed. This attribute is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * updated to the value chosen by the user. An application should ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * this attribute on output, unless the return value of the <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * getDefaultSelection</code> method is DefaultSelectionType.RANGE. An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * application should honor the return value of <code>getPageRanges</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * over the return value of this method, if possible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @return  an integer greater than zero and less than or equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *          <i>toPage</i> and greater than or equal to <i>minPage</i> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *          less than or equal to <i>maxPage</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    public int getFromPage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        if (fromPage != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            return fromPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        } else if (toPage != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            return getMinPage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        } else if (pageRanges != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            return prFirst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            return getMinPage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * Specifies, for jobs using these attributes, the first page to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * printed, if a range of pages is to be printed. If this attribute is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * specified, then the values from the pageRanges attribute are used. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * pageRanges and either or both of fromPage and toPage are specified,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * pageRanges takes precedence. Specifying none of pageRanges, fromPage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * or toPage is equivalent to calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * setPageRanges(new int[][] { new int[] { <i>minPage</i> } });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * @param   fromPage an integer greater than zero and less than or equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     *          <i>toPage</i> and greater than or equal to <i>minPage</i> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     *          less than or equal to <i>maxPage</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * @throws  IllegalArgumentException if one or more of the above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     *          conditions is violated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    public void setFromPage(int fromPage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        if (fromPage <= 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            (toPage != 0 && fromPage > toPage) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            fromPage < minPage ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            fromPage > maxPage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                                               "fromPage");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        this.fromPage = fromPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * Specifies the maximum value the user can specify as the last page to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * be printed for jobs using these attributes. This attribute cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * modified by, and is not subject to any limitations of, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * implementation or the target printer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * @return  an integer greater than zero and greater than or equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     *          to <i>minPage</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    public int getMaxPage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        return maxPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * Specifies the maximum value the user can specify as the last page to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * be printed for jobs using these attributes. Not specifying this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * attribute is equivalent to specifying <code>Integer.MAX_VALUE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * @param   maxPage an integer greater than zero and greater than or equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     *          to <i>minPage</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * @throws  IllegalArgumentException if one or more of the above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     *          conditions is violated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    public void setMaxPage(int maxPage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        if (maxPage <= 0 || maxPage < minPage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                                               "maxPage");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        this.maxPage = maxPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * Specifies the minimum value the user can specify as the first page to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * be printed for jobs using these attributes. This attribute cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * modified by, and is not subject to any limitations of, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * implementation or the target printer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * @return  an integer greater than zero and less than or equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     *          to <i>maxPage</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    public int getMinPage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        return minPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * Specifies the minimum value the user can specify as the first page to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * be printed for jobs using these attributes. Not specifying this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * attribute is equivalent to specifying <code>1</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * @param   minPage an integer greater than zero and less than or equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     *          to <i>maxPage</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * @throws  IllegalArgumentException if one or more of the above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     *          conditions is violated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    public void setMinPage(int minPage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        if (minPage <= 0 || minPage > maxPage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                                               "minPage");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        this.minPage = minPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * Specifies the handling of multiple copies, including collation, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * jobs using these attributes. This attribute is updated to the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * chosen by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * @return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     *     MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     *     MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    public MultipleDocumentHandlingType getMultipleDocumentHandling() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        return multipleDocumentHandling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * Specifies the handling of multiple copies, including collation, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * jobs using these attributes. Not specifying this attribute is equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * to specifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * @param   multipleDocumentHandling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     *     MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     *     MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * @throws  IllegalArgumentException if multipleDocumentHandling is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    public void setMultipleDocumentHandling(MultipleDocumentHandlingType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                                            multipleDocumentHandling) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        if (multipleDocumentHandling == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                                               "multipleDocumentHandling");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        this.multipleDocumentHandling = multipleDocumentHandling;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     * Sets the handling of multiple copies, including collation, for jobs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * using these attributes to the default. The default handling is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    public void setMultipleDocumentHandlingToDefault() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        setMultipleDocumentHandling(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * Specifies, for jobs using these attributes, the ranges of pages to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * printed, if a range of pages is to be printed. All range numbers are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * inclusive. This attribute is updated to the value chosen by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * An application should ignore this attribute on output, unless the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * return value of the <code>getDefaultSelection</code> method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * DefaultSelectionType.RANGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * @return  an array of integer arrays of 2 elements. An array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     *          is interpreted as a range spanning all pages including and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     *          between the specified pages. Ranges must be in ascending
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     *          order and must not overlap. Specified page numbers cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     *          less than <i>minPage</i> nor greater than <i>maxPage</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     *          For example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     *          (new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     *                         new int[] { 15, 19 } }),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     *          specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    public int[][] getPageRanges() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        if (pageRanges != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
            // Return a copy because otherwise client code could circumvent the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            // the checks made in setPageRanges by modifying the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            // array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            int[][] copy = new int[pageRanges.length][2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            for (int i = 0; i < pageRanges.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                copy[i][0] = pageRanges[i][0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                copy[i][1] = pageRanges[i][1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            return copy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        } else if (fromPage != 0 || toPage != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            int fromPage = getFromPage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
            int toPage = getToPage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            return new int[][] { new int[] { fromPage, toPage } };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            int minPage = getMinPage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            return new int[][] { new int[] { minPage, minPage } };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * Specifies, for jobs using these attributes, the ranges of pages to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * printed, if a range of pages is to be printed. All range numbers are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * inclusive. If this attribute is not specified, then the values from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * fromPage and toPages attributes are used. If pageRanges and either or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * both of fromPage and toPage are specified, pageRanges takes precedence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * Specifying none of pageRanges, fromPage, or toPage is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * calling setPageRanges(new int[][] { new int[] { <i>minPage</i>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     *                                                 <i>minPage</i> } });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * @param   pageRanges an array of integer arrays of 2 elements. An array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     *          is interpreted as a range spanning all pages including and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     *          between the specified pages. Ranges must be in ascending
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     *          order and must not overlap. Specified page numbers cannot be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     *          less than <i>minPage</i> nor greater than <i>maxPage</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     *          For example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     *          (new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     *                         new int[] { 15, 19 } }),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     *          specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19. Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     *          (new int[][] { new int[] { 1, 1 }, new int[] { 1, 2 } }),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     *          is an invalid set of page ranges because the two ranges
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     *          overlap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * @throws  IllegalArgumentException if one or more of the above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     *          conditions is violated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    public void setPageRanges(int[][] pageRanges) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        String xcp = "Invalid value for attribute pageRanges";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        int first = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        int last = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        if (pageRanges == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
            throw new IllegalArgumentException(xcp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        for (int i = 0; i < pageRanges.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            if (pageRanges[i] == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                pageRanges[i].length != 2 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                pageRanges[i][0] <= last ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                pageRanges[i][1] < pageRanges[i][0]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                    throw new IllegalArgumentException(xcp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            last = pageRanges[i][1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
            if (first == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                first = pageRanges[i][0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        if (first < minPage || last > maxPage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            throw new IllegalArgumentException(xcp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        // Store a copy because otherwise client code could circumvent the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        // the checks made above by holding a reference to the array and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        // modifying it after calling setPageRanges.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        int[][] copy = new int[pageRanges.length][2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        for (int i = 0; i < pageRanges.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            copy[i][0] = pageRanges[i][0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            copy[i][1] = pageRanges[i][1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        this.pageRanges = copy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        this.prFirst = first;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        this.prLast = last;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * Returns the destination printer for jobs using these attributes. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * attribute is updated to the value chosen by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     * @return  the possibly null printer name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    public String getPrinter() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        return printer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * Specifies the destination printer for jobs using these attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * Default is platform-dependent and implementation-defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * @param   printer the possibly null printer name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    public void setPrinter(String printer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        this.printer = printer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * Returns how consecutive pages should be imposed upon the sides of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * print medium for jobs using these attributes. SidesType.ONE_SIDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * imposes each consecutive page upon the same side of consecutive media
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * sheets. This imposition is sometimes called <i>simplex</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * SidesType.TWO_SIDED_LONG_EDGE imposes each consecutive pair of pages
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * upon front and back sides of consecutive media sheets, such that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * orientation of each pair of pages on the medium would be correct for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     * the reader as if for binding on the long edge. This imposition is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * sometimes called <i>duplex</i>. SidesType.TWO_SIDED_SHORT_EDGE imposes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * each consecutive pair of pages upon front and back sides of consecutive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * media sheets, such that the orientation of each pair of pages on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * medium would be correct for the reader as if for binding on the short
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * edge. This imposition is sometimes called <i>tumble</i>. This attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * is updated to the value chosen by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * @return  SidesType.ONE_SIDED, SidesType.TWO_SIDED_LONG_EDGE, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     *          SidesType.TWO_SIDED_SHORT_EDGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    public SidesType getSides() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        return sides;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     * Specifies how consecutive pages should be imposed upon the sides of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     * print medium for jobs using these attributes. SidesType.ONE_SIDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * imposes each consecutive page upon the same side of consecutive media
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     * sheets. This imposition is sometimes called <i>simplex</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     * SidesType.TWO_SIDED_LONG_EDGE imposes each consecutive pair of pages
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     * upon front and back sides of consecutive media sheets, such that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
     * orientation of each pair of pages on the medium would be correct for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     * the reader as if for binding on the long edge. This imposition is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     * sometimes called <i>duplex</i>. SidesType.TWO_SIDED_SHORT_EDGE imposes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * each consecutive pair of pages upon front and back sides of consecutive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     * media sheets, such that the orientation of each pair of pages on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     * medium would be correct for the reader as if for binding on the short
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
     * edge. This imposition is sometimes called <i>tumble</i>. Not specifying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     * this attribute is equivalent to specifying SidesType.ONE_SIDED.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     * @param   sides SidesType.ONE_SIDED, SidesType.TWO_SIDED_LONG_EDGE, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     *          SidesType.TWO_SIDED_SHORT_EDGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * @throws  IllegalArgumentException if sides is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    public void setSides(SidesType sides) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        if (sides == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
                                               "sides");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        this.sides = sides;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * Sets how consecutive pages should be imposed upon the sides of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     * print medium for jobs using these attributes to the default. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     * default imposition is SidesType.ONE_SIDED.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    public void setSidesToDefault() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        setSides(SidesType.ONE_SIDED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * Returns, for jobs using these attributes, the last page (inclusive)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
     * to be printed, if a range of pages is to be printed. This attribute is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
     * updated to the value chosen by the user. An application should ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * this attribute on output, unless the return value of the <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * getDefaultSelection</code> method is DefaultSelectionType.RANGE. An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * application should honor the return value of <code>getPageRanges</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * over the return value of this method, if possible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * @return  an integer greater than zero and greater than or equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     *          to <i>toPage</i> and greater than or equal to <i>minPage</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     *          and less than or equal to <i>maxPage</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    public int getToPage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        if (toPage != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            return toPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        } else if (fromPage != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            return fromPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        } else if (pageRanges != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
            return prLast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            return getMinPage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * Specifies, for jobs using these attributes, the last page (inclusive)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     * to be printed, if a range of pages is to be printed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     * If this attribute is not specified, then the values from the pageRanges
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * attribute are used. If pageRanges and either or both of fromPage and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * toPage are specified, pageRanges takes precedence. Specifying none of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * pageRanges, fromPage, or toPage is equivalent to calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * setPageRanges(new int[][] { new int[] { <i>minPage</i> } });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * @param   toPage an integer greater than zero and greater than or equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     *          to <i>fromPage</i> and greater than or equal to <i>minPage</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     *          and less than or equal to <i>maxPage</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     * @throws  IllegalArgumentException if one or more of the above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     *          conditions is violated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
    public void setToPage(int toPage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        if (toPage <= 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            (fromPage != 0 && toPage < fromPage) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
            toPage < minPage ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            toPage > maxPage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            throw new IllegalArgumentException("Invalid value for attribute "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                                               "toPage");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        this.toPage = toPage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     * Determines whether two JobAttributes are equal to each other.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     * Two JobAttributes are equal if and only if each of their attributes are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     * equal. Attributes of enumeration type are equal if and only if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     * fields refer to the same unique enumeration object. A set of page
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     * ranges is equal if and only if the sets are of equal length, each range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     * enumerates the same pages, and the ranges are in the same order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     * @param   obj the object whose equality will be checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * @return  whether obj is equal to this JobAttribute according to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     *          above criteria.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        if (!(obj instanceof JobAttributes)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        JobAttributes rhs = (JobAttributes)obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        if (fileName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            if (rhs.fileName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
            if (!fileName.equals(rhs.fileName)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        if (pageRanges == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
            if (rhs.pageRanges != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            if (rhs.pageRanges == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                    pageRanges.length != rhs.pageRanges.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
            for (int i = 0; i < pageRanges.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                if (pageRanges[i][0] != rhs.pageRanges[i][0] ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                    pageRanges[i][1] != rhs.pageRanges[i][1]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
        if (printer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
            if (rhs.printer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
            if (!printer.equals(rhs.printer)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        return (copies == rhs.copies &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                defaultSelection == rhs.defaultSelection &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                destination == rhs.destination &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                dialog == rhs.dialog &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                fromPage == rhs.fromPage &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                maxPage == rhs.maxPage &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                minPage == rhs.minPage &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                multipleDocumentHandling == rhs.multipleDocumentHandling &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                prFirst == rhs.prFirst &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                prLast == rhs.prLast &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                sides == rhs.sides &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                toPage == rhs.toPage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * Returns a hash code value for this JobAttributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     * @return  the hash code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
        int rest = ((copies + fromPage + maxPage + minPage + prFirst + prLast +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                     toPage) * 31) << 21;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
        if (pageRanges != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
            int sum = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            for (int i = 0; i < pageRanges.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                sum += pageRanges[i][0] + pageRanges[i][1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            rest ^= (sum * 31) << 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
        if (fileName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            rest ^= fileName.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
        if (printer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            rest ^= printer.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
        return (defaultSelection.hashCode() << 6 ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                destination.hashCode() << 5 ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
                dialog.hashCode() << 3 ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
                multipleDocumentHandling.hashCode() << 2 ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
                sides.hashCode() ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                rest);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * Returns a string representation of this JobAttributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * @return  the string representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
        int[][] pageRanges = getPageRanges();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
        String prStr = "[";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        boolean first = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        for (int i = 0; i < pageRanges.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
            if (first) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
                first = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                prStr += ",";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
            prStr += pageRanges[i][0] + ":" + pageRanges[i][1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        prStr += "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        return "copies=" + getCopies() + ",defaultSelection=" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
            getDefaultSelection() + ",destination=" + getDestination() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            ",dialog=" + getDialog() + ",fileName=" + getFileName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
            ",fromPage=" + getFromPage() + ",maxPage=" + getMaxPage() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
            ",minPage=" + getMinPage() + ",multiple-document-handling=" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
            getMultipleDocumentHandling() + ",page-ranges=" + prStr +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
            ",printer=" + getPrinter() + ",sides=" + getSides() + ",toPage=" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
            getToPage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
}