当前位置: 首页>>代码示例>>Java>>正文


Java AttributeSet.toArray方法代码示例

本文整理汇总了Java中javax.print.attribute.AttributeSet.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet.toArray方法的具体用法?Java AttributeSet.toArray怎么用?Java AttributeSet.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.print.attribute.AttributeSet的用法示例。


在下文中一共展示了AttributeSet.toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkPrintService

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:vilie,项目名称:javify,代码行数:35,代码来源:CupsPrintServiceLookup.java

示例2: checkPrintService

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:35,代码来源:CupsPrintServiceLookup.java

示例3: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:WinPrintService.java

示例4: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:DefaultPrintService.java

示例5: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:PSStreamPrintService.java

示例6: removeUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * 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);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:ServiceUI.java

示例7: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:Win32PrintService.java

示例8: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:UnixPrintService.java

示例9: removeUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * 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);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:ServiceUI.java

示例10: getUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:Win32PrintService.java

示例11: removeUnsupportedAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * 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);
            }
        }
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:33,代码来源:ServiceUI.java

示例12: writeAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * Writes the given attribute groups of the given map instance
 * (key=group, values=set of attributes) into the supplied data
 * output stream.
 *
 * @param attributes the set with the attributes.
 *
 * @throws IOException if thrown by the used DataOutputStream.
 * @throws IppException if unknown attributes occur.
 */
public void writeAttributes(AttributeSet attributes)
    throws IOException, IppException
{
  Attribute[] attributeArray = attributes.toArray();
  for (int i = 0; i < attributeArray.length; i++)
    {
      logger.log(Component.IPP, "Attribute: Name: <" + attributeArray[i]
        .getCategory().getName() + "> Value: <"
        + attributeArray[i].toString() + ">");

      if (attributeArray[i] instanceof IntegerSyntax)
        write((IntegerSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof TextSyntax)
        write((TextSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof DateTimeSyntax)
        write((DateTimeSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof ResolutionSyntax)
        write((ResolutionSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof SetOfIntegerSyntax)
        write((SetOfIntegerSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof EnumSyntax)
        write((EnumSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof URISyntax)
        write((URISyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof CharsetSyntax)
        write((CharsetSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof NaturalLanguageSyntax)
        write((NaturalLanguageSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof RequestedAttributes)
        write((RequestedAttributes) attributeArray[i]);
      else
        throw new IppException("Unknown syntax type");
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:45,代码来源:IppRequest.java

示例13: writeAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
 * Writes the given attribute groups of the given map instance
 * (key=group, values=set of attributes) into the supplied data
 * output stream.
 * 
 * @param attributes the set with the attributes.
 * 
 * @throws IOException if thrown by the used DataOutputStream.
 * @throws IppException if unknown attributes occur.
 */
public void writeAttributes(AttributeSet attributes)
    throws IOException, IppException
{
  Attribute[] attributeArray = attributes.toArray();
  for (int i = 0; i < attributeArray.length; i++)
    {
      logger.log(Component.IPP, "Attribute: Name: <" + attributeArray[i]
        .getCategory().getName() + "> Value: <" 
        + attributeArray[i].toString() + ">");          
      
      if (attributeArray[i] instanceof IntegerSyntax)
        write((IntegerSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof TextSyntax)
        write((TextSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof DateTimeSyntax)
        write((DateTimeSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof ResolutionSyntax)
        write((ResolutionSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof SetOfIntegerSyntax)
        write((SetOfIntegerSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof EnumSyntax)
        write((EnumSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof URISyntax)
        write((URISyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof CharsetSyntax)
        write((CharsetSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof NaturalLanguageSyntax)
        write((NaturalLanguageSyntax) attributeArray[i]);
      else if (attributeArray[i] instanceof RequestedAttributes)
        write((RequestedAttributes) attributeArray[i]);
      else
        throw new IppException("Unknown syntax type");
    }
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:45,代码来源:IppRequest.java

示例14: setAttributes

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
public void setAttributes(final AttributeSet attrs) {
    if (attrs != null) {
        for (Attribute attr : attrs.toArray()) {
            setAttribute(attr);
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:8,代码来源:DevmodeStructWrapper.java

示例15: getAttribute

import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
private <T extends Attribute> T getAttribute(final Class<T> c,
                final AttributeSet... attrSets) {
    for (AttributeSet attrs : attrSets) {
        if (attrs != null) {
            for (Attribute attr : attrs.toArray()) {
                if (c.equals(attr.getCategory())) {
                    return c.cast(attr);
                }
            }
        }
    }

    return null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:WinPrintJob.java


注:本文中的javax.print.attribute.AttributeSet.toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。