use of javax.print.attribute.HashPrintServiceAttributeSet in project jdk8u_jdk by JetBrains.
the class UnixPrintService method getSysVServiceAttributes.
private PrintServiceAttributeSet getSysVServiceAttributes() {
PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet();
attrs.add(getQueuedJobCountSysV());
attrs.add(getPrinterIsAcceptingJobsSysV());
return attrs;
}
use of javax.print.attribute.HashPrintServiceAttributeSet in project jdk8u_jdk by JetBrains.
the class UnixPrintServiceLookup method getPrintServices.
/*
* If service attributes are specified then there must be additional
* filtering.
*/
public PrintService[] getPrintServices(DocFlavor flavor, AttributeSet attributes) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPrintJobAccess();
}
PrintRequestAttributeSet requestSet = null;
PrintServiceAttributeSet serviceSet = null;
if (attributes != null && !attributes.isEmpty()) {
requestSet = new HashPrintRequestAttributeSet();
serviceSet = new HashPrintServiceAttributeSet();
Attribute[] attrs = attributes.toArray();
for (int i = 0; i < attrs.length; i++) {
if (attrs[i] instanceof PrintRequestAttribute) {
requestSet.add(attrs[i]);
} else if (attrs[i] instanceof PrintServiceAttribute) {
serviceSet.add(attrs[i]);
}
}
}
PrintService[] services = getPrintServices(serviceSet);
if (services.length == 0) {
return services;
}
if (CUPSPrinter.isCupsRunning()) {
ArrayList matchingServices = new ArrayList();
for (int i = 0; i < services.length; i++) {
try {
if (services[i].getUnsupportedAttributes(flavor, requestSet) == null) {
matchingServices.add(services[i]);
}
} catch (IllegalArgumentException e) {
}
}
services = new PrintService[matchingServices.size()];
return (PrintService[]) matchingServices.toArray(services);
} else {
// We only need to compare 1 PrintService because all
// UnixPrintServices are the same anyway. We will not use
// default PrintService because it might be null.
PrintService service = services[0];
if ((flavor == null || service.isDocFlavorSupported(flavor)) && service.getUnsupportedAttributes(flavor, requestSet) == null) {
return services;
} else {
return new PrintService[0];
}
}
}
Aggregations