jdk/test/java/awt/print/PrinterJob/DummyPrintTest.java
author psadhukhan
Fri, 15 Apr 2016 11:45:11 +0530
changeset 37690 0e619f348ff7
permissions -rw-r--r--
6921664: The number of copies and the job name are not passed to a 3rd party PrintService Reviewed-by: prr, jdv
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37690
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     1
/*
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     4
 *
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     8
 *
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    13
 * accompanied this code).
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    14
 *
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    18
 *
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    21
 * questions.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    22
 */
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    23
/*
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    24
 * @test
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    25
 * @bug      6921664
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    26
 * @summary  Verifies number of copies and the job name are passed to a
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    27
 *           3rd party PrintService.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    28
 * @run      main DummyPrintTest
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    29
 */
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    30
import java.awt.Graphics;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    31
import java.awt.print.PageFormat;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    32
import java.awt.print.Printable;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    33
import java.awt.print.PrinterException;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    34
import java.awt.print.PrinterJob;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    35
import java.util.HashSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    36
import java.util.Set;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    37
import javax.print.Doc;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    38
import javax.print.DocFlavor;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    39
import javax.print.DocPrintJob;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    40
import javax.print.PrintException;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    41
import javax.print.PrintService;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    42
import javax.print.PrintServiceLookup;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    43
import javax.print.ServiceUIFactory;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    44
import javax.print.attribute.Attribute;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    45
import javax.print.attribute.AttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    46
import javax.print.attribute.HashPrintJobAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    47
import javax.print.attribute.HashPrintServiceAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    48
import javax.print.attribute.PrintJobAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    49
import javax.print.attribute.PrintRequestAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    50
import javax.print.attribute.PrintServiceAttribute;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    51
import javax.print.attribute.PrintServiceAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    52
import javax.print.attribute.standard.Copies;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    53
import javax.print.attribute.standard.JobName;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    54
import javax.print.attribute.standard.PrinterName;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    55
import javax.print.attribute.standard.PrinterState;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    56
import javax.print.event.PrintJobAttributeListener;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    57
import javax.print.event.PrintJobListener;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    58
import javax.print.event.PrintServiceAttributeListener;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    59
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    60
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    61
public class DummyPrintTest {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    62
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    63
    public static void main(String[] args) throws Exception {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    64
        // register custom print service implementation
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    65
        String printerName = "myDummyPrintService";
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    66
        PrintServiceLookup.registerService(new DummyPrintService(printerName));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    67
        // calling third party print logic
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    68
        thirdPartyPrintLogic(printerName);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    69
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    70
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    71
    static void thirdPartyPrintLogic(String printerName) throws Exception {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    72
        PrinterJob printerjob = PrinterJob.getPrinterJob();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    73
        printerjob.setCopies(2);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    74
        printerjob.setJobName("myJobName");
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    75
        printerjob.setPrintable(new DummyPrintable());
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    76
        for (PrintService printService : PrinterJob.lookupPrintServices()) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    77
            System.out.println("check printer name of service " + printService);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    78
            if (printerName.equals(printService.getName())) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    79
                System.out.println("correct printer service do print...");
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    80
                printerjob.setPrintService(printService);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    81
                printerjob.print();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    82
                break;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    83
            }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    84
        }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    85
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    86
}
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    87
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    88
class DummyPrintService implements PrintService {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    89
    private final String _name;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    90
    private final Set<DocFlavor> _supportedFlavors;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    91
    private final PrintServiceAttributeSet _printServiceAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    92
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    93
    public DummyPrintService(String name) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    94
        _name = name;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    95
        _supportedFlavors = new HashSet<DocFlavor>();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    96
        _supportedFlavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    97
        _supportedFlavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    98
        _printServiceAttributeSet = new HashPrintServiceAttributeSet();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    99
        _printServiceAttributeSet.add(new PrinterName(name, null));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   100
        _printServiceAttributeSet.add(PrinterState.IDLE);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   101
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   102
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   103
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   104
    public String toString() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   105
        return "Dummy Printer : " + getName();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   106
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   107
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   108
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   109
    public String getName() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   110
        return _name;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   111
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   112
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   113
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   114
    public DocPrintJob createPrintJob() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   115
        return new DummyDocPrintJob(this);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   116
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   117
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   118
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   119
    public boolean isDocFlavorSupported(DocFlavor flavor) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   120
        return _supportedFlavors.contains(flavor);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   121
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   122
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   123
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   124
    public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   125
        return category.cast(_printServiceAttributeSet.get(category));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   126
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   127
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   128
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   129
    public PrintServiceAttributeSet getAttributes() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   130
        return _printServiceAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   131
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   132
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   133
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   134
    public DocFlavor[] getSupportedDocFlavors() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   135
        return _supportedFlavors.toArray(new DocFlavor[_supportedFlavors.size()]);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   136
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   137
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   138
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   139
    public Object getDefaultAttributeValue(Class<? extends Attribute> category) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   140
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   141
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   142
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   143
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   144
    public ServiceUIFactory getServiceUIFactory() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   145
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   146
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   147
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   148
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   149
    public Class<?>[] getSupportedAttributeCategories() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   150
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   151
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   152
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   153
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   154
    public Object getSupportedAttributeValues(Class<? extends Attribute> category,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   155
                                    DocFlavor flavor, AttributeSet attributes) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   156
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   157
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   158
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   159
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   160
    public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   161
                                                 AttributeSet attributes) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   162
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   163
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   164
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   165
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   166
    public boolean isAttributeCategorySupported(Class<? extends Attribute> category) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   167
        return false;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   168
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   169
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   170
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   171
    public boolean isAttributeValueSupported(Attribute attrval,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   172
                                             DocFlavor flavor,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   173
                                             AttributeSet attributes) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   174
        return false;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   175
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   176
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   177
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   178
    public void addPrintServiceAttributeListener(PrintServiceAttributeListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   179
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   180
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   181
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   182
    public void removePrintServiceAttributeListener(PrintServiceAttributeListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   183
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   184
}
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   185
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   186
class DummyDocPrintJob implements DocPrintJob {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   187
    private static int _counter;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   188
    private final PrintService _printService;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   189
    private final PrintJobAttributeSet _printJobAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   190
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   191
    public DummyDocPrintJob(PrintService printService) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   192
        _counter++;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   193
        _printService = printService;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   194
        _printJobAttributeSet = new HashPrintJobAttributeSet();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   195
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   196
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   197
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   198
    public PrintService getPrintService() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   199
        return _printService;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   200
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   201
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   202
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   203
    public PrintJobAttributeSet getAttributes() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   204
        return _printJobAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   205
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   206
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   207
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   208
    public void addPrintJobAttributeListener(PrintJobAttributeListener listener,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   209
                                    PrintJobAttributeSet printJobAttributeSet) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   210
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   211
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   212
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   213
    public void removePrintJobAttributeListener(PrintJobAttributeListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   214
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   215
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   216
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   217
    public void addPrintJobListener(PrintJobListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   218
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   219
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   220
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   221
    public void removePrintJobListener(PrintJobListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   222
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   223
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   224
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   225
    public void print(Doc doc,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   226
                      PrintRequestAttributeSet printRequestAttributeSet)
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   227
          throws PrintException {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   228
        System.out.println("job name: " + printRequestAttributeSet.get(JobName.class));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   229
        System.out.println("copies: " + printRequestAttributeSet.get(Copies.class));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   230
        if(printRequestAttributeSet.get(JobName.class) == null ||
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   231
            printRequestAttributeSet.get(Copies.class) == null) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   232
            throw new RuntimeException("Copies and JobName is not passed correctly");
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   233
        }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   234
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   235
}
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   236
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   237
class DummyPrintable implements Printable {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   238
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   239
    public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   240
            throws PrinterException {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   241
        if (pageIndex == 0) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   242
            return Printable.PAGE_EXISTS;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   243
        } else {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   244
            return Printable.NO_SUCH_PAGE;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   245
        }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   246
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   247
}