public interface AttributeSet
Attribute
对象。
一个属性集包含一组属性值,其中重复的值不在设定的允许。此外,在属性集的每个值有一定的类别成员,和至多一个价值在任何特定的类中设置允许。一个属性设置的值,Attribute
对象和类别类
对象。属性的类别是类(或接口)在类层次结构的根类属性的类(或接口)类。注意,属性对象的类可能是一个父类的属性对象的类而不是对象本身的属性。属性对象的类是通过调用接口中定义的方法确定Attribute
getCategory()
。
一个attributeset接口类似于java集合API的java.util.map接口,但更多的是限制性的类型,它会接受,并结合键和值到一个属性。
属性集在打印服务应用接口的几个地方使用。在每一种情况下,只有某些种类的属性可以出现在属性集,由标记的属性类实现了接口,DocAttribute
,PrintRequestAttribute
,PrintJobAttribute
,和PrintServiceAttribute
确定。有四个专业的属性集被限制为只包含一个属性的四种——DocAttributeSet
,PrintRequestAttributeSet
,PrintJobAttributeSet
,和PrintServiceAttributeSet
,分别。请注意,许多属性类实现了一个以上的标记接口,因此可能会出现在多个上下文中。
DocAttributeSet
,含DocAttribute
s,指定要应用到单个文件的个人文档和打印作业设置的特点。PrintRequestAttributeSet
,含PrintRequestAttribute
s,指定要应用到整个打印工作,在打印作业的所有文档的设置。PrintJobAttributeSet
,含PrintJobAttribute
s,报告的打印作业的状态。PrintServiceAttributeSet
,含PrintServiceAttribute
s、报告打印服务实例的状态。在某些情况下,客户端只允许检查属性集的内容,但不改变它们(该集合是只读的)。在其他地方,客户端允许检查和改变一个属性集的内容(设置读写)。一个只读属性,调用一个变异操作引发unmodifiablesetexception。
打印服务API提供了一个实现类接口attributeset,HashAttributeSet
。一个客户端可以使用类或接口attributeset HashAttributeSet
提供它自己的实现。打印服务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()
如果此属性集不包含任何属性,则返回真。
|
boolean |
remove(Attribute attribute)
如果存在的话,从该属性集中移除指定的属性。
|
boolean |
remove(类<?> category)
如果存在的话,从这个属性设置这个类别的任何属性。
|
int |
size()
返回此属性集的属性的数目。
|
Attribute[] |
toArray()
返回此集合中包含的属性的数组。
|
Attribute get(类<?> category)
category
属性类的相关属性值被返回。它必须是一个
类
实现接口
Attribute
。
NullPointerException
-(unchecked例外)如果
category
空抛。
ClassCastException
-(unchecked例外)如果
category
不是
类
实现接口
Attribute
扔。
boolean add(Attribute attribute)
attribute
属性值被添加到这个属性设置。
NullPointerException
-(unchecked例外)如果
attribute
空抛。
UnmodifiableSetException
-(unchecked异常)如果这个属性设置不支持
add()
操作抛出。
boolean remove(类<?> category)
category
是空的,然后
remove()
不返回
false。
category
属性范畴是删除从这个属性设置。
UnmodifiableSetException
-(unchecked异常)如果这个属性设置不支持
remove()
操作抛出。
boolean remove(Attribute attribute)
attribute
是空的,然后
remove()
不返回
false。
attribute
属性值被删除从这个属性设置。
UnmodifiableSetException
-(unchecked异常)如果这个属性设置不支持
remove()
操作抛出。
boolean containsKey(类<?> category)
category
的该属性集的存在是进行测试。
boolean containsValue(Attribute attribute)
attribute
属性值为该属性集的存在是进行测试。
boolean addAll(AttributeSet attributes)
add(Attribute)
操作已经被应用到该属性集的每个元素依次从指定的设置相同。如果指定的设置是在操作进行改性的
addAll(AttributeSet)
操作行为是未定义的。
如果addAll(AttributeSet)
操作抛出异常,该属性集的状态的影响是依赖于实现的;元素从指定的集合点前的异常可能会或可能不会被添加到这个属性设置。
attributes
的元素被添加到这个属性设置。
UnmodifiableSetException
-(unchecked异常)如果这个属性设置不支持
addAll(AttributeSet)方法引发。
NullPointerException
-(unchecked异常)如果在指定集合的一些元素是空抛。
add(Attribute)
int size()
Attribute[] toArray()
void clear()
UnmodifiableSetException
-(unchecked异常)如果这个属性设置不支持
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.