Example usage for javax.print PrintService getName

List of usage examples for javax.print PrintService getName

Introduction

In this page you can find the example usage for javax.print PrintService getName.

Prototype

public String getName();

Source Link

Document

Returns a string name for this print service which may be used by applications to request a particular print service.

Usage

From source file:org.springframework.integration.print.core.PrintServiceExecutor.java

public PrintServiceExecutor(String printerName) {

    if (!StringUtils.hasText(printerName)) {
        this.printService = PrintServiceLookup.lookupDefaultPrintService();
        Assert.notNull(this.printService, "Did not find a the default print service.");
    } else {//from  www  .java2s . c  o m
        PrintService matchingPrintService = null;

        for (PrintService printService : PrintServiceExecutor.getAvailablePrinterServices()) {
            if (printerName.equalsIgnoreCase(printService.getName())) {
                matchingPrintService = printService;
                break;
            }
        }

        this.printService = matchingPrintService;

        Assert.notNull(this.printService,
                String.format("Did not find the" + "print service for printer '%s'.", printerName));
    }

    if (logger.isInfoEnabled()) {
        logger.info("Setting up print service for printer '" + this.printService.getName() + "'.");
    } else if (logger.isDebugEnabled()) {
        logger.debug(this.getPrinterInfo());
    }

}