-
- All Known Subinterfaces:
-
DocAttributeSet,PrintJobAttributeSet,PrintRequestAttributeSet,PrintServiceAttributeSet
- 所有已知实现类:
-
HashAttributeSet,HashDocAttributeSet,HashPrintJobAttributeSet,HashPrintRequestAttributeSet,HashPrintServiceAttributeSet
public interface AttributeSet接口AttributeSet指定一组打印属性的接口。 打印属性是其类实现接口Attribute的对象。属性集包含一组属性值,其中集合中不允许重复值。 此外,属性集中的每个值都是某个类别的成员,并且在该集合中最多允许任何特定类别中的一个值。 对于属性集,值为
Attribute个对象,类别为类个对象。 属性的类别是该类属性的类层次结构根的类(或接口)。 请注意,属性对象的类别可能是属性对象类的超类,而不是属性对象的类本身。 通过调用接口Attribute中定义的getCategory()方法确定属性对象的类别。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,报告打印服务实例的状态。
UnmodifiableSetException。Print Service API提供了接口
AttributeSet一个实现,类HashAttributeSet。 客户端可以使用类HashAttributeSet或提供其自己的接口AttributeSet的实现。 打印服务API还提供接口的实现AttributeSet的子接口-类HashDocAttributeSet,HashPrintRequestAttributeSet,HashPrintJobAttributeSet,和HashPrintServiceAttributeSet。
-
-
方法摘要
所有方法 实例方法 抽象方法 变量和类型 方法 描述 booleanadd(Attribute attribute)将指定的属性添加到此属性集(如果该属性集尚不存在),首先删除与指定属性值相同的属性类别中的任何现有值。booleanaddAll(AttributeSet attributes)将指定集中的所有元素添加到此属性。voidclear()从此属性集中删除所有属性。booleancontainsKey(类<?> category)如果此属性集包含指定类别的属性,则返回true。booleancontainsValue(Attribute attribute)如果此属性集包含给定的属性值,则返回true。booleanequals(Object object)将指定对象与此属性集进行比较以进行相等性比较。Attributeget(类<?> category)返回此属性集在给定属性类别中包含的属性值。inthashCode()返回此属性集的哈希码值。booleanisEmpty()如果此属性集不包含任何属性,则返回true。booleanremove(类<?> category)从此属性集中删除此类别的任何属性(如果存在)。booleanremove(Attribute attribute)从此属性集中删除指定的属性(如果存在)。intsize()返回此属性集中的属性数。Attribute[]toArray()返回此set中包含的属性数组。
-
-
-
方法详细信息
-
get
Attribute get(类<?> category)
返回此属性集在给定属性类别中包含的属性值。 如果此属性集在给定属性类别中不包含任何属性值,则返回null。- 参数
-
category- 要返回其关联属性值的属性类别。 它必须是类,它实现了接口Attribute。 - 结果
-
此属性集中包含的给定属性类别中的属性值,如果此属性集在给定属性类别中不包含任何属性值,
null - 异常
-
NullPointerException- 如果category是null -
ClassCastException- 如果category不是类,它实现了接口Attribute
-
add
boolean add(Attribute attribute)
将指定的属性添加到此属性集(如果该属性集尚不存在),首先删除与指定属性值相同的属性类别中的任何现有值。- 参数
-
attribute- 要添加到此属性集的属性值 - 结果
-
true如果此属性集因调用而更改,即给定的属性值尚未是此属性集的成员 - 异常
-
NullPointerException- 如果attribute是null -
UnmodifiableSetException- 如果此属性集不支持add()操作
-
remove
boolean remove(类<?> category)
从此属性集中删除此类别的任何属性(如果存在)。 如果category是null,则remove()什么都不做,将返回false。- 参数
-
category- 要从此属性集中删除的属性类别 - 结果
-
true如果此属性集因调用而更改,即给定的属性值是此属性集的成员 - 异常
-
UnmodifiableSetException- 如果此属性集不支持remove()操作
-
remove
boolean remove(Attribute attribute)
从此属性集中删除指定的属性(如果存在)。 如果attribute是null,则remove()什么都不做,将返回false。- 参数
-
attribute- 要从此属性集中删除的属性值 - 结果
-
true如果此属性集因调用而更改,即给定的属性值是此属性集的成员 - 异常
-
UnmodifiableSetException- 如果此属性集不支持remove()操作
-
containsKey
boolean containsKey(类<?> category)
如果此属性集包含指定类别的属性,则返回true。- 参数
-
category- 要测试其在此属性集中的存在 - 结果
-
true如果此属性集包含指定类别的属性值
-
containsValue
boolean containsValue(Attribute attribute)
如果此属性集包含给定的属性值,则返回true。- 参数
-
attribute- 要测试其在此属性集中的存在的属性值 - 结果
-
true如果此属性集包含给定的属性值
-
addAll
boolean addAll(AttributeSet attributes)
将指定集中的所有元素添加到此属性。 结果与=add(Attribute)操作已连续应用于指定集合中的每个元素的操作相同。 如果在操作过程中修改了指定的集,则未指定addAll(AttributeSet)操作的行为。如果
addAll(AttributeSet)操作抛出异常,则对此属性集的状态的影响取决于实现; 在异常点之前的指定集合中的元素可能已添加或未添加到此属性集中。- 参数
-
attributes- 其元素将添加到此属性集 - 结果
-
true如果此属性集因调用而更改 - 异常
-
UnmodifiableSetException- 如果此属性集不支持addAll(AttributeSet)方法 -
NullPointerException- 如果指定集中的某些元素为null - 另请参见:
-
add(Attribute)
-
size
int size()
返回此属性集中的属性数。 如果此属性集包含的元素超过Integer.MAX_VALUE,则返回Integer.MAX_VALUE。- 结果
- 此属性集中的属性数
-
toArray
Attribute[] toArray()
返回此set中包含的属性数组。- 结果
-
Attributes包含在此集合中作为数组,如果AttributeSet为空则为零长度
-
clear
void clear()
从此属性集中删除所有属性。- 异常
-
UnmodifiableSetException- 如果此属性集不支持clear()操作
-
isEmpty
boolean isEmpty()
如果此属性集不包含任何属性,则返回true。- 结果
-
true如果此属性集不包含任何属性
-
equals
boolean equals(Object object)
将指定对象与此属性集进行比较以进行相等性比较。 如果给定对象也是属性集并且两个属性集包含相同的属性category-attribute value mappings,则返回true。 这可确保equals()方法在AttributeSet接口的不同实现中正常工作。- 重写:
-
equals在类Object - 参数
-
object- 要与此属性集进行相等性比较 - 结果
-
true如果指定的对象等于此属性集 - 另请参见:
-
Object.hashCode(),HashMap
-
hashCode
int hashCode()
返回此属性集的哈希码值。 属性集的哈希码被定义为AttributeSet中每个条目的哈希码的AttributeSet。 这确保t1.equals(t2)暗示t1.hashCode()==t2.hashCode()为任何两个属性集t1和t2,根据总承包Object.hashCode()的要求 。- 重写:
-
hashCode在课堂Object - 结果
- 此属性集的哈希码值
- 另请参见:
-
Object.equals(java.lang.Object),System.identityHashCode(java.lang.Object)
-
-