当前位置: 首页>>代码示例>>Java>>正文


Java PrinterName.getValue方法代码示例

本文整理汇总了Java中javax.print.attribute.standard.PrinterName.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java PrinterName.getValue方法的具体用法?Java PrinterName.getValue怎么用?Java PrinterName.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.print.attribute.standard.PrinterName的用法示例。


在下文中一共展示了PrinterName.getValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import javax.print.attribute.standard.PrinterName; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
        String serviceName = service.getName();
        PrinterName name = service.getAttribute(PrinterName.class);
        String printerName = name.getValue();

        PrintService serviceByName = lookupByName(printerName);
        System.out.println("service " + service);
        System.out.println("serviceByName " + serviceByName);
        if (!service.equals(serviceByName)) {
            throw new RuntimeException("NOK " + serviceName
                               + " expected: " + service.getClass().getName()
                               + " got: " + serviceByName.getClass().getName());
        }
    }
    System.out.println("Test PASSED");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:GetPrintServices.java

示例2: getServiceByName

import javax.print.attribute.standard.PrinterName; //导入方法依赖的package包/类
private PrintService getServiceByName(PrinterName nameAttr) {
    String name = nameAttr.getValue();
    if (name == null || name.equals("") || !checkPrinterName(name)) {
        return null;
    }
    /* check if all printers are already available */
    if (printServices != null) {
        for (PrintService printService : printServices) {
            PrinterName printerName =
                (PrinterName)printService.getAttribute(PrinterName.class);
            if (printerName.getValue().equals(name)) {
                return printService;
            }
        }
    }
    /* take CUPS into account first */
    if (CUPSPrinter.isCupsRunning()) {
        try {
            return new IPPPrintService(name,
                                       new URL("http://"+
                                               CUPSPrinter.getServer()+":"+
                                               CUPSPrinter.getPort()+"/"+
                                               name));
        } catch (Exception e) {
            IPPPrintService.debug_println(debugPrefix+
                                          " getServiceByName Exception "+
                                          e);
        }
    }
    /* fallback if nothing not having a printer at this point */
    PrintService printer = null;
    if (isMac() || isSysV()) {
        printer = getNamedPrinterNameSysV(name);
    } else if (isAIX()) {
        printer = getNamedPrinterNameAIX(name);
    } else {
        printer = getNamedPrinterNameBSD(name);
    }
    return printer;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:UnixPrintServiceLookup.java

示例3: getServiceByName

import javax.print.attribute.standard.PrinterName; //导入方法依赖的package包/类
private PrintService getServiceByName(PrinterName nameAttr) {
    String name = nameAttr.getValue();
    if (name == null || name.equals("") || !checkPrinterName(name)) {
        return null;
    }
    /* check if all printers are already available */
    if (printServices != null) {
        for (PrintService printService : printServices) {
            PrinterName printerName = printService.getAttribute(PrinterName.class);
            if (printerName.getValue().equals(name)) {
                return printService;
            }
        }
    }
    /* take CUPS into account first */
    if (CUPSPrinter.isCupsRunning()) {
        try {
            return new IPPPrintService(name,
                                       new URL("http://"+
                                               CUPSPrinter.getServer()+":"+
                                               CUPSPrinter.getPort()+"/"+
                                               name));
        } catch (Exception e) {
            IPPPrintService.debug_println(debugPrefix+
                                          " getServiceByName Exception "+
                                          e);
        }
    }
    /* fallback if nothing not having a printer at this point */
    PrintService printer = null;
    if (isMac() || isSysV()) {
        printer = getNamedPrinterNameSysV(name);
    } else if (isAIX()) {
        printer = getNamedPrinterNameAIX(name);
    } else {
        printer = getNamedPrinterNameBSD(name);
    }
    return printer;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:PrintServiceLookupProvider.java

示例4: getServiceByName

import javax.print.attribute.standard.PrinterName; //导入方法依赖的package包/类
private PrintService getServiceByName(PrinterName nameAttr) {
    String name = nameAttr.getValue();
    PrintService printer = null;
    if (name == null || name.equals("") || !checkPrinterName(name)) {
        return null;
    }
    if (isSysV()) {
        printer = getNamedPrinterNameSysV(name);
    } else {
        printer = getNamedPrinterNameBSD(name);
    }
    return printer;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:14,代码来源:UnixPrintServiceLookup.java

示例5: getServiceByName

import javax.print.attribute.standard.PrinterName; //导入方法依赖的package包/类
private PrintService getServiceByName(PrinterName nameAttr) {
    String name = nameAttr.getValue();
    if (name == null || name.equals("") || !checkPrinterName(name)) {
        return null;
    }
    /* check if all printers are already available */
    if (printServices != null) {
        for (PrintService printService : printServices) {
            PrinterName printerName =
                (PrinterName)printService.getAttribute(PrinterName.class);
            if (printerName.getValue().equals(name)) {
                return printService;
            }
        }
    }
    /* take CUPS into account first */
    if (CUPSPrinter.isCupsRunning()) {
        try {
            return new IPPPrintService(name,
                                       new URL("http://"+
                                               CUPSPrinter.getServer()+":"+
                                               CUPSPrinter.getPort()+"/"+
                                               name));
        } catch (Exception e) {
            IPPPrintService.debug_println(debugPrefix+
                                          " getServiceByName Exception "+
                                          e);
        }
    }
    /* fallback if nothing not having a printer at this point */
    PrintService printer = null;
    if (isMac() || isSysV()) {
        printer = getNamedPrinterNameSysV(name);
    } else {
        printer = getNamedPrinterNameBSD(name);
    }
    return printer;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:39,代码来源:UnixPrintServiceLookup.java

示例6: getServiceByName

import javax.print.attribute.standard.PrinterName; //导入方法依赖的package包/类
private PrintService getServiceByName(PrinterName nameAttr) {
    String name = nameAttr.getValue();
    if (name == null || name.equals("") || !checkPrinterName(name)) {
        return null;
    }
    /* check is all printers are already available */
    if (printServices != null) {
        for (PrintService printService : printServices) {
            if (printService.getName().equals(name)) {
                return printService;
            }
        }
    }
    /* take CUPS into account first */
    if (CUPSPrinter.isCupsRunning()) {
        try {
            return new IPPPrintService(name,
                                       new URL("http://"+
                                               CUPSPrinter.getServer()+":"+
                                               CUPSPrinter.getPort()+"/"+
                                               name));
        } catch (Exception e) {
            IPPPrintService.debug_println(debugPrefix+
                                          " getServiceByName Exception "+
                                          e);
        }
    }
    /* fallback if nothing not having a printer at this point */
    PrintService printer = null;
    if (isMac() || isSysV()) {
        printer = getNamedPrinterNameSysV(name);
    } else {
        printer = getNamedPrinterNameBSD(name);
    }
    return printer;
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:37,代码来源:UnixPrintServiceLookup.java


注:本文中的javax.print.attribute.standard.PrinterName.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。