private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsAIX() { // On AIX there should not be a blank after '-a'. String command = "/usr/bin/lpstat -a" + printer; String results[]= UnixPrintServiceLookup.execCmd(command); // Remove headers and bogus entries added by remote printers. results = filterPrinterNamesAIX(results); if (results != null && results.length > 0) { for (int i = 0; i < results.length; i++) { if (results[i].contains("READY") || results[i].contains("RUNNING")) { return PrinterIsAcceptingJobs.ACCEPTING_JOBS; } } } return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS; }
public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) { if (category == null) { throw new NullPointerException("category"); } if (!(PrintServiceAttribute.class.isAssignableFrom(category))) { throw new IllegalArgumentException("Not a PrintServiceAttribute"); } if (category == PrinterName.class) { return (T)getPrinterName(); } else if (category == PrinterState.class) { return (T)getPrinterState(); } else if (category == PrinterStateReasons.class) { return (T)getPrinterStateReasons(); } else if (category == QueuedJobCount.class) { return (T)getQueuedJobCount(); } else if (category == PrinterIsAcceptingJobs.class) { return (T)getPrinterIsAcceptingJobs(); } else { return null; } }
public PrintServiceStub(String name) { _name = name; _flavors = new HashSet<DocFlavor>(); _flavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE); _flavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE); _attributes = new HashMap<>(); _attributes.put(PrinterName.class, new PrinterName(name, null)); _attributes.put(PrinterState.class, PrinterState.IDLE); _attributes.put(PrinterInfo.class, new PrinterInfo("Custom location", null)); _attributes.put(PrinterIsAcceptingJobs.class, PrinterIsAcceptingJobs.ACCEPTING_JOBS); _attributes.put(PrinterMakeAndModel.class, new PrinterMakeAndModel( "Custom printer", null)); _attributes.put(Media.class, new Media[] { MediaSizeName.ISO_A4 }); }
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsAIX() { // On AIX there should not be a blank after '-a'. String command = "/usr/bin/lpstat -a" + printer; String results[]= PrintServiceLookupProvider.execCmd(command); // Remove headers and bogus entries added by remote printers. results = filterPrinterNamesAIX(results); if (results != null && results.length > 0) { for (int i = 0; i < results.length; i++) { if (results[i].contains("READY") || results[i].contains("RUNNING")) { return PrinterIsAcceptingJobs.ACCEPTING_JOBS; } } } return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS; }
@SuppressWarnings("unchecked") public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) { if (category == null) { throw new NullPointerException("category"); } if (!(PrintServiceAttribute.class.isAssignableFrom(category))) { throw new IllegalArgumentException("Not a PrintServiceAttribute"); } if (category == PrinterName.class) { return (T)getPrinterName(); } else if (category == PrinterState.class) { return (T)getPrinterState(); } else if (category == PrinterStateReasons.class) { return (T)getPrinterStateReasons(); } else if (category == QueuedJobCount.class) { return (T)getQueuedJobCount(); } else if (category == PrinterIsAcceptingJobs.class) { return (T)getPrinterIsAcceptingJobs(); } else { return null; } }