public interface AttributeSet 
      Attribute的对象。 
        属性集包含一组属性值,其中集合中不允许重复的值。 此外,属性集中的每个值都是某个类别的成员,并且在该集合中允许任何特定类别中的最多一个值。 对于属性集,值为Attribute对象,类别为类对象。 属性类别是该类属性的类层次结构根目录下的类(或接口)。 请注意,属性对象的类别可能是属性对象的类的超类,而不是属性对象的类本身。 属性对象的类别是通过调用确定getCategory()在接口中定义的方法Attribute 。 
AttributeSet的接口类似于Java Collections API的java.util.Map接口的接口,但是它将接受的类型更具限制性,并将键和值组合到一个Attribute中。
 属性集在Print Service API的多个位置使用。 在每个上下文中,只有某些种类的属性被允许出现在该属性集,如由该属性类实现加标签接口确定- DocAttribute , PrintRequestAttribute , PrintJobAttribute和PrintServiceAttribute 。 但是也有一些限制为仅包含四种属性的一个属性组四个特- DocAttributeSet , PrintRequestAttributeSet , PrintJobAttributeSet和PrintServiceAttributeSet ,分别。 请注意,许多属性类实现多个标记接口,因此可能会出现在多个上下文中。 
DocAttributeSet ,含有DocAttribute个 S,指定单个文档和所述打印作业设置的特性,以被应用到一个单独的文档。 PrintRequestAttributeSet ,含PrintRequestAttribute个 S,指定设置应用到整个打印作业,并在打印作业中所有文档。 PrintJobAttributeSet ,包含PrintJobAttribute s,报告打印作业的状态。 PrintServiceAttributeSet ,包含PrintServiceAttribute s,报告打印服务实例的状态。 在某些情况下,只允许客户端检查属性集的内容,但不允许更改它们(该集合是只读的)。 在其他地方,允许客户端检查和更改属性集的内容(集合是读写)。 对于只读属性集,调用mutating操作会引发UnmodifiableSetException。
 Print Service API提供了一个接口AttributeSet的实现,类别为HashAttributeSet 。 客户端可以使用类别HashAttributeSet或提供自己的接口AttributeSet的实现。 打印服务API还提供:接口AttributeSet的子接口的实现-班HashDocAttributeSet , HashPrintRequestAttributeSet , HashPrintJobAttributeSet和HashPrintServiceAttributeSet 。 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | add(Attribute attribute)
              如果指定的属性不存在,请将指定的属性添加到此属性集中,首先删除与指定的属性值相同的属性类别中的任何现有值。 
             | 
| boolean | addAll(AttributeSet attributes)
              将指定集合中的所有元素添加到此属性。 
             | 
| void | clear()
              从该属性集中删除所有属性。 
             | 
| boolean | containsKey(类<?> category)
              如果此属性集包含指定类别的属性,则返回 
             true 。 
             | 
| boolean | containsValue(Attribute attribute)
              如果此属性集包含给定的属性值,则返回 
             true 。 
             | 
| boolean | equals(Object object)
              将指定的对象与此属性集进行比较以便相等。 
             | 
| Attribute | get(类<?> category)
              返回此属性集在给定属性类别中包含的属性值。 
             | 
| int | hashCode()
              返回此属性集的哈希码值。 
             | 
| boolean | isEmpty()
              如果此属性集不包含任何属性,则返回true。 
             | 
| boolean | remove(Attribute attribute)
              从该属性集中删除指定的属性(如果存在)。 
             | 
| boolean | remove(类<?> category)
              从此属性集中删除此类别的任何属性(如果存在)。 
             | 
| int | size()
              返回此属性集中的属性数。 
             | 
| Attribute[] | toArray()
              返回此集合中包含的属性的数组。 
             | 
Attribute get(类<?> category)
category - 要返回其关联属性值的属性类别。 
            它必须是类实现接口Attribute 。 
           NullPointerException - (未选中的异常)如果 
            category为空,则抛出。 
           ClassCastException - (未经检查的异常)如果category不是实现接口Attribute的类 ,则抛出 。 
           boolean add(Attribute attribute)
attribute - 要添加到此属性集的属性值。 
           NullPointerException - (未经检查的异常)如果 
            attribute为空,则抛出。 
           UnmodifiableSetException - (未经检查的异常)如果此属性集不支持 
            add()操作。 
           boolean remove(类<?> category)
category为空,则remove()不执行任何操作并返回false 。 
          category - 要从此属性集中删除的属性类别。 
           UnmodifiableSetException - (未经检查的异常)如果此属性集不支持 
            remove()操作。 
           boolean remove(Attribute attribute)
attribute为空,则remove()不执行任何操作并返回false 。 
          attribute - 要从此属性集中删除的属性值。 
           UnmodifiableSetException - (未经检查的异常)如果此属性集不支持 
            remove()操作。 
           boolean containsKey(类<?> category)
category - 在此属性集中的存在将被测试。 
           boolean containsValue(Attribute attribute)
attribute - 要测试其在该属性集中的属性值。 
           boolean addAll(AttributeSet attributes)
add(Attribute)操作相同。 
           如果在操作进行中修改了指定的集合,那么addAll(AttributeSet)操作的行为是未指定的。 
            如果addAll(AttributeSet)操作引发异常,对该属性集的状态的影响是依赖于实现的; 在异常点之前的指定集合中的元素可能已经被添加到该属性集中,也可能不被添加到该属性集中。 
attributes - 其元素将被添加到此属性集。 
           UnmodifiableSetException - (未检查异常)如果此属性集不支持 
            addAll(AttributeSet)方法,则抛出此异常。 
           NullPointerException - (未检查的异常)如果指定集合中的某些元素为空,则抛出。 
           add(Attribute) 
           int size()
Attribute[] toArray()
void clear()
UnmodifiableSetException - (未经检查的异常)如果此属性集不支持 
            clear()操作。 
           boolean isEmpty()
boolean equals(Object object)
equals在 
            Object 
           object - 要与此属性集进行比较。 
           Object.hashCode() , HashMap 
           int hashCode()
Object.hashCode()的一般合同的要求 。 
          hashCode在 
            Object 
           Object.equals(java.lang.Object) , 
            System.identityHashCode(java.lang.Object) 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.