Java Code Examples for javax.print.attribute.standard.PrinterIsAcceptingJobs#ACCEPTING_JOBS

The following examples show how to use javax.print.attribute.standard.PrinterIsAcceptingJobs#ACCEPTING_JOBS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnixPrintService.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;

}
 
Example 2
Source File: UnixPrintService.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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
             * "myprinter@somehost 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 ;
}
 
Example 3
Source File: UnixPrintService.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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
             * "myprinter@somehost 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 ;
}
 
Example 4
Source File: UnixPrintService.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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
             * "myprinter@somehost 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 ;
}
 
Example 5
Source File: UnixPrintService.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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
             * "myprinter@somehost 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 ;
}
 
Example 6
Source File: UnixPrintService.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;

}
 
Example 7
Source File: UnixPrintService.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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
             * "myprinter@somehost 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 ;
}
 
Example 8
Source File: UnixPrintService.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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
             * "myprinter@somehost 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 ;
}
 
Example 9
Source File: UnixPrintService.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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
             * "myprinter@somehost 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 ;
}
 
Example 10
Source File: UnixPrintService.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;

}
 
Example 11
Source File: Win32PrintService.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
    if (getJobStatus(printer, 2) != 1) {
        return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS;
    }
    else {
        return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
    }
}
 
Example 12
Source File: UnixPrintService.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
    if (PrintServiceLookupProvider.isSysV()) {
        return getPrinterIsAcceptingJobsSysV();
    } else if (PrintServiceLookupProvider.isBSD()) {
        return getPrinterIsAcceptingJobsBSD();
    } else if (PrintServiceLookupProvider.isAIX()) {
        return getPrinterIsAcceptingJobsAIX();
    } else {
        return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
    }
}
 
Example 13
Source File: UnixPrintService.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsBSD() {
    if (PrintServiceLookupProvider.cmdIndex ==
        PrintServiceLookupProvider.UNINITIALIZED) {

        PrintServiceLookupProvider.cmdIndex =
            PrintServiceLookupProvider.getBSDCommandIndex();
    }

    String command = "/usr/sbin/lpc status " + printer
        + lpcStatusCom[PrintServiceLookupProvider.cmdIndex];
    String results[]= PrintServiceLookupProvider.execCmd(command);

    if (results != null && results.length > 0) {
        if (PrintServiceLookupProvider.cmdIndex ==
            PrintServiceLookupProvider.BSD_LPD_NG) {
            if (results[0].startsWith("enabled enabled")) {
                return PrinterIsAcceptingJobs.ACCEPTING_JOBS ;
            }
        } else {
            if ((results[1].trim().startsWith("queuing is enabled") &&
                results[2].trim().startsWith("printing is enabled")) ||
                (results.length >= 4 &&
                 results[2].trim().startsWith("queuing is enabled") &&
                 results[3].trim().startsWith("printing is enabled"))) {
                return PrinterIsAcceptingJobs.ACCEPTING_JOBS ;
            }
        }
    }
    return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS ;
}
 
Example 14
Source File: UnixPrintService.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
    if (PrintServiceLookupProvider.isSysV()) {
        return getPrinterIsAcceptingJobsSysV();
    } else if (PrintServiceLookupProvider.isBSD()) {
        return getPrinterIsAcceptingJobsBSD();
    } else if (PrintServiceLookupProvider.isAIX()) {
        return getPrinterIsAcceptingJobsAIX();
    } else {
        return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
    }
}
 
Example 15
Source File: UnixPrintService.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
    if (UnixPrintServiceLookup.isSysV()) {
        return getPrinterIsAcceptingJobsSysV();
    } else if (UnixPrintServiceLookup.isBSD()) {
        return getPrinterIsAcceptingJobsBSD();
    } else if (UnixPrintServiceLookup.isAIX()) {
        return getPrinterIsAcceptingJobsAIX();
    } else {
        return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
    }
}
 
Example 16
Source File: UnixPrintService.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobsBSD() {
    if (UnixPrintServiceLookup.cmdIndex ==
        UnixPrintServiceLookup.UNINITIALIZED) {

        UnixPrintServiceLookup.cmdIndex =
            UnixPrintServiceLookup.getBSDCommandIndex();
    }

    String command = "/usr/sbin/lpc status " + printer
        + lpcStatusCom[UnixPrintServiceLookup.cmdIndex];
    String results[]= UnixPrintServiceLookup.execCmd(command);

    if (results != null && results.length > 0) {
        if (UnixPrintServiceLookup.cmdIndex ==
            UnixPrintServiceLookup.BSD_LPD_NG) {
            if (results[0].startsWith("enabled enabled")) {
                return PrinterIsAcceptingJobs.ACCEPTING_JOBS ;
            }
        } else {
            if ((results[1].trim().startsWith("queuing is enabled") &&
                results[2].trim().startsWith("printing is enabled")) ||
                (results.length >= 4 &&
                 results[2].trim().startsWith("queuing is enabled") &&
                 results[3].trim().startsWith("printing is enabled"))) {
                return PrinterIsAcceptingJobs.ACCEPTING_JOBS ;
            }
        }
    }
    return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS ;
}
 
Example 17
Source File: Win32PrintService.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
    if (getJobStatus(printer, 2) != 1) {
        return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS;
    }
    else {
        return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
    }
}
 
Example 18
Source File: UnixPrintService.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
    if (UnixPrintServiceLookup.isSysV()) {
        return getPrinterIsAcceptingJobsSysV();
    } else if (UnixPrintServiceLookup.isBSD()) {
        return getPrinterIsAcceptingJobsBSD();
    } else if (UnixPrintServiceLookup.isAIX()) {
        return getPrinterIsAcceptingJobsAIX();
    } else {
        return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
    }
}
 
Example 19
Source File: Win32PrintService.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
    if (getJobStatus(printer, 2) != 1) {
        return PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS;
    }
    else {
        return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
    }
}
 
Example 20
Source File: UnixPrintService.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private PrinterIsAcceptingJobs getPrinterIsAcceptingJobs() {
    if (PrintServiceLookupProvider.isSysV()) {
        return getPrinterIsAcceptingJobsSysV();
    } else if (PrintServiceLookupProvider.isBSD()) {
        return getPrinterIsAcceptingJobsBSD();
    } else if (PrintServiceLookupProvider.isAIX()) {
        return getPrinterIsAcceptingJobsAIX();
    } else {
        return PrinterIsAcceptingJobs.ACCEPTING_JOBS;
    }
}