1.1 --- a/test/java/awt/PrintJob/EdgeTest/EdgeTest.java Wed Apr 15 08:47:21 2009 -0700
1.2 +++ b/test/java/awt/PrintJob/EdgeTest/EdgeTest.java Mon Apr 20 12:31:36 2009 -0700
1.3 @@ -27,6 +27,7 @@
1.4 * @summary Verifies that (0, 0) is the upper-left corner of the page, not
1.5 * the upper-left corner adjusted for the margins.
1.6 * @author dpm
1.7 + * @run main/manual EdgeTest
1.8 */
1.9
1.10 import java.awt.*;
1.11 @@ -43,7 +44,9 @@
1.12 }
1.13 );
1.14 f.setVisible(true);
1.15 - PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", null);
1.16 + JobAttributes job = new JobAttributes();
1.17 + job.setDialog(JobAttributes.DialogType.NONE);
1.18 + PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", job, null);
1.19 if (pj != null) {
1.20 Graphics g = pj.getGraphics();
1.21 Dimension d = pj.getPageDimension();
2.1 --- a/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java Wed Apr 15 08:47:21 2009 -0700
2.2 +++ b/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java Mon Apr 20 12:31:36 2009 -0700
2.3 @@ -44,7 +44,10 @@
2.4 public MultipleEndFrame() {
2.5 super("MultipleEnd");
2.6 setVisible(true);
2.7 - PrintJob pj = getToolkit().getPrintJob(this, "MuiltipleEnd", null);
2.8 +
2.9 + JobAttributes job = new JobAttributes();
2.10 + job.setDialog(JobAttributes.DialogType.NONE);
2.11 + PrintJob pj = getToolkit().getPrintJob(this, "MultipleEnd", job, null);
2.12 if (pj != null) {
2.13 pj.end();
2.14 pj.end();
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/test/java/awt/print/PrinterJob/Collate2DPrintingTest.java Mon Apr 20 12:31:36 2009 -0700
3.3 @@ -0,0 +1,252 @@
3.4 +/*
3.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3.7 + *
3.8 + * This code is free software; you can redistribute it and/or modify it
3.9 + * under the terms of the GNU General Public License version 2 only, as
3.10 + * published by the Free Software Foundation.
3.11 + *
3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3.15 + * version 2 for more details (a copy is included in the LICENSE file that
3.16 + * accompanied this code).
3.17 + *
3.18 + * You should have received a copy of the GNU General Public License version
3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3.21 + *
3.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
3.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
3.24 + * have any questions.
3.25 + */
3.26 +
3.27 +/**
3.28 + * @test
3.29 + * @bug 6362683
3.30 + * @summary Collation should work.
3.31 + * @run main/manual Collate2DPrintingTest
3.32 + */
3.33 +import java.awt.*;
3.34 +import java.awt.event.*;
3.35 +import java.awt.print.*;
3.36 +import javax.print.attribute.standard.*;
3.37 +import javax.print.attribute.*;
3.38 +import javax.print.*;
3.39 +import java.io.*;
3.40 +
3.41 +public class Collate2DPrintingTest
3.42 + extends Frame implements Doc, Printable, ActionListener {
3.43 +
3.44 + Button print2D = new Button("2D Print");
3.45 + Button printMerlin = new Button("PrintService");
3.46 + PrinterJob pj = PrinterJob.getPrinterJob();
3.47 + PrintService defService = null;
3.48 + HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
3.49 +
3.50 + public Collate2DPrintingTest() {
3.51 +
3.52 + Panel butPanel = new Panel();
3.53 + butPanel.add(print2D);
3.54 + butPanel.add(printMerlin);
3.55 + print2D.addActionListener(this);
3.56 + printMerlin.addActionListener(this);
3.57 + addWindowListener (new WindowAdapter() {
3.58 + public void windowClosing (WindowEvent e) {
3.59 + dispose();
3.60 + }
3.61 + });
3.62 + add("South", butPanel);
3.63 +
3.64 + defService = PrintServiceLookup.lookupDefaultPrintService();
3.65 + PrintService[] pservice;
3.66 + if (defService == null) {
3.67 + pservice = PrintServiceLookup.lookupPrintServices(null, null);
3.68 + if (pservice.length == 0) {
3.69 + throw new RuntimeException("No printer found. TEST ABORTED");
3.70 + }
3.71 + defService = pservice[0];
3.72 + }
3.73 + prSet.add(SheetCollate.COLLATED);
3.74 + prSet.add(new Copies(2));
3.75 + pj.setPrintable(Collate2DPrintingTest.this);
3.76 + setSize(300, 200);
3.77 + setVisible(true);
3.78 + }
3.79 +
3.80 +
3.81 + public int print(Graphics g, PageFormat pf, int pageIndex)
3.82 + throws PrinterException {
3.83 + g.drawString("Page: " + pageIndex, 100, 100);
3.84 + if (pageIndex == 2) {
3.85 + return Printable.NO_SUCH_PAGE;
3.86 + } else {
3.87 + return Printable.PAGE_EXISTS;
3.88 + }
3.89 + }
3.90 +
3.91 + public void actionPerformed (ActionEvent ae) {
3.92 + try {
3.93 + if (ae.getSource() == print2D) {
3.94 + if (pj.printDialog(prSet)) {
3.95 + pj.print(prSet);
3.96 + }
3.97 + } else {
3.98 + DocPrintJob pj = defService.createPrintJob();
3.99 + pj.print(this, prSet);
3.100 + }
3.101 + System.out.println ("DONE");
3.102 + } catch (Exception e) {
3.103 + e.printStackTrace();
3.104 + }
3.105 + }
3.106 +
3.107 + public DocAttributeSet getAttributes() {
3.108 + return null;
3.109 + }
3.110 +
3.111 + public DocFlavor getDocFlavor() {
3.112 + DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
3.113 + return flavor;
3.114 + }
3.115 +
3.116 + public Object getPrintData() {
3.117 + return this;
3.118 + }
3.119 +
3.120 + public Reader getReaderForText() {
3.121 + return null;
3.122 + }
3.123 +
3.124 + public InputStream getStreamForBytes() {
3.125 + return null;
3.126 + }
3.127 +
3.128 + public static void main( String[] args) {
3.129 +
3.130 + String[] instructions =
3.131 + {
3.132 + "You must have a printer available to perform this test",
3.133 + "The print result should be collated."
3.134 + };
3.135 + Sysout.createDialog( );
3.136 + Sysout.printInstructions( instructions );
3.137 +
3.138 + new Collate2DPrintingTest();
3.139 + }
3.140 +}
3.141 +
3.142 +
3.143 +class Sysout {
3.144 + private static TestDialog dialog;
3.145 +
3.146 + public static void createDialogWithInstructions( String[] instructions )
3.147 + {
3.148 + dialog = new TestDialog( new Frame(), "Instructions" );
3.149 + dialog.printInstructions( instructions );
3.150 + dialog.setVisible(true);
3.151 + println( "Any messages for the tester will display here." );
3.152 + }
3.153 +
3.154 + public static void createDialog( )
3.155 + {
3.156 + dialog = new TestDialog( new Frame(), "Instructions" );
3.157 + String[] defInstr = { "Instructions will appear here. ", "" } ;
3.158 + dialog.printInstructions( defInstr );
3.159 + dialog.setVisible(true);
3.160 + println( "Any messages for the tester will display here." );
3.161 + }
3.162 +
3.163 +
3.164 + public static void printInstructions( String[] instructions )
3.165 + {
3.166 + dialog.printInstructions( instructions );
3.167 + }
3.168 +
3.169 +
3.170 + public static void println( String messageIn )
3.171 + {
3.172 + dialog.displayMessage( messageIn );
3.173 + }
3.174 +
3.175 +}// Sysout class
3.176 +
3.177 +/**
3.178 + This is part of the standard test machinery. It provides a place for the
3.179 + test instructions to be displayed, and a place for interactive messages
3.180 + to the user to be displayed.
3.181 + To have the test instructions displayed, see Sysout.
3.182 + To have a message to the user be displayed, see Sysout.
3.183 + Do not call anything in this dialog directly.
3.184 + */
3.185 +class TestDialog extends Dialog {
3.186 +
3.187 + TextArea instructionsText;
3.188 + TextArea messageText;
3.189 + int maxStringLength = 80;
3.190 +
3.191 + //DO NOT call this directly, go through Sysout
3.192 + public TestDialog( Frame frame, String name )
3.193 + {
3.194 + super( frame, name );
3.195 + int scrollBoth = TextArea.SCROLLBARS_BOTH;
3.196 + instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
3.197 + add( "North", instructionsText );
3.198 +
3.199 + messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
3.200 + add("Center", messageText);
3.201 +
3.202 + pack();
3.203 +
3.204 + setVisible(true);
3.205 + }// TestDialog()
3.206 +
3.207 + //DO NOT call this directly, go through Sysout
3.208 + public void printInstructions( String[] instructions )
3.209 + {
3.210 + //Clear out any current instructions
3.211 + instructionsText.setText( "" );
3.212 +
3.213 + //Go down array of instruction strings
3.214 +
3.215 + String printStr, remainingStr;
3.216 + for( int i=0; i < instructions.length; i++ )
3.217 + {
3.218 + //chop up each into pieces maxSringLength long
3.219 + remainingStr = instructions[ i ];
3.220 + while( remainingStr.length() > 0 )
3.221 + {
3.222 + //if longer than max then chop off first max chars to print
3.223 + if( remainingStr.length() >= maxStringLength )
3.224 + {
3.225 + //Try to chop on a word boundary
3.226 + int posOfSpace = remainingStr.
3.227 + lastIndexOf( ' ', maxStringLength - 1 );
3.228 +
3.229 + if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
3.230 +
3.231 + printStr = remainingStr.substring( 0, posOfSpace + 1 );
3.232 + remainingStr = remainingStr.substring( posOfSpace + 1 );
3.233 + }
3.234 + //else just print
3.235 + else
3.236 + {
3.237 + printStr = remainingStr;
3.238 + remainingStr = "";
3.239 + }
3.240 +
3.241 + instructionsText.append( printStr + "\n" );
3.242 +
3.243 + }// while
3.244 +
3.245 + }// for
3.246 +
3.247 + }//printInstructions()
3.248 +
3.249 + //DO NOT call this directly, go through Sysout
3.250 + public void displayMessage( String messageIn )
3.251 + {
3.252 + messageText.append( messageIn + "\n" );
3.253 + }
3.254 +
3.255 + }// TestDialog class
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/test/java/awt/print/PrinterJob/PrtException.java Mon Apr 20 12:31:36 2009 -0700
4.3 @@ -0,0 +1,78 @@
4.4 +/*
4.5 + * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4.7 + *
4.8 + * This code is free software; you can redistribute it and/or modify it
4.9 + * under the terms of the GNU General Public License version 2 only, as
4.10 + * published by the Free Software Foundation.
4.11 + *
4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4.15 + * version 2 for more details (a copy is included in the LICENSE file that
4.16 + * accompanied this code).
4.17 + *
4.18 + * You should have received a copy of the GNU General Public License version
4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4.21 + *
4.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
4.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
4.24 + * have any questions.
4.25 + */
4.26 +/*
4.27 + @test
4.28 + @bug 4429544
4.29 + @summary This test should not throw a printer exception. Test has been modified to correspond with the behavior of 1.5 and above.
4.30 + @run main PrtException
4.31 +*/
4.32 +
4.33 +import java.awt.*;
4.34 +import java.awt.print.*;
4.35 +import javax.print.*;
4.36 +
4.37 +public class PrtException implements Printable {
4.38 + PrinterJob pj;
4.39 +
4.40 + public PrtException() {
4.41 +
4.42 + try{
4.43 + PrintService[] svc;
4.44 + PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
4.45 + if (defService == null) {
4.46 + svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
4.47 + if (svc.length == 0) {
4.48 + throw new RuntimeException("Printer is required for this test. TEST ABORTED");
4.49 + }
4.50 + defService = svc[0];
4.51 + }
4.52 +
4.53 + System.out.println("PrintService found : "+defService);
4.54 + pj = PrinterJob.getPrinterJob();;
4.55 + pj.setPrintService(defService);
4.56 + //pj.setPrintable(this); // commenting this line should not result in PrinterException
4.57 + pj.print();
4.58 + } catch(PrinterException e ) {
4.59 + e.printStackTrace();
4.60 + throw new RuntimeException(" PrinterException should not be thrown. TEST FAILED");
4.61 + }
4.62 + System.out.println("TEST PASSED");
4.63 + }
4.64 +
4.65 +
4.66 + public int print(Graphics g,PageFormat pf,int pageIndex) {
4.67 + Graphics2D g2= (Graphics2D)g;
4.68 + if(pageIndex>=1){
4.69 + return Printable.NO_SUCH_PAGE;
4.70 + }
4.71 + g2.translate(pf.getImageableX(), pf.getImageableY());
4.72 + g2.setColor(Color.black);
4.73 + g2.drawString("Hello world.", 10, 10);
4.74 +
4.75 + return Printable.PAGE_EXISTS;
4.76 + }
4.77 +
4.78 + public static void main(String arg[]) {
4.79 + PrtException sp = new PrtException();
4.80 + }
4.81 +}
5.1 --- a/test/javax/print/CheckDupFlavor.java Wed Apr 15 08:47:21 2009 -0700
5.2 +++ b/test/javax/print/CheckDupFlavor.java Mon Apr 20 12:31:36 2009 -0700
5.3 @@ -1,5 +1,5 @@
5.4 /*
5.5 - * Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
5.6 + * Copyright 2004-2009 Sun Microsystems, Inc. All Rights Reserved.
5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5.8 *
5.9 * This code is free software; you can redistribute it and/or modify it
5.10 @@ -35,17 +35,19 @@
5.11
5.12 public class CheckDupFlavor {
5.13 public static void main(String[] args){
5.14 - PrintService pservice =
5.15 - PrintServiceLookup.lookupDefaultPrintService();
5.16 -
5.17 - if (pservice == null) {
5.18 - System.out.println("No default PrintService found. Test ABORTED.");
5.19 - return;
5.20 + PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
5.21 + PrintService[] pservice;
5.22 + if (defService == null) {
5.23 + pservice = PrintServiceLookup.lookupPrintServices(null, null);
5.24 + if (pservice.length == 0) {
5.25 + throw new RuntimeException("No printer found. TEST ABORTED");
5.26 + }
5.27 + defService = pservice[0];
5.28 }
5.29
5.30 - System.out.println("Default service = "+pservice);
5.31 + System.out.println("PrintService = "+defService);
5.32
5.33 - DocFlavor[] flavors = pservice.getSupportedDocFlavors();
5.34 + DocFlavor[] flavors = defService.getSupportedDocFlavors();
5.35 if (flavors==null) {
5.36 System.out.println("No flavors supported. Test PASSED.");
5.37 return;
5.38 @@ -54,13 +56,13 @@
5.39
5.40 ArrayList flavorList = new ArrayList();
5.41 for (int i=0; i<flavors.length; i++) {
5.42 - if (flavors[i] == null) {
5.43 - throw new RuntimeException("Null flavor. Test FAILED.");
5.44 - } else if (flavorList.contains(flavors[i])) {
5.45 - throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
5.46 - } else {
5.47 - flavorList.add(flavors[i]);
5.48 - }
5.49 + if (flavors[i] == null) {
5.50 + throw new RuntimeException("Null flavor. Test FAILED.");
5.51 + } else if (flavorList.contains(flavors[i])) {
5.52 + throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
5.53 + } else {
5.54 + flavorList.add(flavors[i]);
5.55 + }
5.56 }
5.57 System.out.println("No duplicate found. Test PASSED.");
5.58 }
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/test/javax/print/LookupServices.java Mon Apr 20 12:31:36 2009 -0700
6.3 @@ -0,0 +1,50 @@
6.4 +/*
6.5 + * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6.7 + *
6.8 + * This code is free software; you can redistribute it and/or modify it
6.9 + * under the terms of the GNU General Public License version 2 only, as
6.10 + * published by the Free Software Foundation.
6.11 + *
6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6.15 + * version 2 for more details (a copy is included in the LICENSE file that
6.16 + * accompanied this code).
6.17 + *
6.18 + * You should have received a copy of the GNU General Public License version
6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6.21 + *
6.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
6.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
6.24 + * have any questions.
6.25 + */
6.26 +
6.27 +/*
6.28 + * @test
6.29 + * @bug 4510477 6520186
6.30 + * @summary No crash with HP OfficeJet 600 installed.
6.31 + * @run main LookupServices
6.32 +*/
6.33 +
6.34 +import javax.print.attribute.*;
6.35 +import javax.print.*;
6.36 +
6.37 +public class LookupServices {
6.38 + public static void main (String [] args) {
6.39 +
6.40 + DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
6.41 + HashPrintRequestAttributeSet prSet = null;
6.42 +
6.43 + PrintService[] serv = PrintServiceLookup.lookupPrintServices(flavor, null);
6.44 + System.out.println("default "+PrintServiceLookup.lookupDefaultPrintService());
6.45 + if (serv.length==0) {
6.46 + System.out.println("no PrintService supports GIF");
6.47 + return;
6.48 + }
6.49 +
6.50 + System.out.println("Selected print service: "+ serv[0]);
6.51 + }
6.52 +
6.53 +}
7.1 --- a/test/javax/print/TestRaceCond.java Wed Apr 15 08:47:21 2009 -0700
7.2 +++ b/test/javax/print/TestRaceCond.java Mon Apr 20 12:31:36 2009 -0700
7.3 @@ -43,6 +43,10 @@
7.4 PrintService[] pservs = PrintServiceLookup.lookupPrintServices(null, null);
7.5 PrintService pserv2 = PrintServiceLookup.lookupDefaultPrintService();
7.6
7.7 + if ((pserv1 == null) || (pserv2==null)) {
7.8 + return;
7.9 + }
7.10 +
7.11 if (pserv1.hashCode() != pserv2.hashCode()) {
7.12 throw new RuntimeException("Different hashCodes for equal print "
7.13 + "services: " + pserv1.hashCode() + " "
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/test/javax/print/attribute/Chroma.java Mon Apr 20 12:31:36 2009 -0700
8.3 @@ -0,0 +1,66 @@
8.4 +/*
8.5 + * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8.7 + *
8.8 + * This code is free software; you can redistribute it and/or modify it
8.9 + * under the terms of the GNU General Public License version 2 only, as
8.10 + * published by the Free Software Foundation.
8.11 + *
8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8.15 + * version 2 for more details (a copy is included in the LICENSE file that
8.16 + * accompanied this code).
8.17 + *
8.18 + * You should have received a copy of the GNU General Public License version
8.19 + * 2 along with this work; if not, write to the Free Software Foundation,
8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8.21 + *
8.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
8.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
8.24 + * have any questions.
8.25 + */
8.26 +/*
8.27 + * @test 1.3 01/05/11
8.28 + * @bug 4456750
8.29 + * @summary Test for supported chromaticity values with null DocFlavor.
8.30 + * No exception should be thrown.
8.31 + * @run main Chroma
8.32 +*/
8.33 +
8.34 +// Chroma.java
8.35 +import java.io.*;
8.36 +
8.37 +import javax.print.*;
8.38 +import javax.print.attribute.*;
8.39 +import javax.print.attribute.standard.*;
8.40 +
8.41 +public class Chroma {
8.42 +
8.43 + public static void main(String args[]) {
8.44 +
8.45 + StreamPrintServiceFactory []fact =
8.46 + StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
8.47 + DocFlavor.SERVICE_FORMATTED.PRINTABLE,
8.48 + DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
8.49 +
8.50 + if (fact.length != 0) {
8.51 + OutputStream out = new ByteArrayOutputStream();
8.52 + StreamPrintService sps = fact[0].getPrintService(out);
8.53 + checkChroma(sps);
8.54 + }
8.55 +
8.56 + PrintService defSvc = PrintServiceLookup.lookupDefaultPrintService();
8.57 + if (defSvc != null) {
8.58 + checkChroma(defSvc);
8.59 + }
8.60 +
8.61 + }
8.62 +
8.63 + static void checkChroma(PrintService svc) {
8.64 + if (svc.isAttributeCategorySupported(Chromaticity.class)) {
8.65 + svc.getSupportedAttributeValues(Chromaticity.class,null,null);
8.66 + }
8.67 + }
8.68 +
8.69 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/test/javax/print/attribute/ChromaticityValues.java Mon Apr 20 12:31:36 2009 -0700
9.3 @@ -0,0 +1,97 @@
9.4 +/*
9.5 + * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9.7 + *
9.8 + * This code is free software; you can redistribute it and/or modify it
9.9 + * under the terms of the GNU General Public License version 2 only, as
9.10 + * published by the Free Software Foundation.
9.11 + *
9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9.15 + * version 2 for more details (a copy is included in the LICENSE file that
9.16 + * accompanied this code).
9.17 + *
9.18 + * You should have received a copy of the GNU General Public License version
9.19 + * 2 along with this work; if not, write to the Free Software Foundation,
9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9.21 + *
9.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
9.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
9.24 + * have any questions.
9.25 + */
9.26 +/*
9.27 + * @test
9.28 + * @bug 4446106
9.29 + * @summary Test for chromaticity values.
9.30 + * @run main ChromaticityValues
9.31 +*/
9.32 +
9.33 +
9.34 +
9.35 +import javax.print.*;
9.36 +import javax.print.attribute.*;
9.37 +import javax.print.attribute.standard.*;
9.38 +import java.util.ArrayList;
9.39 +
9.40 +public class ChromaticityValues {
9.41 +
9.42 + public static void main(String args[]) {
9.43 + System.out.println("=======================================================================");
9.44 + System.out.println("INSTRUCTIONS: This test is only for WINDOWS platform. ");
9.45 + System.out.println("You should have a printer configured as your default printer in your system.");
9.46 + System.out.println("=======================================================================");
9.47 +
9.48 + String os=System.getProperty("os.name").toLowerCase();
9.49 +
9.50 + if (!(os.indexOf("win")>=0)) {
9.51 + System.out.println("Not a Windows System. TEST ABORTED");
9.52 + return;
9.53 + }
9.54 +
9.55 + PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
9.56 + if (pservice == null) {
9.57 + throw new RuntimeException("A printer is required for this test.");
9.58 + }
9.59 +
9.60 + System.out.println("Default Service is "+pservice);
9.61 + ColorSupported psa = (ColorSupported)pservice.getAttribute(ColorSupported.class);
9.62 + ArrayList cValues = new ArrayList();
9.63 +
9.64 + if (pservice.isAttributeCategorySupported(Chromaticity.class)) {
9.65 + Chromaticity[] values =(Chromaticity[])
9.66 + (pservice.getSupportedAttributeValues(Chromaticity.class, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null));
9.67 + if ((values != null) && (values.length > 0)) {
9.68 + for (int i=0; i<values.length; i++) {
9.69 + cValues.add(values[i]);
9.70 + }
9.71 + } else {
9.72 + System.out.println("Chromaticity value is unknown. TEST ABORTED");
9.73 + return;
9.74 + }
9.75 +
9.76 + } else {
9.77 + System.out.println("Chromaticity is not supported. TEST ABORTED");
9.78 + return;
9.79 +
9.80 + }
9.81 +
9.82 + if (psa != null) {
9.83 + if (psa.equals(ColorSupported.SUPPORTED)) {
9.84 + if (cValues.size() < 2) {
9.85 + throw new RuntimeException("ColorSupported is supported, values for Chromaticity should be monochrome and color.");
9.86 + }
9.87 + } else {
9.88 + if ((cValues.size() != 1) ||
9.89 + (!cValues.contains(Chromaticity.MONOCHROME))) {
9.90 + throw new RuntimeException("ColorSupported is not supported, values for Chromaticity should only be monochrome.");
9.91 + }
9.92 + }
9.93 + } else { // ColorSupported unknown
9.94 + if (!cValues.contains(Chromaticity.COLOR)) {
9.95 + throw new RuntimeException("ColorSupported is unknown, values for Chromaticity should at least include color.");
9.96 + }
9.97 +
9.98 + }
9.99 + }
9.100 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/test/javax/print/attribute/GetCopiesSupported.java Mon Apr 20 12:31:36 2009 -0700
10.3 @@ -0,0 +1,57 @@
10.4 +/*
10.5 + * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10.7 + *
10.8 + * This code is free software; you can redistribute it and/or modify it
10.9 + * under the terms of the GNU General Public License version 2 only, as
10.10 + * published by the Free Software Foundation.
10.11 + *
10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10.15 + * version 2 for more details (a copy is included in the LICENSE file that
10.16 + * accompanied this code).
10.17 + *
10.18 + * You should have received a copy of the GNU General Public License version
10.19 + * 2 along with this work; if not, write to the Free Software Foundation,
10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10.21 + *
10.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
10.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
10.24 + * have any questions.
10.25 + */
10.26 +/*
10.27 + @test
10.28 + @bug 4463280
10.29 + @summary No ClassCastException should occur.
10.30 + @run main GetCopiesSupported
10.31 +*/
10.32 +
10.33 +import javax.print.*;
10.34 +import javax.print.attribute.*;
10.35 +import javax.print.attribute.standard.*;
10.36 +
10.37 +public class GetCopiesSupported {
10.38 +
10.39 + public static void main(String args[]) {
10.40 + PrintService service = PrintServiceLookup.lookupDefaultPrintService();
10.41 + PrintService[] pservice;
10.42 + if (service == null) {
10.43 + pservice = PrintServiceLookup.lookupPrintServices(null, null);
10.44 + if (pservice.length == 0) {
10.45 + throw new RuntimeException("No printer found. TEST ABORTED");
10.46 + }
10.47 + service = pservice[0];
10.48 + }
10.49 +
10.50 + if (service != null) {
10.51 + CopiesSupported c = (CopiesSupported)
10.52 + service.getSupportedAttributeValues(Copies.class,
10.53 + null, null);
10.54 +
10.55 + System.out.println("CopiesSupported : "+c);
10.56 + }
10.57 + }
10.58 +
10.59 +
10.60 +}
11.1 --- a/test/javax/print/attribute/PSCopiesFlavorTest.java Wed Apr 15 08:47:21 2009 -0700
11.2 +++ b/test/javax/print/attribute/PSCopiesFlavorTest.java Mon Apr 20 12:31:36 2009 -0700
11.3 @@ -1,5 +1,5 @@
11.4 /*
11.5 - * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
11.6 + * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
11.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11.8 *
11.9 * This code is free software; you can redistribute it and/or modify it
11.10 @@ -37,26 +37,26 @@
11.11 public static void main(String args[]) {
11.12
11.13 DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
11.14 - PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
11.15 - if (!(ps.isDocFlavorSupported(flavor))) {
11.16 - System.out.println("unsupported flavor :" + flavor);
11.17 - return;
11.18 + PrintService[] ps = PrintServiceLookup.lookupPrintServices(flavor, null);
11.19 + if (ps.length > 0) {
11.20 + System.out.println("found PrintService: "+ps[0]);
11.21 + Copies c = new Copies(1);
11.22 + PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
11.23 + aset.add(c);
11.24 + boolean suppVal = ps[0].isAttributeValueSupported(c, flavor, null);
11.25 + AttributeSet us = ps[0].getUnsupportedAttributes(flavor, aset);
11.26 + if (suppVal || us == null) {
11.27 + throw new RuntimeException("Copies should be unsupported value");
11.28 + }
11.29 +
11.30 + Object value = ps[0].getSupportedAttributeValues(Copies.class,
11.31 + flavor, null);
11.32 +
11.33 + //Copies Supported
11.34 + if(value instanceof CopiesSupported) {
11.35 + throw new RuntimeException("Copies should have no supported values.");
11.36 + }
11.37 }
11.38 - Copies c = new Copies(1);
11.39 - PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
11.40 - aset.add(c);
11.41 - boolean suppVal = ps.isAttributeValueSupported(c, flavor, null);
11.42 - AttributeSet us = ps.getUnsupportedAttributes(flavor, aset);
11.43 - if (suppVal || us == null) {
11.44 - throw new RuntimeException("Copies should be unsupported value");
11.45 - }
11.46 -
11.47 - Object value = ps.getSupportedAttributeValues(Copies.class, flavor, null);
11.48 -
11.49 - //Copies Supported
11.50 - if(value instanceof CopiesSupported) {
11.51 - throw new RuntimeException("Copies should have no supported values.");
11.52 - }
11.53
11.54 }
11.55 }
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/test/javax/print/attribute/SidesPageRangesTest.java Mon Apr 20 12:31:36 2009 -0700
12.3 @@ -0,0 +1,122 @@
12.4 +/*
12.5 + * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12.7 + *
12.8 + * This code is free software; you can redistribute it and/or modify it
12.9 + * under the terms of the GNU General Public License version 2 only, as
12.10 + * published by the Free Software Foundation.
12.11 + *
12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12.15 + * version 2 for more details (a copy is included in the LICENSE file that
12.16 + * accompanied this code).
12.17 + *
12.18 + * You should have received a copy of the GNU General Public License version
12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12.21 + *
12.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
12.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
12.24 + * have any questions.
12.25 + */
12.26 +/*
12.27 + * @test
12.28 + * @bug 4903366
12.29 + * @summary No crash should occur.
12.30 + * @run main SidesPageRangesTest
12.31 +*/
12.32 +import java.awt.*;
12.33 +import javax.print.*;
12.34 +import javax.print.attribute.standard.*;
12.35 +import javax.print.attribute.*;
12.36 +import java.io.*;
12.37 +import java.util.Locale;
12.38 +import java.net.URL;
12.39 +
12.40 +public class SidesPageRangesTest {
12.41 + /**
12.42 + * Constructor
12.43 + */
12.44 + public SidesPageRangesTest() {
12.45 + super();
12.46 + }
12.47 + /**
12.48 + * Starts the application.
12.49 + */
12.50 + public static void main(java.lang.String[] args) {
12.51 + SidesPageRangesTest pd = new SidesPageRangesTest();
12.52 + PrintService defService = null;
12.53 + DocFlavor flavors[] = null;
12.54 + PrintService[] pservice;
12.55 + defService = PrintServiceLookup.lookupDefaultPrintService();
12.56 + if (defService == null) {
12.57 + pservice = PrintServiceLookup.lookupPrintServices(null, null);
12.58 + if (pservice.length == 0) {
12.59 + throw new RuntimeException("Printer is required for this test. TEST ABORTED");
12.60 + }
12.61 + defService = pservice[0];
12.62 + }
12.63 + System.out.println("Default Print Service "+defService);
12.64 +
12.65 +
12.66 + if (defService.isAttributeCategorySupported(PageRanges.class)) {
12.67 + System.out.println("\nPageRanges Attribute category is supported");
12.68 + } else {
12.69 + System.out.println("\nPageRanges Attribute category is not supported. terminating...");
12.70 + System.exit(1);
12.71 + }
12.72 +
12.73 + flavors = defService.getSupportedDocFlavors();
12.74 + System.out.println("\nGetting Supported values for PageRanges for each supported DocFlavor");
12.75 + System.out.println("===============================================================\n");
12.76 + for (int y = 0; y < flavors.length; y ++) {
12.77 + System.out.println("\n\n");
12.78 +
12.79 + System.out.println("Doc Flavor: "+flavors[y]);
12.80 + System.out.println("-----------------------------");
12.81 +
12.82 + Object vals = defService.getSupportedAttributeValues(PageRanges.class, flavors[y], null);
12.83 + if (vals == null) {
12.84 + System.out.println("No supported values for PageRanges for this doc flavor. ");
12.85 + }
12.86 +
12.87 + PageRanges[] pr = null;
12.88 + if (vals instanceof PageRanges[]) {
12.89 + pr = (PageRanges[]) vals;
12.90 + for (int x = 0; x < pr.length; x ++) {
12.91 + System.out.println("\nSupported Value "+pr[x]);
12.92 + System.out.println("is "+pr[x]+" value supported? "+defService.isAttributeValueSupported(pr[x], flavors[y], null));
12.93 +
12.94 + if (!defService.isAttributeValueSupported(pr[x], flavors[y], null)) {
12.95 + throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
12.96 + }
12.97 + }
12.98 + } else if (vals instanceof PageRanges) {
12.99 + System.out.println(vals);
12.100 + System.out.println("is "+vals+" value supported? "+defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null));
12.101 + if (!defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null)) {
12.102 + throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
12.103 + }
12.104 + }
12.105 +
12.106 + // SIDES test
12.107 + vals = defService.getSupportedAttributeValues(Sides.class, flavors[y], null);
12.108 + if (vals == null) {
12.109 + System.out.println("No supported values for Sides for this doc flavor. ");
12.110 + }
12.111 +
12.112 + Sides[] s = null;
12.113 + if (vals instanceof Sides[]) {
12.114 + s = (Sides[]) vals;
12.115 + for (int x = 0; x < s.length; x ++) {
12.116 + System.out.println("\nSupported Value "+s[x]);
12.117 + System.out.println("is "+s[x]+" value supported? "+defService.isAttributeValueSupported(s[x], flavors[y], null));
12.118 + if (!defService.isAttributeValueSupported(s[x], flavors[y], null)) {
12.119 + throw new RuntimeException("Sides contradicts getSupportedAttributeValues");
12.120 + }
12.121 + }
12.122 + }
12.123 + }
12.124 + }
12.125 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/test/javax/print/attribute/SupportedPrintableAreas.java Mon Apr 20 12:31:36 2009 -0700
13.3 @@ -0,0 +1,83 @@
13.4 +/*
13.5 + * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
13.7 + *
13.8 + * This code is free software; you can redistribute it and/or modify it
13.9 + * under the terms of the GNU General Public License version 2 only, as
13.10 + * published by the Free Software Foundation.
13.11 + *
13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13.15 + * version 2 for more details (a copy is included in the LICENSE file that
13.16 + * accompanied this code).
13.17 + *
13.18 + * You should have received a copy of the GNU General Public License version
13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
13.21 + *
13.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
13.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
13.24 + * have any questions.
13.25 + */
13.26 +
13.27 +/*
13.28 + * @test
13.29 + * @bug 4762773 6289206 6324049 6362765
13.30 + * @summary Tests that get non-null return list of printable areas.
13.31 + * @run main SupportedPrintableAreas
13.32 + */
13.33 +
13.34 +
13.35 +import javax.print.*;
13.36 +import javax.print.event.*;
13.37 +import javax.print.attribute.*;
13.38 +import javax.print.attribute.standard.*;
13.39 +
13.40 +public class SupportedPrintableAreas {
13.41 +
13.42 + public static void main(String[] args) {
13.43 + PrintService[] svc;
13.44 + PrintService printer = PrintServiceLookup.lookupDefaultPrintService();
13.45 + if (printer == null) {
13.46 + svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
13.47 + if (svc.length == 0) {
13.48 + throw new RuntimeException("Printer is required for this test. TEST ABORTED");
13.49 + }
13.50 + printer = svc[0];
13.51 + }
13.52 + System.out.println("PrintService found : "+printer);
13.53 +
13.54 + if (!printer.isAttributeCategorySupported(MediaPrintableArea.class)) {
13.55 + return;
13.56 + }
13.57 + Object value = printer.getSupportedAttributeValues(
13.58 + MediaPrintableArea.class, null, null);
13.59 + if (!value.getClass().isArray()) {
13.60 + throw new RuntimeException("unexpected value");
13.61 + }
13.62 +
13.63 + PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
13.64 + value = printer.getSupportedAttributeValues(
13.65 + MediaPrintableArea.class, null, aset);
13.66 + if (!value.getClass().isArray()) {
13.67 + throw new RuntimeException("unexpected value");
13.68 + }
13.69 +
13.70 + Media media = (Media)printer.getDefaultAttributeValue(Media.class);
13.71 + aset.add(media);
13.72 + value = printer.getSupportedAttributeValues(
13.73 + MediaPrintableArea.class, null, aset);
13.74 + if (!value.getClass().isArray()) {
13.75 + throw new RuntimeException("unexpected value");
13.76 + }
13.77 +
13.78 + // test for 6289206
13.79 + aset.add(MediaTray.MANUAL);
13.80 + value = printer.getSupportedAttributeValues(
13.81 + MediaPrintableArea.class, null, aset);
13.82 + if ((value != null) && !value.getClass().isArray()) {
13.83 + throw new RuntimeException("unexpected value");
13.84 + }
13.85 + }
13.86 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/test/javax/print/attribute/autosense/PrintAutoSenseData.java Mon Apr 20 12:31:36 2009 -0700
14.3 @@ -0,0 +1,152 @@
14.4 +/*
14.5 + * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
14.7 + *
14.8 + * This code is free software; you can redistribute it and/or modify it
14.9 + * under the terms of the GNU General Public License version 2 only, as
14.10 + * published by the Free Software Foundation.
14.11 + *
14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14.15 + * version 2 for more details (a copy is included in the LICENSE file that
14.16 + * accompanied this code).
14.17 + *
14.18 + * You should have received a copy of the GNU General Public License version
14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
14.21 + *
14.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
14.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
14.24 + * have any questions.
14.25 + */
14.26 +
14.27 +/*
14.28 + * @test
14.29 + * @bug 4468109
14.30 + * @summary Test for printing AUTOSENSE DocFlavor. No exception should be thrown.
14.31 + * @run main PrintAutoSenseData
14.32 +*/
14.33 +
14.34 +import java.io.*;
14.35 +import javax.print.*;
14.36 +import javax.print.attribute.*;
14.37 +import javax.print.attribute.standard.*;
14.38 +import java.net.URL;
14.39 +
14.40 +public class PrintAutoSenseData
14.41 +{
14.42 + private DocFlavor flavor = DocFlavor.URL.AUTOSENSE; //represents the docflavor.
14.43 + private PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor, null);
14.44 +
14.45 +
14.46 + public PrintAutoSenseData()
14.47 + {
14.48 + if (service.length == 0)
14.49 + {
14.50 + System.out.println("No print service available...");
14.51 + return;
14.52 + }
14.53 +
14.54 + System.out.println("selected PrintService: " + this.service[0]);
14.55 + if (service[0].isDocFlavorSupported(flavor)) {
14.56 + System.out.println("DocFlavor.URL.AUTOSENSE supported");
14.57 + } else {
14.58 + System.out.println("DocFlavor.URL.AUTOSENSE not supported. Testing aborted !!");
14.59 + return;
14.60 + }
14.61 +
14.62 + DocPrintJob job = service[0].createPrintJob();
14.63 + this.print();
14.64 + }
14.65 +
14.66 + // The print method prints sample file with DocFlavor.URL.AUTOSENSE.
14.67 + void print()
14.68 + {
14.69 + String fileName = "./sample.txt";
14.70 + DocPrintJob job = service[0].createPrintJob();
14.71 +
14.72 + // The representation class is a URL.
14.73 + System.out.println("printing " + fileName + " using doc flavor: " + this.flavor);
14.74 + System.out.println("Rep. class name: " + this.flavor.getRepresentationClassName() + " MimeType: " + this.flavor.getMimeType());
14.75 +
14.76 + Doc doc = new URLDoc(fileName, this.flavor);
14.77 + HashPrintRequestAttributeSet prSet =
14.78 + new HashPrintRequestAttributeSet();
14.79 + prSet.add(new Destination(new File("./dest.prn").toURI()));
14.80 + //print the document.
14.81 + try {
14.82 + job.print(doc, prSet);
14.83 + } catch ( Exception e ) {
14.84 + e.printStackTrace();
14.85 + }
14.86 + }
14.87 +
14.88 + public static void main(String[] args) {
14.89 + new PrintAutoSenseData();
14.90 + }
14.91 +
14.92 +}
14.93 +
14.94 +/* This class is for reading autosense data with URL representation class */
14.95 +
14.96 +class URLDoc implements Doc
14.97 +{
14.98 + protected String fileName = null;
14.99 + protected DocFlavor flavor = null;
14.100 + protected Object printData = null;
14.101 + protected InputStream instream = null;
14.102 +
14.103 + public URLDoc(String filename, DocFlavor docFlavor)
14.104 + {
14.105 + this.fileName = filename;
14.106 + this.flavor = docFlavor;
14.107 + }
14.108 +
14.109 + public DocFlavor getDocFlavor() {
14.110 + return DocFlavor.URL.AUTOSENSE;
14.111 + }
14.112 +
14.113 + public DocAttributeSet getAttributes()
14.114 + {
14.115 + HashDocAttributeSet hset = new HashDocAttributeSet();
14.116 + return hset;
14.117 + }
14.118 +
14.119 + public Object getPrintData()
14.120 + {
14.121 + if ( this.printData == null )
14.122 + {
14.123 + this.printData = URLDoc.class.getResource(this.fileName);
14.124 + System.out.println("getPrintData(): " + this.printData);
14.125 + }
14.126 + return this.printData;
14.127 + }
14.128 +
14.129 + public Reader getReaderForText()
14.130 + {
14.131 + return null;
14.132 + }
14.133 +
14.134 + public InputStream getStreamForBytes()
14.135 + {
14.136 + System.out.println("getStreamForBytes(): " + this.printData);
14.137 + try
14.138 + {
14.139 + if ( (this.printData != null) && (this.printData instanceof URL) )
14.140 + {
14.141 + this.instream = ((URL)this.printData).openStream();
14.142 + }
14.143 + if (this.instream == null)
14.144 + {
14.145 + URL url = URLDoc.class.getResource(this.fileName);
14.146 + this.instream = url.openStream();
14.147 + }
14.148 + }
14.149 + catch ( IOException ie )
14.150 + {
14.151 + System.out.println("URLDoc: exception: " + ie.toString());
14.152 + }
14.153 + return this.instream;
14.154 + }
14.155 +}