javax.print.attribute.standard.JobSheets Java Examples
The following examples show how to use
javax.print.attribute.standard.JobSheets.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BannerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { job = PrinterJob.getPrinterJob(); PrintService prtSrv = job.getPrintService(); if (job.getPrintService() == null) { System.out.println("No printers. Test cannot continue"); return; } if (!prtSrv.isAttributeCategorySupported(JobSheets.class)) { return; } SwingUtilities.invokeAndWait(() -> { doTest(BannerTest::printTest); }); mainThread = Thread.currentThread(); try { Thread.sleep(180000); } catch (InterruptedException e) { if (!testPassed && testGeneratedInterrupt) { throw new RuntimeException("Banner page did not print"); } } if (!testGeneratedInterrupt) { throw new RuntimeException("user has not executed the test"); } }
Example #2
Source File: UnixPrintJob.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
UnixPrintJob(PrintService service) { this.service = service; mDestination = service.getName(); if (PrintServiceLookupProvider.isMac()) { mDestination = ((IPPPrintService)service).getDest(); } mDestType = UnixPrintJob.DESTPRINTER; JobSheets js = (JobSheets)(service. getDefaultAttributeValue(JobSheets.class)); if (js != null && js.equals(JobSheets.NONE)) { mNoJobSheet = true; } }
Example #3
Source File: TestCheckSystemDefaultBannerOption.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main (String[] args) throws Exception { job = PrinterJob.getPrinterJob(); PrintService prtSrv = job.getPrintService(); if (prtSrv == null) { System.out.println("No printers. Test cannot continue"); return; } // do not run the test if JobSheet category is not supported if (!prtSrv.isAttributeCategorySupported(JobSheets.class)) { return; } // check system default banner option and let user know what to expect JobSheets js = (JobSheets)job.getPrintService(). getDefaultAttributeValue(JobSheets.class); if (js != null && js.equals(JobSheets.NONE)) { noJobSheet = true; } SwingUtilities.invokeAndWait(() -> { doTest(TestCheckSystemDefaultBannerOption::printTest); }); mainThread = Thread.currentThread(); try { Thread.sleep(60000); } catch (InterruptedException e) { if (!testPassed && testGeneratedInterrupt) { String banner = noJobSheet ? "Banner page" : " No Banner page"; throw new RuntimeException(banner + " is printed"); } } if (!testGeneratedInterrupt) { throw new RuntimeException("user has not executed the test"); } }
Example #4
Source File: UnixPrintJob.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private String[] printExecCmd(String printer, String options, boolean noJobSheet, String jobTitle, int copies, String spoolFile) { int PRINTER = 0x1; int OPTIONS = 0x2; int JOBTITLE = 0x4; int COPIES = 0x8; int NOSHEET = 0x10; int pFlags = 0; String execCmd[]; int ncomps = 2; // minimum number of print args int n = 0; // conveniently "lp" is the default destination for both lp and lpr. if (printer != null && !printer.equals("") && !printer.equals("lp")) { pFlags |= PRINTER; ncomps+=1; } if (options != null && !options.equals("")) { pFlags |= OPTIONS; ncomps+=1; } if (jobTitle != null && !jobTitle.equals("")) { pFlags |= JOBTITLE; ncomps+=1; } if (copies > 1) { pFlags |= COPIES; ncomps+=1; } if (noJobSheet) { pFlags |= NOSHEET; ncomps+=1; } else if (getPrintService(). isAttributeCategorySupported(JobSheets.class)) { ncomps+=1; } if (PrintServiceLookupProvider.osname.equals("SunOS")) { ncomps+=1; // lp uses 1 more arg than lpr (make a copy) execCmd = new String[ncomps]; execCmd[n++] = "/usr/bin/lp"; execCmd[n++] = "-c"; // make a copy of the spool file if ((pFlags & PRINTER) != 0) { execCmd[n++] = "-d" + printer; } if ((pFlags & JOBTITLE) != 0) { String quoteChar = "\""; execCmd[n++] = "-t " + quoteChar+jobTitle+quoteChar; } if ((pFlags & COPIES) != 0) { execCmd[n++] = "-n " + copies; } if ((pFlags & NOSHEET) != 0) { execCmd[n++] = "-o nobanner"; } else if (getPrintService(). isAttributeCategorySupported(JobSheets.class)) { execCmd[n++] = "-o job-sheets=standard"; } if ((pFlags & OPTIONS) != 0) { execCmd[n++] = "-o " + options; } } else { execCmd = new String[ncomps]; execCmd[n++] = "/usr/bin/lpr"; if ((pFlags & PRINTER) != 0) { execCmd[n++] = "-P" + printer; } if ((pFlags & JOBTITLE) != 0) { execCmd[n++] = "-J " + jobTitle; } if ((pFlags & COPIES) != 0) { execCmd[n++] = "-#" + copies; } if ((pFlags & NOSHEET) != 0) { execCmd[n++] = "-h"; } else if (getPrintService(). isAttributeCategorySupported(JobSheets.class)) { execCmd[n++] = "-o job-sheets=standard"; } if ((pFlags & OPTIONS) != 0) { execCmd[n++] = "-o" + options; } } execCmd[n++] = spoolFile; if (IPPPrintService.debugPrint) { System.out.println("UnixPrintJob>> execCmd"); for (int i=0; i<execCmd.length; i++) { System.out.print(" "+execCmd[i]); } System.out.println(); } return execCmd; }
Example #5
Source File: UnixPrintJob.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #6
Source File: UnixPrintJob.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #7
Source File: UnixPrintJob.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #8
Source File: UnixPrintJob.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #9
Source File: UnixPrintJob.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #10
Source File: UnixPrintJob.java From hottub with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #11
Source File: UnixPrintJob.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #12
Source File: UnixPrintJob.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #13
Source File: UnixPrintJob.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class<? extends Attribute> category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #14
Source File: PSPrinterJob.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private String[] printExecCmd(String printer, String options, boolean noJobSheet, String jobTitle, int copies, String spoolFile) { int PRINTER = 0x1; int OPTIONS = 0x2; int JOBTITLE = 0x4; int COPIES = 0x8; int NOSHEET = 0x10; int pFlags = 0; String execCmd[]; int ncomps = 2; // minimum number of print args int n = 0; if (printer != null && !printer.equals("") && !printer.equals("lp")) { pFlags |= PRINTER; ncomps+=1; } if (options != null && !options.equals("")) { pFlags |= OPTIONS; ncomps+=1; } if (jobTitle != null && !jobTitle.equals("")) { pFlags |= JOBTITLE; ncomps+=1; } if (copies > 1) { pFlags |= COPIES; ncomps+=1; } if (noJobSheet) { pFlags |= NOSHEET; ncomps+=1; } else if (getPrintService(). isAttributeCategorySupported(JobSheets.class)) { ncomps+=1; // for jobsheet } String osname = System.getProperty("os.name"); if (osname.equals("Linux") || osname.contains("OS X")) { execCmd = new String[ncomps]; execCmd[n++] = "/usr/bin/lpr"; if ((pFlags & PRINTER) != 0) { execCmd[n++] = "-P" + printer; } if ((pFlags & JOBTITLE) != 0) { execCmd[n++] = "-J" + jobTitle; } if ((pFlags & COPIES) != 0) { execCmd[n++] = "-#" + copies; } if ((pFlags & NOSHEET) != 0) { execCmd[n++] = "-h"; } else if (getPrintService(). isAttributeCategorySupported(JobSheets.class)) { execCmd[n++] = "-o job-sheets=standard"; } if ((pFlags & OPTIONS) != 0) { execCmd[n++] = "-o" + options; } } else { ncomps+=1; //add 1 arg for lp execCmd = new String[ncomps]; execCmd[n++] = "/usr/bin/lp"; execCmd[n++] = "-c"; // make a copy of the spool file if ((pFlags & PRINTER) != 0) { execCmd[n++] = "-d" + printer; } if ((pFlags & JOBTITLE) != 0) { execCmd[n++] = "-t" + jobTitle; } if ((pFlags & COPIES) != 0) { execCmd[n++] = "-n" + copies; } if ((pFlags & NOSHEET) != 0) { execCmd[n++] = "-o nobanner"; } else if (getPrintService(). isAttributeCategorySupported(JobSheets.class)) { execCmd[n++] = "-o job-sheets=standard"; } if ((pFlags & OPTIONS) != 0) { execCmd[n++] = "-o" + options; } } execCmd[n++] = spoolFile; return execCmd; }
Example #15
Source File: PSPrinterJob.java From Bytecoder with Apache License 2.0 | 4 votes |
private String[] printExecCmd(String printer, String options, boolean noJobSheet, String jobTitle, int copies, String spoolFile) { int PRINTER = 0x1; int OPTIONS = 0x2; int JOBTITLE = 0x4; int COPIES = 0x8; int NOSHEET = 0x10; int pFlags = 0; String[] execCmd; int ncomps = 2; // minimum number of print args int n = 0; if (printer != null && !printer.isEmpty() && !printer.equals("lp")) { pFlags |= PRINTER; ncomps+=1; } if (options != null && !options.isEmpty()) { pFlags |= OPTIONS; ncomps+=1; } if (jobTitle != null && !jobTitle.isEmpty()) { pFlags |= JOBTITLE; ncomps+=1; } if (copies > 1) { pFlags |= COPIES; ncomps+=1; } if (noJobSheet) { pFlags |= NOSHEET; ncomps+=1; } else if (getPrintService(). isAttributeCategorySupported(JobSheets.class)) { ncomps+=1; // for jobsheet } String osname = System.getProperty("os.name"); if (osname.equals("Linux") || osname.contains("OS X")) { execCmd = new String[ncomps]; execCmd[n++] = "/usr/bin/lpr"; if ((pFlags & PRINTER) != 0) { execCmd[n++] = "-P" + printer; } if ((pFlags & JOBTITLE) != 0) { execCmd[n++] = "-J" + jobTitle; } if ((pFlags & COPIES) != 0) { execCmd[n++] = "-#" + copies; } if ((pFlags & NOSHEET) != 0) { execCmd[n++] = "-h"; } else if (getPrintService(). isAttributeCategorySupported(JobSheets.class)) { execCmd[n++] = "-o job-sheets=standard"; } if ((pFlags & OPTIONS) != 0) { execCmd[n++] = "-o" + options; } } else { ncomps+=1; //add 1 arg for lp execCmd = new String[ncomps]; execCmd[n++] = "/usr/bin/lp"; execCmd[n++] = "-c"; // make a copy of the spool file if ((pFlags & PRINTER) != 0) { execCmd[n++] = "-d" + printer; } if ((pFlags & JOBTITLE) != 0) { execCmd[n++] = "-t" + jobTitle; } if ((pFlags & COPIES) != 0) { execCmd[n++] = "-n" + copies; } if ((pFlags & NOSHEET) != 0) { execCmd[n++] = "-o nobanner"; } else if (getPrintService(). isAttributeCategorySupported(JobSheets.class)) { execCmd[n++] = "-o job-sheets=standard"; } if ((pFlags & OPTIONS) != 0) { execCmd[n++] = "-o" + options; } } execCmd[n++] = spoolFile; return execCmd; }
Example #16
Source File: UnixPrintJob.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #17
Source File: UnixPrintJob.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #18
Source File: UnixPrintJob.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }
Example #19
Source File: UnixPrintJob.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private void getAttributeValues(DocFlavor flavor) throws PrintException { Attribute attr; Class category; if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) { fidelity = true; } else { fidelity = false; } Attribute []attrs = reqAttrSet.toArray(); for (int i=0; i<attrs.length; i++) { attr = attrs[i]; category = attr.getCategory(); if (fidelity == true) { if (!service.isAttributeCategorySupported(category)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported category: " + category, category, null); } else if (!service.isAttributeValueSupported(attr, flavor, null)) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintJobAttributeException( "unsupported attribute: " + attr, null, attr); } } if (category == Destination.class) { URI uri = ((Destination)attr).getURI(); if (!"file".equals(uri.getScheme())) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException("Not a file: URI"); } else { try { mDestType = DESTFILE; mDestination = (new File(uri)).getPath(); } catch (Exception e) { throw new PrintException(e); } // check write access SecurityManager security = System.getSecurityManager(); if (security != null) { try { security.checkWrite(mDestination); } catch (SecurityException se) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(se); } } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { mNoJobSheet = true; } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); } else if (category == Copies.class) { copies = ((Copies)attr).getValue(); } else if (category == Media.class) { if (attr instanceof MediaSizeName) { mediaName = (MediaSizeName)attr; IPPPrintService.debug_println(debugPrefix+ "mediaName "+mediaName); if (!service.isAttributeValueSupported(attr, null, null)) { mediaSize = MediaSize.getMediaSizeForName(mediaName); } } else if (attr instanceof CustomMediaTray) { customTray = (CustomMediaTray)attr; } } else if (category == OrientationRequested.class) { orient = (OrientationRequested)attr; } else if (category == NumberUp.class) { nUp = (NumberUp)attr; } else if (category == Sides.class) { sides = (Sides)attr; } } }