本文整理汇总了Java中javax.print.attribute.standard.PrinterIsAcceptingJobs类的典型用法代码示例。如果您正苦于以下问题:Java PrinterIsAcceptingJobs类的具体用法?Java PrinterIsAcceptingJobs怎么用?Java PrinterIsAcceptingJobs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrinterIsAcceptingJobs类属于javax.print.attribute.standard包,在下文中一共展示了PrinterIsAcceptingJobs类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrinterIsAcceptingJobsSysV
import javax.print.attribute.standard.PrinterIsAcceptingJobs; //导入依赖的package包/类
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsSysV() {
String command = "/usr/bin/lpstat -a " + printer;
String results[]= UnixPrintServiceLookup.execCmd(command);
if (results != null && results.length > 0) {
if (results[0].startsWith(printer + " accepting requests")) {
return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
}
else if (results[0].startsWith(printer)) {
/* As well as "myprinter accepting requests", look for
* "[email protected] accepting requests".
*/
int index = printer.length();
String str = results[0];
if (str.length() > index &&
str.charAt(index) == '@' &&
str.indexOf(" accepting requests", index) > 0 &&
str.indexOf(" not accepting requests", index) == -1) {
return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
}
}
}
return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS ;
}
示例2: getPrinterIsAcceptingJobsAIX
import javax.print.attribute.standard.PrinterIsAcceptingJobs; //导入依赖的package包/类
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;
}
示例3: getAttribute
import javax.print.attribute.standard.PrinterIsAcceptingJobs; //导入依赖的package包/类
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;
}
}
示例4: PrintServiceStub
import javax.print.attribute.standard.PrinterIsAcceptingJobs; //导入依赖的package包/类
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 });
}
示例5: getPrinterIsAcceptingJobsSysV
import javax.print.attribute.standard.PrinterIsAcceptingJobs; //导入依赖的package包/类
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsSysV() {
String command = "/usr/bin/lpstat -a " + printer;
String results[]= PrintServiceLookupProvider.execCmd(command);
if (results != null && results.length > 0) {
if (results[0].startsWith(printer + " accepting requests")) {
return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
}
else if (results[0].startsWith(printer)) {
/* As well as "myprinter accepting requests", look for
* "[email protected] accepting requests".
*/
int index = printer.length();
String str = results[0];
if (str.length() > index &&
str.charAt(index) == '@' &&
str.indexOf(" accepting requests", index) > 0 &&
str.indexOf(" not accepting requests", index) == -1) {
return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
}
}
}
return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS ;
}
示例6: getPrinterIsAcceptingJobsAIX
import javax.print.attribute.standard.PrinterIsAcceptingJobs; //导入依赖的package包/类
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;
}
示例7: getAttribute
import javax.print.attribute.standard.PrinterIsAcceptingJobs; //导入依赖的package包/类
@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;
}
}