本文整理汇总了Java中javax.print.attribute.PrintServiceAttributeSet.get方法的典型用法代码示例。如果您正苦于以下问题:Java PrintServiceAttributeSet.get方法的具体用法?Java PrintServiceAttributeSet.get怎么用?Java PrintServiceAttributeSet.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.print.attribute.PrintServiceAttributeSet
的用法示例。
在下文中一共展示了PrintServiceAttributeSet.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttribute
import javax.print.attribute.PrintServiceAttributeSet; //导入方法依赖的package包/类
public PrintServiceAttribute getAttribute(Class category) {
if (!PrintServiceAttribute.class.isAssignableFrom(category)) {
throw new IllegalArgumentException();
}
PrintServiceAttributeSet attributes = getAttributes();
if (attributes.containsKey(category)) {
PrintServiceAttribute attribute = (PrintServiceAttribute) attributes
.get(category);
return attribute;
}
return null;
}
示例2: getPrintServices
import javax.print.attribute.PrintServiceAttributeSet; //导入方法依赖的package包/类
private PrintService[]
getPrintServices(PrintServiceAttributeSet serviceSet) {
if (serviceSet == null || serviceSet.isEmpty()) {
return getPrintServices();
}
/* Typically expect that if a service attribute is specified that
* its a printer name and there ought to be only one match.
* Directly retrieve that service and confirm
* that it meets the other requirements.
* If printer name isn't mentioned then go a slow path checking
* all printers if they meet the reqiremements.
*/
PrintService[] services;
PrinterName name = (PrinterName)serviceSet.get(PrinterName.class);
PrintService defService;
if (name != null && (defService = getDefaultPrintService()) != null) {
/* To avoid execing a unix command see if the client is asking
* for the default printer by name, since we already have that
* initialised.
*/
PrinterName defName =
(PrinterName)defService.getAttribute(PrinterName.class);
if (defName != null && name.equals(defName)) {
if (matchesAttributes(defService, serviceSet)) {
services = new PrintService[1];
services[0] = defService;
return services;
} else {
return new PrintService[0];
}
} else {
/* Its not the default service */
PrintService service = getServiceByName(name);
if (service != null &&
matchesAttributes(service, serviceSet)) {
services = new PrintService[1];
services[0] = service;
return services;
} else {
return new PrintService[0];
}
}
} else {
/* specified service attributes don't include a name.*/
Vector matchedServices = new Vector();
services = getPrintServices();
for (int i = 0; i< services.length; i++) {
if (matchesAttributes(services[i], serviceSet)) {
matchedServices.add(services[i]);
}
}
services = new PrintService[matchedServices.size()];
for (int i = 0; i< services.length; i++) {
services[i] = (PrintService)matchedServices.elementAt(i);
}
return services;
}
}
示例3: getPrintServices
import javax.print.attribute.PrintServiceAttributeSet; //导入方法依赖的package包/类
private PrintService[]
getPrintServices(PrintServiceAttributeSet serviceSet) {
if (serviceSet == null || serviceSet.isEmpty()) {
return getPrintServices();
}
/* Typically expect that if a service attribute is specified that
* its a printer name and there ought to be only one match.
* Directly retrieve that service and confirm
* that it meets the other requirements.
* If printer name isn't mentioned then go a slow path checking
* all printers if they meet the reqiremements.
*/
PrintService[] services;
PrinterName name = (PrinterName)serviceSet.get(PrinterName.class);
PrintService defService;
if (name != null && (defService = getDefaultPrintService()) != null) {
/* To avoid execing a unix command see if the client is asking
* for the default printer by name, since we already have that
* initialised.
*/
PrinterName defName = defService.getAttribute(PrinterName.class);
if (defName != null && name.equals(defName)) {
if (matchesAttributes(defService, serviceSet)) {
services = new PrintService[1];
services[0] = defService;
return services;
} else {
return new PrintService[0];
}
} else {
/* Its not the default service */
PrintService service = getServiceByName(name);
if (service != null &&
matchesAttributes(service, serviceSet)) {
services = new PrintService[1];
services[0] = service;
return services;
} else {
return new PrintService[0];
}
}
} else {
/* specified service attributes don't include a name.*/
Vector<PrintService> matchedServices = new Vector<>();
services = getPrintServices();
for (int i = 0; i< services.length; i++) {
if (matchesAttributes(services[i], serviceSet)) {
matchedServices.add(services[i]);
}
}
services = new PrintService[matchedServices.size()];
for (int i = 0; i< services.length; i++) {
services[i] = matchedServices.elementAt(i);
}
return services;
}
}