Java 类javax.print.attribute.AttributeSet 实例源码

项目:javify    文件:PrintServiceLookup.java   
/**
 * Searches print services capable of printing in the given document flavor
 * which supports the specified printing attributes.
 *
 * @param flavor the document flavor to support. If <code>null</code> this
 * constraint is ignored during lookup.
 * @param attributes the printing attributes to support. If
 * <code>null</code> this constraint is ignored during lookup.
 * @return The resulting available print services, or an array of length 0
 * if none is found.
 */
public static final PrintService[] lookupPrintServices(DocFlavor flavor,
  AttributeSet attributes)
{
  ArrayList result = new ArrayList();

  PrintService[] services =
    systemProvider.getPrintServices(flavor, attributes);
  result.addAll(Arrays.asList(services));

  for (Iterator it = printServiceLookups.iterator(); it.hasNext(); )
    {
      PrintServiceLookup lookup = (PrintServiceLookup) it.next();
      services = lookup.getPrintServices(flavor, attributes);
      result.addAll(Arrays.asList(services));
    }

  for (Iterator it = printServices.iterator(); it.hasNext(); )
    {
      PrintService service = (PrintService) it.next();
      if (systemProvider.checkPrintService(flavor, attributes, service))
        result.add(service);
    }

  return (PrintService[]) result.toArray(new PrintService[result.size()]);
}
项目:javify    文件:CupsPrintServiceLookup.java   
/**
* All printers and printer classes of the CUPS server are checked.
* If flavors or attributes are null the constraint is not used.
*
* @param flavors the document flavors which have to be supported.
* @param attributes the attributes which have to be supported.
*
* @return The multidoc print services of the implementing lookup service
* for the given parameters, or an array of length 0 if none is available.
*/
public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors,
    AttributeSet attributes)
{
  ArrayList result = new ArrayList();
  PrintService[] services = getPrintServices();

  for (int i=0; i < services.length; i++)
    {
      if (checkMultiDocPrintService(flavors, attributes, services[i]))
        result.add(services[i]);
    }

  return (MultiDocPrintService[]) result.toArray(
    new MultiDocPrintService[result.size()]);
}
项目:javify    文件:CupsPrintServiceLookup.java   
/**
 * Checks the given print service - own method so it can be used also
 * to check application registered print services from PrintServiceLookup.
 *
 * @param flavor the document flavor which has to be supported.
 * @param attributes the attributes which have to be supported.
 * @param service the service to check
 *
 * @return <code>true</code> if all constraints match, <code>false</code>
 * otherwise.
 */
public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes,
  PrintService service)
{
  boolean allAttributesSupported = true;
  if (flavor == null || service.isDocFlavorSupported(flavor))
    {
      if (attributes == null || attributes.size() == 0)
        return allAttributesSupported;

      Attribute[] atts = attributes.toArray();
      for (int i = 0; i < atts.length; i++)
        {
          if (! service.isAttributeCategorySupported(atts[i].getCategory()))
            {
              allAttributesSupported = false;
              break;
            }
        }
      return allAttributesSupported;
    }

  return false;
}
项目:jvm-stm    文件:PrintServiceLookup.java   
/**
 * Searches print services capable of printing in the given document flavor
 * which supports the specified printing attributes.
 * 
 * @param flavor the document flavor to support. If <code>null</code> this 
 * constraint is ignored during lookup.
 * @param attributes the printing attributes to support. If 
 * <code>null</code> this constraint is ignored during lookup.
 * @return The resulting available print services, or an array of length 0 
 * if none is found. 
 */
public static final PrintService[] lookupPrintServices(DocFlavor flavor,
  AttributeSet attributes)
{   
  ArrayList result = new ArrayList();

  PrintService[] services = 
    systemProvider.getPrintServices(flavor, attributes);    
  result.addAll(Arrays.asList(services));

  for (Iterator it = printServiceLookups.iterator(); it.hasNext(); )
    {
      PrintServiceLookup lookup = (PrintServiceLookup) it.next();
      services = lookup.getPrintServices(flavor, attributes);   
      result.addAll(Arrays.asList(services));
    }

  for (Iterator it = printServices.iterator(); it.hasNext(); )
    {
      PrintService service = (PrintService) it.next();
      if (systemProvider.checkPrintService(flavor, attributes, service)) 
        result.add(service);
    }

  return (PrintService[]) result.toArray(new PrintService[result.size()]);
}
项目:jvm-stm    文件:CupsPrintServiceLookup.java   
/**
* All printers and printer classes of the CUPS server are checked.
* If flavors or attributes are null the constraint is not used.
* 
* @param flavors the document flavors which have to be supported.
* @param attributes the attributes which have to be supported.
* 
* @return The multidoc print services of the implementing lookup service
* for the given parameters, or an array of length 0 if none is available.
*/
public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors,
    AttributeSet attributes)
{
  ArrayList result = new ArrayList();
  PrintService[] services = getPrintServices();   

  for (int i=0; i < services.length; i++)
    {
      if (checkMultiDocPrintService(flavors, attributes, services[i]))
        result.add(services[i]);  
    }

  return (MultiDocPrintService[]) result.toArray(
    new MultiDocPrintService[result.size()]);
}
项目:jvm-stm    文件:CupsPrintServiceLookup.java   
/**
 * Checks the given print service - own method so it can be used also
 * to check application registered print services from PrintServiceLookup.
 * 
 * @param flavor the document flavor which has to be supported.
 * @param attributes the attributes which have to be supported.
 * @param service the service to check
 * 
 * @return <code>true</code> if all constraints match, <code>false</code> 
 * otherwise.
 */
public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes,
  PrintService service)
{
  boolean allAttributesSupported = true;
  if (flavor == null || service.isDocFlavorSupported(flavor))
    {
      if (attributes == null || attributes.size() == 0)
        return allAttributesSupported;

      Attribute[] atts = attributes.toArray();
      for (int i = 0; i < atts.length; i++)
        {
          if (! service.isAttributeCategorySupported(atts[i].getCategory()))
            {
              allAttributesSupported = false;
              break;
            }
        }
      return allAttributesSupported;
    }

  return false;
}
项目:lixia-javardp    文件:Printer.java   
@Override
public void create(String filename) {
    // find the printing service
    //http://www.coderanch.com/t/385989/java/java/send-raw-data-printer
    AttributeSet attributeSet = new HashAttributeSet();  
    attributeSet.add(new PrinterName(filename, null));
    PrintService[] services = PrintServiceLookup.lookupPrintServices(null, attributeSet);
    if(services.length > 0){
        if(printFile != null){
            printFile.deleteOnExit();
            printFile = null;
        }
        try {
            printFile = File.createTempFile("printer_"+name,".redirect");
        } catch (IOException e) {
            e.printStackTrace();
        }
        printService = services[0];
    }

}
项目:cn1    文件:WinPrintService.java   
public AttributeSet getUnsupportedAttributes(final DocFlavor flavor,
                final AttributeSet attributes) {
    checkFlavor(flavor);

    if (attributes == null) {
        return null;
    }

    final AttributeSet result = new HashAttributeSet();

    for (Attribute attr : attributes.toArray()) {
        if (!isAttributeValueSupported(attr, flavor, attributes)) {
            result.add(attr);
        }
    }

    return result.size() > 0 ? result : null;
}
项目:cn1    文件:WinPrintJob.java   
void notifyAttrListeners(final AttributeSet... attrSets) {
    final List<PrintJobAttribute> list = new ArrayList<PrintJobAttribute>();
    final PrintJobAttribute[] attrs;

    for (AttributeSet attrSet : attrSets) {
        if (attrSet != null) {
            for (Attribute attr : attrSet.toArray()) {
                if (attr instanceof PrintJobAttribute) {
                    list.add((PrintJobAttribute) attr);
                }
            }
        }
    }

    attrs = new PrintJobAttribute[list.size()];
    notifyAttrListeners(list.toArray(attrs));
}
项目:cn1    文件:WinPrintJob.java   
private String getDocName(final Object doc,
                final AttributeSet... attrSets) {
    Attribute name = getAttribute(DocumentName.class, attrSets);

    if (name == null) {
        name = getAttribute(JobName.class, attrSets);
    }

    if ((name == null) && (doc instanceof Component)) {
        Component c = (Component) doc;

        while (c != null) {
            if (c instanceof Frame) {
                if (((Frame) c).getTitle().length() > 0) {
                    return ((Frame) c).getTitle();
                }
            }
            c = c.getParent();
        }
    }

    return name != null ? ((TextSyntax) name).getValue()
                    : WinPrintService.DEFAULT_JOB_NAME.getValue();
}
项目:cn1    文件:WinPrintServiceLookup.java   
@Override
public PrintService[] getPrintServices(final DocFlavor flavor,
                final AttributeSet attributes) {
    final PrintService[] matchingServices;
    final PrintService[] allServices = getPrintServices();
    final Vector<PrintService> v = new Vector<PrintService>(
                    allServices.length);

    for (PrintService srv : allServices) {
        if (((flavor == null) || srv.isDocFlavorSupported(flavor))
                        && (srv
                                        .getUnsupportedAttributes(flavor,
                                                        attributes) == null)) {
            v.add(srv);
        }
    }

    matchingServices = new PrintService[v.size()];
    return v.toArray(matchingServices);
}
项目:cn1    文件:Win32PrintServiceProvider.java   
public PrintService[] getPrintServices(DocFlavor flavor,
        AttributeSet attributes) {
    PrintService[] services = getPrintServices();
    if (flavor == null && attributes == null) {
        return services;
    }
    ArrayList requestedServices = new ArrayList();
    for (int i = 0; i < services.length; i++) {

        try {
            AttributeSet unsupportedSet =
                services[i].getUnsupportedAttributes(flavor, attributes);
            if (unsupportedSet == null && (flavor == null ||
                    services[i].isDocFlavorSupported(flavor))) {
                requestedServices.add(services[i]);
            }
        } catch (IllegalArgumentException iae) {
            // DocFlavor not supported by service, skiping.
        }
    }
    return (requestedServices.size() == 0) ? new PrintService[0] :
        (PrintService[])requestedServices.toArray(new PrintService[0]);
}
项目:cn1    文件:DefaultPrintService.java   
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
        AttributeSet attributes) {
    if (attributes == null) {
        return null;
    }
    if (flavor != null && !isDocFlavorSupported(flavor)) {
        throw new IllegalArgumentException("Flavor " + flavor.getMimeType()
                + " is not supported by print service");
    }

    Attribute[] attrs = attributes.toArray();
    HashAttributeSet unsupported = new HashAttributeSet();
    for (int i = 0; i < attrs.length; i++) {
        if (!isAttributeValueSupported(attrs[i], flavor, attributes)) {
            unsupported.add(attrs[i]);
        }
    }
    if (unsupported.size() > 0) {
        return unsupported;
    }
    return null;
}
项目:cn1    文件:CUPSPrintServiceProvider.java   
public PrintService[] getPrintServices(DocFlavor flavor,
        AttributeSet attributes) {
    PrintService[] cupsservices = getPrintServices();
    if (flavor == null && attributes == null) {
        return cupsservices;
    }

    ArrayList requestedServices = new ArrayList();
    for (int i = 0; i < cupsservices.length; i++) {
        try {
            AttributeSet unsupportedSet = cupsservices[i]
                    .getUnsupportedAttributes(flavor, attributes);
            if (unsupportedSet == null) {
                requestedServices.add(cupsservices[i]);
            }
        } catch (IllegalArgumentException iae) {
            // DocFlavor not supported by service, skiping.
        }
    }
    return (requestedServices.size() == 0) ? new PrintService[0]
            : (PrintService[]) requestedServices
                    .toArray(new PrintService[0]);
}
项目:JamVM-PH    文件:PrintServiceLookup.java   
/**
 * Searches print services capable of printing in the given document flavor
 * which supports the specified printing attributes.
 * 
 * @param flavor the document flavor to support. If <code>null</code> this 
 * constraint is ignored during lookup.
 * @param attributes the printing attributes to support. If 
 * <code>null</code> this constraint is ignored during lookup.
 * @return The resulting available print services, or an array of length 0 
 * if none is found. 
 */
public static final PrintService[] lookupPrintServices(DocFlavor flavor,
  AttributeSet attributes)
{   
  ArrayList result = new ArrayList();

  PrintService[] services = 
    systemProvider.getPrintServices(flavor, attributes);    
  result.addAll(Arrays.asList(services));

  for (Iterator it = printServiceLookups.iterator(); it.hasNext(); )
    {
      PrintServiceLookup lookup = (PrintServiceLookup) it.next();
      services = lookup.getPrintServices(flavor, attributes);   
      result.addAll(Arrays.asList(services));
    }

  for (Iterator it = printServices.iterator(); it.hasNext(); )
    {
      PrintService service = (PrintService) it.next();
      if (systemProvider.checkPrintService(flavor, attributes, service)) 
        result.add(service);
    }

  return (PrintService[]) result.toArray(new PrintService[result.size()]);
}
项目:JamVM-PH    文件:CupsPrintServiceLookup.java   
/**
* All printers and printer classes of the CUPS server are checked.
* If flavors or attributes are null the constraint is not used.
* 
* @param flavors the document flavors which have to be supported.
* @param attributes the attributes which have to be supported.
* 
* @return The multidoc print services of the implementing lookup service
* for the given parameters, or an array of length 0 if none is available.
*/
public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors,
    AttributeSet attributes)
{
  ArrayList result = new ArrayList();
  PrintService[] services = getPrintServices();   

  for (int i=0; i < services.length; i++)
    {
      if (checkMultiDocPrintService(flavors, attributes, services[i]))
        result.add(services[i]);  
    }

  return (MultiDocPrintService[]) result.toArray(
    new MultiDocPrintService[result.size()]);
}
项目:JamVM-PH    文件:CupsPrintServiceLookup.java   
/**
 * Checks the given print service - own method so it can be used also
 * to check application registered print services from PrintServiceLookup.
 * 
 * @param flavor the document flavor which has to be supported.
 * @param attributes the attributes which have to be supported.
 * @param service the service to check
 * 
 * @return <code>true</code> if all constraints match, <code>false</code> 
 * otherwise.
 */
public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes,
  PrintService service)
{
  boolean allAttributesSupported = true;
  if (flavor == null || service.isDocFlavorSupported(flavor))
    {
      if (attributes == null || attributes.size() == 0)
        return allAttributesSupported;

      Attribute[] atts = attributes.toArray();
      for (int i = 0; i < atts.length; i++)
        {
          if (! service.isAttributeCategorySupported(atts[i].getCategory()))
            {
              allAttributesSupported = false;
              break;
            }
        }
      return allAttributesSupported;
    }

  return false;
}
项目:OpenJSharp    文件:PSStreamPrintService.java   
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;
    }
}
项目:OpenJSharp    文件:ServiceUI.java   
/**
 * Removes any attributes from the given AttributeSet that are
 * unsupported by the given PrintService/DocFlavor combination.
 */
private static void removeUnsupportedAttributes(PrintService ps,
                                                DocFlavor flavor,
                                                AttributeSet aset)
{
    AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
                                                             aset);

    if (asUnsupported != null) {
        Attribute[] usAttrs = asUnsupported.toArray();

        for (int i=0; i<usAttrs.length; i++) {
            Class category = usAttrs[i].getCategory();

            if (ps.isAttributeCategorySupported(category)) {
                Attribute attr =
                    (Attribute)ps.getDefaultAttributeValue(category);

                if (attr != null) {
                    aset.add(attr);
                } else {
                    aset.remove(category);
                }
            } else {
                aset.remove(category);
            }
        }
    }
}
项目:OpenJSharp    文件:Win32PrintServiceLookup.java   
public MultiDocPrintService[]
    getMultiDocPrintServices(DocFlavor[] flavors,
                             AttributeSet attributes) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
      security.checkPrintJobAccess();
    }
    return new MultiDocPrintService[0];
}
项目:OpenJSharp    文件:Win32PrintService.java   
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;
    }
}
项目:OpenJSharp    文件:UnixPrintServiceLookup.java   
public MultiDocPrintService[]
    getMultiDocPrintServices(DocFlavor[] flavors,
                             AttributeSet attributes) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
      security.checkPrintJobAccess();
    }
    return new MultiDocPrintService[0];
}
项目:OpenJSharp    文件:UnixPrintService.java   
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;
    }
}
项目:OpenJSharp    文件:Win32PrintServiceLookup.java   
public MultiDocPrintService[]
    getMultiDocPrintServices(DocFlavor[] flavors,
                             AttributeSet attributes) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
      security.checkPrintJobAccess();
    }
    return new MultiDocPrintService[0];
}
项目:jdk8u-jdk    文件:PSStreamPrintService.java   
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;
    }
}
项目:jdk8u-jdk    文件:ServiceUI.java   
/**
 * Removes any attributes from the given AttributeSet that are
 * unsupported by the given PrintService/DocFlavor combination.
 */
private static void removeUnsupportedAttributes(PrintService ps,
                                                DocFlavor flavor,
                                                AttributeSet aset)
{
    AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
                                                             aset);

    if (asUnsupported != null) {
        Attribute[] usAttrs = asUnsupported.toArray();

        for (int i=0; i<usAttrs.length; i++) {
            Class category = usAttrs[i].getCategory();

            if (ps.isAttributeCategorySupported(category)) {
                Attribute attr =
                    (Attribute)ps.getDefaultAttributeValue(category);

                if (attr != null) {
                    aset.add(attr);
                } else {
                    aset.remove(category);
                }
            } else {
                aset.remove(category);
            }
        }
    }
}
项目:jdk8u-jdk    文件:Win32PrintServiceLookup.java   
public MultiDocPrintService[]
    getMultiDocPrintServices(DocFlavor[] flavors,
                             AttributeSet attributes) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
      security.checkPrintJobAccess();
    }
    return new MultiDocPrintService[0];
}
项目:jdk8u-jdk    文件:Win32PrintService.java   
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;
    }
}
项目:jdk8u-jdk    文件:UnixPrintServiceLookup.java   
public MultiDocPrintService[]
    getMultiDocPrintServices(DocFlavor[] flavors,
                             AttributeSet attributes) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
      security.checkPrintJobAccess();
    }
    return new MultiDocPrintService[0];
}
项目:jdk8u-jdk    文件:UnixPrintService.java   
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;
    }
}
项目:jdk8u-jdk    文件:GetPrintServices.java   
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;
}
项目:openjdk-jdk10    文件:PSStreamPrintService.java   
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;
    }
}
项目:openjdk-jdk10    文件:ServiceUI.java   
/**
 * Removes any attributes from the given {@code AttributeSet} that are
 * unsupported by the given {@code PrintService/DocFlavor} combination.
 */
private static void removeUnsupportedAttributes(PrintService ps,
                                                DocFlavor flavor,
                                                AttributeSet aset)
{
    AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
                                                             aset);

    if (asUnsupported != null) {
        Attribute[] usAttrs = asUnsupported.toArray();

        for (int i=0; i<usAttrs.length; i++) {
            Class<? extends Attribute> category = usAttrs[i].getCategory();

            if (ps.isAttributeCategorySupported(category)) {
                Attribute attr =
                    (Attribute)ps.getDefaultAttributeValue(category);

                if (attr != null) {
                    aset.add(attr);
                } else {
                    aset.remove(category);
                }
            } else {
                aset.remove(category);
            }
        }
    }
}
项目:openjdk-jdk10    文件:UnixPrintService.java   
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;
    }
}
项目:openjdk-jdk10    文件:PrintServiceLookupProvider.java   
public MultiDocPrintService[]
    getMultiDocPrintServices(DocFlavor[] flavors,
                             AttributeSet attributes) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
      security.checkPrintJobAccess();
    }
    return new MultiDocPrintService[0];
}
项目:openjdk-jdk10    文件:Win32PrintService.java   
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;
    }
}
项目:openjdk-jdk10    文件:PrintServiceLookupProvider.java   
public MultiDocPrintService[]
    getMultiDocPrintServices(DocFlavor[] flavors,
                             AttributeSet attributes) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
      security.checkPrintJobAccess();
    }
    return new MultiDocPrintService[0];
}
项目:openjdk-jdk10    文件:GetPrintServices.java   
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;
}
项目:openjdk9    文件:PSStreamPrintService.java   
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;
    }
}
项目:openjdk9    文件:ServiceUI.java   
/**
 * Removes any attributes from the given AttributeSet that are
 * unsupported by the given PrintService/DocFlavor combination.
 */
private static void removeUnsupportedAttributes(PrintService ps,
                                                DocFlavor flavor,
                                                AttributeSet aset)
{
    AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
                                                             aset);

    if (asUnsupported != null) {
        Attribute[] usAttrs = asUnsupported.toArray();

        for (int i=0; i<usAttrs.length; i++) {
            Class<? extends Attribute> category = usAttrs[i].getCategory();

            if (ps.isAttributeCategorySupported(category)) {
                Attribute attr =
                    (Attribute)ps.getDefaultAttributeValue(category);

                if (attr != null) {
                    aset.add(attr);
                } else {
                    aset.remove(category);
                }
            } else {
                aset.remove(category);
            }
        }
    }
}