Search in sources :

Example 1 with HashAttributeSet

use of javax.print.attribute.HashAttributeSet in project jdk8u_jdk by JetBrains.

the class Win32MediaSize method getUnsupportedAttributes.

public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes) {
    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("flavor " + flavor + "is not supported");
    }
    if (attributes == null) {
        return null;
    }
    Attribute attr;
    AttributeSet unsupp = new HashAttributeSet();
    Attribute[] attrs = attributes.toArray();
    for (int i = 0; i < attrs.length; i++) {
        try {
            attr = attrs[i];
            if (!isAttributeCategorySupported(attr.getCategory())) {
                unsupp.add(attr);
            } else if (!isAttributeValueSupported(attr, flavor, attributes)) {
                unsupp.add(attr);
            }
        } catch (ClassCastException e) {
        }
    }
    if (unsupp.isEmpty()) {
        return null;
    } else {
        return unsupp;
    }
}
Also used : PrintServiceAttribute(javax.print.attribute.PrintServiceAttribute) Attribute(javax.print.attribute.Attribute) AttributeSet(javax.print.attribute.AttributeSet) PrintServiceAttributeSet(javax.print.attribute.PrintServiceAttributeSet) PrintRequestAttributeSet(javax.print.attribute.PrintRequestAttributeSet) HashAttributeSet(javax.print.attribute.HashAttributeSet) HashPrintServiceAttributeSet(javax.print.attribute.HashPrintServiceAttributeSet) HashAttributeSet(javax.print.attribute.HashAttributeSet)

Example 2 with HashAttributeSet

use of javax.print.attribute.HashAttributeSet in project jdk8u_jdk by JetBrains.

the class PSStreamPrintService method getUnsupportedAttributes.

public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes) {
    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("flavor " + flavor + "is not supported");
    }
    if (attributes == null) {
        return null;
    }
    Attribute attr;
    AttributeSet unsupp = new HashAttributeSet();
    Attribute[] attrs = attributes.toArray();
    for (int i = 0; i < attrs.length; i++) {
        try {
            attr = attrs[i];
            if (!isAttributeCategorySupported(attr.getCategory())) {
                unsupp.add(attr);
            } else if (!isAttributeValueSupported(attr, flavor, attributes)) {
                unsupp.add(attr);
            }
        } catch (ClassCastException e) {
        }
    }
    if (unsupp.isEmpty()) {
        return null;
    } else {
        return unsupp;
    }
}
Also used : PrintServiceAttribute(javax.print.attribute.PrintServiceAttribute) Attribute(javax.print.attribute.Attribute) AttributeSet(javax.print.attribute.AttributeSet) PrintServiceAttributeSet(javax.print.attribute.PrintServiceAttributeSet) HashAttributeSet(javax.print.attribute.HashAttributeSet) HashPrintServiceAttributeSet(javax.print.attribute.HashPrintServiceAttributeSet) HashAttributeSet(javax.print.attribute.HashAttributeSet)

Example 3 with HashAttributeSet

use of javax.print.attribute.HashAttributeSet in project jdk8u_jdk by JetBrains.

the class UnixPrintService method getUnsupportedAttributes.

public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes) {
    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("flavor " + flavor + "is not supported");
    }
    if (attributes == null) {
        return null;
    }
    Attribute attr;
    AttributeSet unsupp = new HashAttributeSet();
    Attribute[] attrs = attributes.toArray();
    for (int i = 0; i < attrs.length; i++) {
        try {
            attr = attrs[i];
            if (!isAttributeCategorySupported(attr.getCategory())) {
                unsupp.add(attr);
            } else if (!isAttributeValueSupported(attr, flavor, attributes)) {
                unsupp.add(attr);
            }
        } catch (ClassCastException e) {
        }
    }
    if (unsupp.isEmpty()) {
        return null;
    } else {
        return unsupp;
    }
}
Also used : PrintServiceAttribute(javax.print.attribute.PrintServiceAttribute) Attribute(javax.print.attribute.Attribute) AttributeSet(javax.print.attribute.AttributeSet) PrintServiceAttributeSet(javax.print.attribute.PrintServiceAttributeSet) HashAttributeSet(javax.print.attribute.HashAttributeSet) HashPrintServiceAttributeSet(javax.print.attribute.HashPrintServiceAttributeSet) HashAttributeSet(javax.print.attribute.HashAttributeSet)

Example 4 with HashAttributeSet

use of javax.print.attribute.HashAttributeSet in project jdk8u_jdk by JetBrains.

the class GetPrintServices method lookupByName.

private static PrintService lookupByName(String name) {
    AttributeSet attributes = new HashAttributeSet();
    attributes.add(new PrinterName(name, null));
    for (PrintService service : PrintServiceLookup.lookupPrintServices(null, attributes)) {
        return service;
    }
    return null;
}
Also used : PrinterName(javax.print.attribute.standard.PrinterName) AttributeSet(javax.print.attribute.AttributeSet) HashAttributeSet(javax.print.attribute.HashAttributeSet) HashAttributeSet(javax.print.attribute.HashAttributeSet) PrintService(javax.print.PrintService)

Aggregations

AttributeSet (javax.print.attribute.AttributeSet)4 HashAttributeSet (javax.print.attribute.HashAttributeSet)4 Attribute (javax.print.attribute.Attribute)3 HashPrintServiceAttributeSet (javax.print.attribute.HashPrintServiceAttributeSet)3 PrintServiceAttribute (javax.print.attribute.PrintServiceAttribute)3 PrintServiceAttributeSet (javax.print.attribute.PrintServiceAttributeSet)3 PrintService (javax.print.PrintService)1 PrintRequestAttributeSet (javax.print.attribute.PrintRequestAttributeSet)1 PrinterName (javax.print.attribute.standard.PrinterName)1