Java Code Examples for javax.print.PrintService#getName()

The following examples show how to use javax.print.PrintService#getName() . 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: ServiceNotifier.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
ServiceNotifier(PrintService service) {
    super(service.getName() + " notifier");
    this.service = service;
    listeners = new Vector();
    try {
          setPriority(Thread.NORM_PRIORITY-1);
          setDaemon(true);
          start();
    } catch (SecurityException e) {
    }
}
 
Example 2
Source File: UnixPrintJob.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
UnixPrintJob(PrintService service) {
    this.service = service;
    mDestination = service.getName();
    if (UnixPrintServiceLookup.isMac()) {
        mDestination = ((IPPPrintService)service).getDest();
    }
    mDestType = UnixPrintJob.DESTPRINTER;
}
 
Example 3
Source File: ServiceNotifier.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
ServiceNotifier(PrintService service) {
    super(service.getName() + " notifier");
    this.service = service;
    listeners = new Vector();
    try {
          setPriority(Thread.NORM_PRIORITY-1);
          setDaemon(true);
          start();
    } catch (SecurityException e) {
    }
}
 
Example 4
Source File: ServiceNotifier.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
ServiceNotifier(PrintService service) {
    super(service.getName() + " notifier");
    this.service = service;
    listeners = new Vector();
    try {
          setPriority(Thread.NORM_PRIORITY-1);
          setDaemon(true);
          start();
    } catch (SecurityException e) {
    }
}
 
Example 5
Source File: RasterPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Associate this PrinterJob with a new PrintService.
 *
 * Throws <code>PrinterException</code> if the specified service
 * cannot support the <code>Pageable</code> and
 * <code>Printable</code> interfaces necessary to support 2D printing.
 * @param a print service which supports 2D printing.
 *
 * @throws PrinterException if the specified service does not support
 * 2D printing or no longer available.
 */
public void setPrintService(PrintService service)
    throws PrinterException {
    if (service == null) {
        throw new PrinterException("Service cannot be null");
    } else if (!(service instanceof StreamPrintService) &&
               service.getName() == null) {
        throw new PrinterException("Null PrintService name.");
    } else {
        // Check the list of services.  This service may have been
        // deleted already
        PrinterState prnState = (PrinterState)service.getAttribute(
                                              PrinterState.class);
        if (prnState == PrinterState.STOPPED) {
            PrinterStateReasons prnStateReasons =
                (PrinterStateReasons)service.getAttribute(
                                             PrinterStateReasons.class);
            if ((prnStateReasons != null) &&
                (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN)))
            {
                throw new PrinterException("PrintService is no longer available.");
            }
        }


        if (service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PAGEABLE) &&
            service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            myService = service;
        } else {
            throw new PrinterException("Not a 2D print service: " + service);
        }
    }
}
 
Example 6
Source File: RasterPrinterJob.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Associate this PrinterJob with a new PrintService.
 *
 * Throws <code>PrinterException</code> if the specified service
 * cannot support the <code>Pageable</code> and
 * <code>Printable</code> interfaces necessary to support 2D printing.
 * @param a print service which supports 2D printing.
 *
 * @throws PrinterException if the specified service does not support
 * 2D printing or no longer available.
 */
public void setPrintService(PrintService service)
    throws PrinterException {
    if (service == null) {
        throw new PrinterException("Service cannot be null");
    } else if (!(service instanceof StreamPrintService) &&
               service.getName() == null) {
        throw new PrinterException("Null PrintService name.");
    } else {
        // Check the list of services.  This service may have been
        // deleted already
        PrinterState prnState = (PrinterState)service.getAttribute(
                                              PrinterState.class);
        if (prnState == PrinterState.STOPPED) {
            PrinterStateReasons prnStateReasons =
                (PrinterStateReasons)service.getAttribute(
                                             PrinterStateReasons.class);
            if ((prnStateReasons != null) &&
                (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN)))
            {
                throw new PrinterException("PrintService is no longer available.");
            }
        }


        if (service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PAGEABLE) &&
            service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            myService = service;
        } else {
            throw new PrinterException("Not a 2D print service: " + service);
        }
    }
}
 
Example 7
Source File: ServiceNotifier.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
ServiceNotifier(PrintService service) {
    super(service.getName() + " notifier");
    this.service = service;
    listeners = new Vector();
    try {
          setPriority(Thread.NORM_PRIORITY-1);
          setDaemon(true);
          start();
    } catch (SecurityException e) {
    }
}
 
Example 8
Source File: UnixPrintJob.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
UnixPrintJob(PrintService service) {
    this.service = service;
    mDestination = service.getName();
    if (UnixPrintServiceLookup.isMac()) {
        mDestination = ((IPPPrintService)service).getDest();
    }
    mDestType = UnixPrintJob.DESTPRINTER;
}
 
Example 9
Source File: ServiceNotifier.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
ServiceNotifier(PrintService service) {
    super(null, null, service.getName() + " notifier", 0, false);
    this.service = service;
    listeners = new Vector<>();
    try {
          setPriority(Thread.NORM_PRIORITY-1);
          setDaemon(true);
          start();
    } catch (SecurityException e) {
    }
}
 
Example 10
Source File: RasterPrinterJob.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Associate this PrinterJob with a new PrintService.
 *
 * Throws <code>PrinterException</code> if the specified service
 * cannot support the <code>Pageable</code> and
 * <code>Printable</code> interfaces necessary to support 2D printing.
 * @param a print service which supports 2D printing.
 *
 * @throws PrinterException if the specified service does not support
 * 2D printing or no longer available.
 */
public void setPrintService(PrintService service)
    throws PrinterException {
    if (service == null) {
        throw new PrinterException("Service cannot be null");
    } else if (!(service instanceof StreamPrintService) &&
               service.getName() == null) {
        throw new PrinterException("Null PrintService name.");
    } else {
        // Check the list of services.  This service may have been
        // deleted already
        PrinterState prnState = (PrinterState)service.getAttribute(
                                              PrinterState.class);
        if (prnState == PrinterState.STOPPED) {
            PrinterStateReasons prnStateReasons =
                (PrinterStateReasons)service.getAttribute(
                                             PrinterStateReasons.class);
            if ((prnStateReasons != null) &&
                (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN)))
            {
                throw new PrinterException("PrintService is no longer available.");
            }
        }


        if (service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PAGEABLE) &&
            service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            myService = service;
        } else {
            throw new PrinterException("Not a 2D print service: " + service);
        }
    }
}
 
Example 11
Source File: PSPrinterJob.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invoked by the RasterPrintJob super class
 * this method is called after that last page
 * has been imaged.
 */
protected void endDoc() throws PrinterException {
    if (mPSStream != null) {
        mPSStream.println(EOF_COMMENT);
        mPSStream.flush();
        if (mDestType != RasterPrinterJob.STREAM) {
            mPSStream.close();
        }
    }
    if (mDestType == RasterPrinterJob.PRINTER) {
        PrintService pServ = getPrintService();
        if (pServ != null) {
            mDestination = pServ.getName();
           if (isMac) {
                PrintServiceAttributeSet psaSet = pServ.getAttributes();
                if (psaSet != null) {
                    mDestination = psaSet.get(PrinterName.class).toString() ;
                }
            }
        }
        PrinterSpooler spooler = new PrinterSpooler();
        java.security.AccessController.doPrivileged(spooler);
        if (spooler.pex != null) {
            throw spooler.pex;
        }
    }
}
 
Example 12
Source File: RasterPrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Associate this PrinterJob with a new PrintService.
 *
 * Throws <code>PrinterException</code> if the specified service
 * cannot support the <code>Pageable</code> and
 * <code>Printable</code> interfaces necessary to support 2D printing.
 * @param a print service which supports 2D printing.
 *
 * @throws PrinterException if the specified service does not support
 * 2D printing or no longer available.
 */
public void setPrintService(PrintService service)
    throws PrinterException {
    if (service == null) {
        throw new PrinterException("Service cannot be null");
    } else if (!(service instanceof StreamPrintService) &&
               service.getName() == null) {
        throw new PrinterException("Null PrintService name.");
    } else {
        // Check the list of services.  This service may have been
        // deleted already
        PrinterState prnState = (PrinterState)service.getAttribute(
                                              PrinterState.class);
        if (prnState == PrinterState.STOPPED) {
            PrinterStateReasons prnStateReasons =
                (PrinterStateReasons)service.getAttribute(
                                             PrinterStateReasons.class);
            if ((prnStateReasons != null) &&
                (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN)))
            {
                throw new PrinterException("PrintService is no longer available.");
            }
        }


        if (service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PAGEABLE) &&
            service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            myService = service;
        } else {
            throw new PrinterException("Not a 2D print service: " + service);
        }
    }
}
 
Example 13
Source File: GetPrintServices.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
    String serviceName = service.getName();
    PrintService serviceByName = lookupByName(serviceName);
    if (!service.equals(serviceByName)) {
      throw new RuntimeException("NOK " + serviceName
                                 + " expected: " + service.getClass().getName()
                                 + " got: " + serviceByName.getClass().getName());
    }
  }
  System.out.println("Test PASSED");
}
 
Example 14
Source File: UnixPrintJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
UnixPrintJob(PrintService service) {
    this.service = service;
    mDestination = service.getName();
    if (UnixPrintServiceLookup.isMac()) {
        mDestination = ((IPPPrintService)service).getDest();
    }
    mDestType = UnixPrintJob.DESTPRINTER;
}
 
Example 15
Source File: WPrinterJob.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private final String getPrinterAttrib() {
    // getPrintService will get current print service or default if none
    PrintService service = this.getPrintService();
    String name = (service != null) ? service.getName() : null;
    return name;
}
 
Example 16
Source File: WPrinterJob.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private final String getPrinterAttrib() {
    // getPrintService will get current print service or default if none
    PrintService service = this.getPrintService();
    String name = (service != null) ? service.getName() : null;
    return name;
}
 
Example 17
Source File: PrintServiceLookupProvider.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private String getPrinterDestName(PrintService ps) {
    if (isMac()) {
        return ((IPPPrintService)ps).getDest();
    }
    return ps.getName();
}
 
Example 18
Source File: WPrinterJob.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private final String getPrinterAttrib() {
    // getPrintService will get current print service or default if none
    PrintService service = this.getPrintService();
    String name = (service != null) ? service.getName() : null;
    return name;
}
 
Example 19
Source File: WPrinterJob.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private final String getPrinterAttrib() {
    // getPrintService will get current print service or default if none
    PrintService service = this.getPrintService();
    String name = (service != null) ? service.getName() : null;
    return name;
}
 
Example 20
Source File: WPrinterJob.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private final String getPrinterAttrib() {
    // getPrintService will get current print service or default if none
    PrintService service = this.getPrintService();
    String name = (service != null) ? service.getName() : null;
    return name;
}