javax.print.attribute.PrintServiceAttribute Java Examples

The following examples show how to use javax.print.attribute.PrintServiceAttribute. 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 openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #2
Source File: UnixPrintService.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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;
    }
}
 
Example #3
Source File: PSStreamPrintService.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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 == ColorSupported.class) {
        @SuppressWarnings("unchecked")
        T tmp = (T)ColorSupported.SUPPORTED;
        return tmp;
    } else {
        return null;
    }
}
 
Example #4
Source File: UnixPrintService.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #5
Source File: UnixPrintService.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #6
Source File: UnixPrintService.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #7
Source File: UnixPrintService.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #8
Source File: UnixPrintService.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #9
Source File: UnixPrintService.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #10
Source File: UnixPrintService.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #11
Source File: UnixPrintService.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #12
Source File: Win32PrintServiceLookup.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
boolean matchingService(PrintService service,
                        PrintServiceAttributeSet serviceSet) {
    if (serviceSet != null) {
        Attribute [] attrs =  serviceSet.toArray();
        Attribute serviceAttr;
        for (int i=0; i<attrs.length; i++) {
            serviceAttr
                = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
            if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
                return false;
            }
        }
    }
    return true;
}
 
Example #13
Source File: Win32PrintService.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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 == ColorSupported.class) {
        int caps = getPrinterCapabilities();
        if ((caps & DEVCAP_COLOR) != 0) {
            return (T)ColorSupported.SUPPORTED;
        } else {
            return (T)ColorSupported.NOT_SUPPORTED;
        }
    } else 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;
    }
}
 
Example #14
Source File: Win32PrintService.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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 == ColorSupported.class) {
        int caps = getPrinterCapabilities();
        if ((caps & DEVCAP_COLOR) != 0) {
            return (T)ColorSupported.SUPPORTED;
        } else {
            return (T)ColorSupported.NOT_SUPPORTED;
        }
    } else 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;
    }
}
 
Example #15
Source File: PSStreamPrintService.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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 == ColorSupported.class) {
        return (T)ColorSupported.SUPPORTED;
    } else {
        return null;
    }
}
 
Example #16
Source File: Win32PrintServiceLookup.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
boolean matchingService(PrintService service,
                        PrintServiceAttributeSet serviceSet) {
    if (serviceSet != null) {
        Attribute [] attrs =  serviceSet.toArray();
        Attribute serviceAttr;
        for (int i=0; i<attrs.length; i++) {
            serviceAttr
                = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
            if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
                return false;
            }
        }
    }
    return true;
}
 
Example #17
Source File: Win32PrintService.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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 == ColorSupported.class) {
        int caps = getPrinterCapabilities();
        if ((caps & DEVCAP_COLOR) != 0) {
            return (T)ColorSupported.SUPPORTED;
        } else {
            return (T)ColorSupported.NOT_SUPPORTED;
        }
    } else 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;
    }
}
 
Example #18
Source File: UnixPrintServiceLookup.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private boolean matchesAttributes(PrintService service,
                                  PrintServiceAttributeSet attributes) {

    Attribute [] attrs =  attributes.toArray();
    Attribute serviceAttr;
    for (int i=0; i<attrs.length; i++) {
        serviceAttr
            = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
        if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
            return false;
        }
    }
    return true;
}
 
Example #19
Source File: PrintServiceLookupProvider.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
boolean matchingService(PrintService service,
                        PrintServiceAttributeSet serviceSet) {
    if (serviceSet != null) {
        Attribute [] attrs =  serviceSet.toArray();
        Attribute serviceAttr;
        for (int i=0; i<attrs.length; i++) {
            serviceAttr
                = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
            if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
                return false;
            }
        }
    }
    return true;
}
 
Example #20
Source File: Win32PrintService.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 == ColorSupported.class) {
        int caps = getPrinterCapabilities();
        if ((caps & DEVCAP_COLOR) != 0) {
            return (T)ColorSupported.SUPPORTED;
        } else {
            return (T)ColorSupported.NOT_SUPPORTED;
        }
    } else 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;
    }
}
 
Example #21
Source File: UnixPrintServiceLookup.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private boolean matchesAttributes(PrintService service,
                                  PrintServiceAttributeSet attributes) {

    Attribute [] attrs =  attributes.toArray();
    Attribute serviceAttr;
    for (int i=0; i<attrs.length; i++) {
        serviceAttr
            = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
        if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
            return false;
        }
    }
    return true;
}
 
Example #22
Source File: UnixPrintServiceLookup.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean matchesAttributes(PrintService service,
                                  PrintServiceAttributeSet attributes) {

    Attribute [] attrs =  attributes.toArray();
    Attribute serviceAttr;
    for (int i=0; i<attrs.length; i++) {
        serviceAttr
            = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
        if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
            return false;
        }
    }
    return true;
}
 
Example #23
Source File: Win32PrintService.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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 == ColorSupported.class) {
        int caps = getPrinterCapabilities();
        if ((caps & DEVCAP_COLOR) != 0) {
            return (T)ColorSupported.SUPPORTED;
        } else {
            return (T)ColorSupported.NOT_SUPPORTED;
        }
    } else 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;
    }
}
 
Example #24
Source File: PrintServiceLookupProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private boolean matchesAttributes(PrintService service,
                                  PrintServiceAttributeSet attributes) {

    Attribute [] attrs =  attributes.toArray();
    for (int i=0; i<attrs.length; i++) {
        @SuppressWarnings("unchecked")
        Attribute serviceAttr
            = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
        if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
            return false;
        }
    }
    return true;
}
 
Example #25
Source File: Win32PrintServiceLookup.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
boolean matchingService(PrintService service,
                        PrintServiceAttributeSet serviceSet) {
    if (serviceSet != null) {
        Attribute [] attrs =  serviceSet.toArray();
        Attribute serviceAttr;
        for (int i=0; i<attrs.length; i++) {
            serviceAttr
                = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
            if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
                return false;
            }
        }
    }
    return true;
}
 
Example #26
Source File: PrintServiceLookupProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private boolean matchesAttributes(PrintService service,
                                  PrintServiceAttributeSet attributes) {

    Attribute [] attrs =  attributes.toArray();
    Attribute serviceAttr;
    for (int i=0; i<attrs.length; i++) {
        serviceAttr
            = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
        if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
            return false;
        }
    }
    return true;
}
 
Example #27
Source File: PSStreamPrintService.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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 == ColorSupported.class) {
        return (T)ColorSupported.SUPPORTED;
    } else {
        return null;
    }
}
 
Example #28
Source File: PSStreamPrintService.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 == ColorSupported.class) {
        return (T)ColorSupported.SUPPORTED;
    } else {
        return null;
    }
}
 
Example #29
Source File: Win32PrintServiceLookup.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
boolean matchingService(PrintService service,
                        PrintServiceAttributeSet serviceSet) {
    if (serviceSet != null) {
        Attribute [] attrs =  serviceSet.toArray();
        Attribute serviceAttr;
        for (int i=0; i<attrs.length; i++) {
            serviceAttr
                = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
            if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
                return false;
            }
        }
    }
    return true;
}
 
Example #30
Source File: UnixPrintServiceLookup.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private boolean matchesAttributes(PrintService service,
                                  PrintServiceAttributeSet attributes) {

    Attribute [] attrs =  attributes.toArray();
    Attribute serviceAttr;
    for (int i=0; i<attrs.length; i++) {
        serviceAttr
            = service.getAttribute((Class<PrintServiceAttribute>)attrs[i].getCategory());
        if (serviceAttr == null || !serviceAttr.equals(attrs[i])) {
            return false;
        }
    }
    return true;
}