- java.lang.Object
-
- javax.print.attribute.HashAttributeSet
-
- 实现的所有接口
-
Serializable,AttributeSet
- 已知直接子类:
-
HashDocAttributeSet,HashPrintJobAttributeSet,HashPrintRequestAttributeSet,HashPrintServiceAttributeSet
public class HashAttributeSet extends Object implements AttributeSet, Serializable
类HashAttributeSet提供了具有哈希映射特征的AttributeSet实现。- 另请参见:
- Serialized Form
-
-
构造方法摘要
构造方法 变量 构造器 描述 HashAttributeSet()构造一个新的空属性集。protectedHashAttributeSet(类<?> interfaceName)构造一个新的空属性集,其中属性集的成员仅限于给定的接口。HashAttributeSet(Attribute attribute)构造一个最初使用给定属性填充的新属性集。HashAttributeSet(Attribute[] attributes)构造一个新的属性集,最初使用给定数组中的值填充。protectedHashAttributeSet(Attribute[] attributes, 类<?> interfaceName)构造一个新的属性集,其中属性集的成员仅限于给定的接口。protectedHashAttributeSet(Attribute attribute, 类<?> interfaceName)构造一个新的属性集,最初使用给定的属性填充,其中属性集的成员仅限于给定的接口。HashAttributeSet(AttributeSet attributes)构造一个新的属性集,最初使用给定集合中的值填充。protectedHashAttributeSet(AttributeSet attributes, 类<?> interfaceName)构造一个新的属性集,最初使用给定集合中的值填充,其中属性集的成员仅限于给定的接口。
-
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 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中包含的属性数组。
-
-
-
构造方法详细信息
-
HashAttributeSet
public HashAttributeSet()
构造一个新的空属性集。
-
HashAttributeSet
public HashAttributeSet(Attribute attribute)
构造一个最初使用给定属性填充的新属性集。- 参数
-
attribute- 要添加到集合的属性值 - 异常
-
NullPointerException- 如果attribute是null
-
HashAttributeSet
public HashAttributeSet(Attribute[] attributes)
构造一个新的属性集,最初使用给定数组中的值填充。 通过从序列0开始按顺序将attributes数组的元素添加到集合来填充新属性集。因此,如果数组包含重复的属性值或属性类别,则后面的数组元素可以替换先前的数组元素。- 参数
-
attributes- 要添加到集合的属性值数组。 如果是null,则构造一个空属性集。 - 异常
-
NullPointerException-如果任何元件attributes是null
-
HashAttributeSet
public HashAttributeSet(AttributeSet attributes)
构造一个新的属性集,最初使用给定集合中的值填充。- 参数
-
attributes- 初始化此集的属性集。 如果是null,则构造一个空属性集。
-
HashAttributeSet
protected HashAttributeSet(类<?> interfaceName)
构造一个新的空属性集,其中属性集的成员仅限于给定的接口。- 参数
-
interfaceName- 此属性集的所有成员必须是实例的接口。 假设是接口Attribute或其子接口。 - 异常
-
NullPointerException- 如果interfaceName是null
-
HashAttributeSet
protected HashAttributeSet(Attribute attribute, 类<?> interfaceName)
构造一个新的属性集,最初使用给定的属性填充,其中属性集的成员仅限于给定的接口。- 参数
-
attribute- 要添加到集合的属性值 -
interfaceName- 此属性集的所有成员必须是实例的接口。 假设是接口Attribute或其子接口。 - 异常
-
NullPointerException- 如果attribute或interfaceName是null -
ClassCastException-如果attribute不是一个实例interfaceName
-
HashAttributeSet
protected HashAttributeSet(Attribute[] attributes, 类<?> interfaceName)
构造一个新的属性集,其中属性集的成员仅限于给定的接口。 通过从索引0开始按顺序将attributes数组的元素添加到集合来填充新属性集。因此,如果数组包含重复的属性值或属性类别,则后面的数组元素可以替换早期的数组元素。- 参数
-
attributes- 要添加到集合的属性值数组。 如果是null,则构造一个空属性集。 -
interfaceName- 此属性集的所有成员必须是实例的接口。 假设是接口Attribute或其子接口。 - 异常
-
NullPointerException-如果interfaceName是null,或如果任何元件attributes是null -
ClassCastException-如果任何元素attributes不是一个实例interfaceName
-
HashAttributeSet
protected HashAttributeSet(AttributeSet attributes, 类<?> interfaceName)
构造一个新的属性集,最初使用给定集合中的值填充,其中属性集的成员仅限于给定的接口。- 参数
-
attributes- 用于初始化集的属性值集。 如果是null,则构造一个空属性集。 -
interfaceName- 此属性集的所有成员必须是实例的接口。 假设是接口Attribute或其子接口。 - 异常
-
ClassCastException-如果任何元素attributes不是一个实例interfaceName
-
-
方法详细信息
-
get
public Attribute get(类<?> category)
返回此属性集在给定属性类别中包含的属性值。 如果此属性集在给定属性类别中不包含任何属性值,则返回null。- Specified by:
-
get在界面AttributeSet - 参数
-
category- 要返回其关联属性值的属性类别。 它必须是类,它实现了接口Attribute。 - 结果
-
此属性集中包含的给定属性类别中的属性值,如果此属性集在给定属性类别中不包含任何属性值,
null - 异常
-
NullPointerException- 如果category是null -
ClassCastException-如果category不是类实现了接口Attribute
-
add
public boolean add(Attribute attribute)
如果指定的属性尚不存在,则将其添加到此属性集中,首先删除与指定属性值相同的属性类别中的任何现有属性。- Specified by:
-
add,界面AttributeSet - 参数
-
attribute- 要添加到此属性集的属性值 - 结果
-
true如果此属性集因调用而更改,即给定的属性值尚未是此属性集的成员 - 异常
-
NullPointerException- 如果attribute是null -
UnmodifiableSetException- 如果此属性集不支持add()操作
-
remove
public boolean remove(类<?> category)
从此属性集中删除此类别的任何属性(如果存在)。 如果category是null,则remove()不做任何操作,返回false。- Specified by:
-
remove在界面AttributeSet - 参数
-
category- 要从此属性集中删除的属性类别 - 结果
-
true如果此属性集因调用而更改,即给定属性类别是此属性集的成员 - 异常
-
UnmodifiableSetException- 如果此属性集不支持remove()操作
-
remove
public boolean remove(Attribute attribute)
从此属性集中删除指定的属性(如果存在)。 如果attribute是null,则remove()不做任何操作,返回false。- Specified by:
-
remove接口AttributeSet - 参数
-
attribute- 要从此属性集中删除的属性值 - 结果
-
true如果此属性集因调用而更改,即给定属性值true为此属性集的成员 - 异常
-
UnmodifiableSetException- 如果此属性集不支持remove()操作
-
containsKey
public boolean containsKey(类<?> category)
如果此属性集包含指定类别的属性,则返回true。- Specified by:
-
containsKey接口AttributeSet - 参数
-
category- 要测试其在此属性集中的存在 - 结果
-
true如果此属性集包含指定类别的属性值
-
containsValue
public boolean containsValue(Attribute attribute)
如果此属性集包含给定属性,则返回true。- Specified by:
-
containsValue在界面AttributeSet - 参数
-
attribute- 要测试其在此属性集中的存在的值 - 结果
-
true如果此属性集包含给定的属性值
-
addAll
public boolean addAll(AttributeSet attributes)
将指定集中的所有元素添加到此属性。 结果与add(Attribute)操作已连续应用于指定集合中的每个元素的结果相同。 如果在操作过程中修改了指定的集,则未指定addAll(AttributeSet)操作的行为。如果
addAll(AttributeSet)操作抛出异常,则对此属性集的状态的影响取决于实现; 在异常点之前的指定集合中的元素可能已添加或未添加到此属性集中。- Specified by:
-
addAll接口AttributeSet - 参数
-
attributes- 其元素将添加到此属性集 - 结果
-
true如果此属性集因调用而更改 - 异常
-
UnmodifiableSetException- 如果此属性集不支持addAll(AttributeSet)方法 -
NullPointerException- 如果指定集合中的某些元素为null,或者该集合为null - 另请参见:
-
add(Attribute)
-
size
public int size()
返回此属性集中的属性数。 如果此属性集包含超过Integer.MAX_VALUE元素,则返回Integer.MAX_VALUE。- Specified by:
-
size接口AttributeSet - 结果
- 此属性集中的属性数
-
toArray
public Attribute[] toArray()
返回此set中包含的属性数组。- Specified by:
-
toArray在界面AttributeSet - 结果
-
此set中包含的属性为数组,如果
AttributeSet为空,则为零长度
-
clear
public void clear()
从此属性集中删除所有属性。- Specified by:
-
clear在界面AttributeSet - 异常
-
UnmodifiableSetException- 如果此属性集不支持clear()操作
-
isEmpty
public boolean isEmpty()
如果此属性集不包含任何属性,则返回true。- Specified by:
-
isEmptyin interfaceAttributeSet - 结果
-
true如果此属性集不包含任何属性
-
equals
public boolean equals(Object object)
将指定对象与此属性集进行比较以进行相等性比较。 如果给定对象也是属性集并且两个属性集包含相同的属性category-attribute value mappings,则返回true。 这可确保equals()方法在AttributeSet接口的不同实现中正常工作。- Specified by:
-
equals在界面AttributeSet - 重写:
-
equals在课程Object - 参数
-
object- 要与此属性集进行相等性比较 - 结果
-
true如果指定的对象等于此属性集 - 另请参见:
-
Object.hashCode(),HashMap
-
hashCode
public int hashCode()
返回此属性集的哈希码值。 属性集的哈希码被定义为AttributeSet中每个条目的哈希码的AttributeSet。 这确保t1.equals(t2)暗示t1.hashCode()==t2.hashCode()对于任何两个属性集t1和t2,根据t2的一般合同的要求 。- Specified by:
-
hashCode在界面AttributeSet - 重写:
-
hashCode在课堂Object - 结果
- 此属性集的哈希码值
- 另请参见:
-
Object.equals(java.lang.Object),System.identityHashCode(java.lang.Object)
-
-