本文整理汇总了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");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}