APIdia Launch Partner
Top Description Fields Constructors Methods
javax.print.attribute

public Class HashAttributeSet

extends Object
implements AttributeSet, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.print.attribute.AttributeSet
Known Direct Subclasses
javax.print.attribute.HashDocAttributeSet, javax.print.attribute.HashPrintJobAttributeSet, javax.print.attribute.HashPrintRequestAttributeSet, javax.print.attribute.HashPrintServiceAttributeSet
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serial, .Serializable, java.util.HashMap

Class HashAttributeSet provides an AttributeSet implementation with characteristics of a hash map.
Author
Alan Kaminsky

Field Summary

Modifier and TypeField and Description
private transient HashMap<Class<?>, Attribute>
attrMap

A HashMap used by the implementation.

private Class<?>
myInterface

The interface of which all members of this attribute set must be an instance.

private static final long
serialVersionUID

Use serialVersionUID from JDK 1.4 for interoperability.

Constructor Summary

AccessConstructor and Description
public
HashAttributeSet()

Construct a new, empty attribute set.

public
HashAttributeSet(Attribute
attribute value to add to the set
attribute
)

Construct a new attribute set, initially populated with the given attribute.

public
HashAttributeSet(Attribute[]
array of attribute values to add to the set. If null, an empty attribute set is constructed.
attributes
)

Construct a new attribute set, initially populated with the values from the given array.

public
HashAttributeSet(AttributeSet
set of attributes from which to initialise this set. If null, an empty attribute set is constructed.
attributes
)

Construct a new attribute set, initially populated with the values from the given set.

protected
HashAttributeSet(Class<?>
the interface of which all members of this attribute set must be an instance. It is assumed to be interface Attribute or a subinterface thereof.
interfaceName
)

Construct a new, empty attribute set, where the members of the attribute set are restricted to the given interface.

protected
HashAttributeSet(Attribute
attribute value to add to the set
attribute
,
Class<?>
the interface of which all members of this attribute set must be an instance. It is assumed to be interface Attribute or a subinterface thereof.
interfaceName
)

Construct a new attribute set, initially populated with the given attribute, where the members of the attribute set are restricted to the given interface.

protected
HashAttributeSet(Attribute[]
array of attribute values to add to the set. If null, an empty attribute set is constructed.
attributes
,
Class<?>
the interface of which all members of this attribute set must be an instance. It is assumed to be interface Attribute or a subinterface thereof.
interfaceName
)

Construct a new attribute set, where the members of the attribute set are restricted to the given interface.

protected
HashAttributeSet(AttributeSet
set of attribute values to initialise the set. If null, an empty attribute set is constructed.
attributes
,
Class<?>
The interface of which all members of this attribute set must be an instance. It is assumed to be interface Attribute or a subinterface thereof.
interfaceName
)

Construct a new attribute set, initially populated with the values from the given set where the members of the attribute set are restricted to the given interface.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this attribute set changed as a result of the call, i.e., the given attribute value was not already a member of this attribute set
add
(Attribute
attribute value to be added to this attribute set
attribute
)

Implements javax.print.attribute.AttributeSet.add.

Adds the specified attribute to this attribute set if it is not already present, first removing any existing in the same attribute category as the specified attribute value.

public boolean

Returns:

true if this attribute set changed as a result of the call
addAll
(AttributeSet
whose elements are to be added to this attribute set
attributes
)

Implements javax.print.attribute.AttributeSet.addAll.

Adds all of the elements in the specified set to this attribute.

public void
clear()

Implements javax.print.attribute.AttributeSet.clear.

Removes all attributes from this attribute set.

public boolean

Returns:

true if this attribute set contains an attribute value for the specified category
containsKey
(Class<?>
whose presence in this attribute set is to be tested
category
)

Implements javax.print.attribute.AttributeSet.containsKey.

Returns true if this attribute set contains an attribute for the specified category.

public boolean

Returns:

true if this attribute set contains the given attribute value
containsValue
(Attribute
value whose presence in this attribute set is to be tested
attribute
)

Implements javax.print.attribute.AttributeSet.containsValue.

Returns true if this attribute set contains the given attribute.

public boolean

Returns:

true if the specified object is equal to this attribute set
equals
(Object
to be compared for equality with this attribute set
object
)

Overrides java.lang.Object.equals.

Implements javax.print.attribute.AttributeSet.equals.

Compares the specified object with this attribute set for equality.

public Attribute

Returns:

the attribute value in the given attribute category contained in this attribute set, or null if this attribute set does not contain any attribute value in the given attribute category
get
(Class<?>
attribute category whose associated attribute value is to be returned. It must be a Class that implements interface Attribute.
category
)

Implements javax.print.attribute.AttributeSet.get.

Returns the attribute value which this attribute set contains in the given attribute category.

public int

Returns:

the hash code value for this attribute set
hashCode
()

Overrides java.lang.Object.hashCode.

Implements javax.print.attribute.AttributeSet.hashCode.

Returns the hash code value for this attribute set.

public boolean

Returns:

true if this attribute set contains no attributes
isEmpty
()

Implements javax.print.attribute.AttributeSet.isEmpty.

Returns true if this attribute set contains no attributes.

private void
readObject(ObjectInputStream
the input stream
s
)

Reconstitute an instance from a stream that is, deserialize it).

public boolean

Returns:

true if this attribute set changed as a result of the call, i.e., the given attribute category had been a member of this attribute set
remove
(Class<?>
attribute category to be removed from this attribute set
category
)

Implements javax.print.attribute.AttributeSet.remove.

Removes any attribute for this category from this attribute set if present.

public boolean

Returns:

true if this attribute set changed as a result of the call, i.e., the given attribute value had been a member of this attribute set
remove
(Attribute
attribute value to be removed from this attribute set
attribute
)

Implements javax.print.attribute.AttributeSet.remove.

Removes the specified attribute from this attribute set if present.

public int

Returns:

the number of attributes in this attribute set
size
()

Implements javax.print.attribute.AttributeSet.size.

Returns the number of attributes in this attribute set.

public Attribute[]

Returns:

the attributes contained in this set as an array, zero length if the AttributeSet is empty
toArray
()

Implements javax.print.attribute.AttributeSet.toArray.

Returns an array of the attributes contained in this set.

private void
writeObject(ObjectOutputStream
the output stream
s
)

Write the instance to a stream (ie serialize the object).

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

attrMapback to summary
private transient HashMap<Class<?>, Attribute> attrMap

A HashMap used by the implementation. The serialised form doesn't include this instance variable.

myInterfaceback to summary
private Class<?> myInterface

The interface of which all members of this attribute set must be an instance. It is assumed to be interface Attribute or a subinterface thereof.

serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 1.4 for interoperability.

Annotations
@Serial

Constructor Detail

HashAttributeSetback to summary
public HashAttributeSet()

Construct a new, empty attribute set.

HashAttributeSetback to summary
public HashAttributeSet(Attribute attribute)

Construct a new attribute set, initially populated with the given attribute.

Parameters
attribute:Attribute

attribute value to add to the set

Exceptions
NullPointerException:
if attribute is null
HashAttributeSetback to summary
public HashAttributeSet(Attribute[] attributes)

Construct a new attribute set, initially populated with the values from the given array. The new attribute set is populated by adding the elements of attributes array to the set in sequence, starting at index 0. Thus, later array elements may replace earlier array elements if the array contains duplicate attribute values or attribute categories.

Parameters
attributes:Attribute[]

array of attribute values to add to the set. If null, an empty attribute set is constructed.

Exceptions
NullPointerException:
if any element of attributes is null
HashAttributeSetback to summary
public HashAttributeSet(AttributeSet attributes)

Construct a new attribute set, initially populated with the values from the given set.

Parameters
attributes:AttributeSet

set of attributes from which to initialise this set. If null, an empty attribute set is constructed.

HashAttributeSetback to summary
protected HashAttributeSet(Class<?> interfaceName)

Construct a new, empty attribute set, where the members of the attribute set are restricted to the given interface.

Parameters
interfaceName:Class<?>

the interface of which all members of this attribute set must be an instance. It is assumed to be interface Attribute or a subinterface thereof.

Exceptions
NullPointerException:
if interfaceName is null
HashAttributeSetback to summary
protected HashAttributeSet(Attribute attribute, Class<?> interfaceName)

Construct a new attribute set, initially populated with the given attribute, where the members of the attribute set are restricted to the given interface.

Parameters
attribute:Attribute

attribute value to add to the set

interfaceName:Class<?>

the interface of which all members of this attribute set must be an instance. It is assumed to be interface Attribute or a subinterface thereof.

Exceptions
NullPointerException:
if attribute or interfaceName are null
ClassCastException:
if attribute is not an instance of interfaceName
HashAttributeSetback to summary
protected HashAttributeSet(Attribute[] attributes, Class<?> interfaceName)

Construct a new attribute set, where the members of the attribute set are restricted to the given interface. The new attribute set is populated by adding the elements of attributes array to the set in sequence, starting at index 0. Thus, later array elements may replace earlier array elements if the array contains duplicate attribute values or attribute categories.

Parameters
attributes:Attribute[]

array of attribute values to add to the set. If null, an empty attribute set is constructed.

interfaceName:Class<?>

the interface of which all members of this attribute set must be an instance. It is assumed to be interface Attribute or a subinterface thereof.

Exceptions
NullPointerException:
if interfaceName is null, or if any element of attributes is null
ClassCastException:
if any element of attributes is not an instance of interfaceName
HashAttributeSetback to summary
protected HashAttributeSet(AttributeSet attributes, Class<?> interfaceName)

Construct a new attribute set, initially populated with the values from the given set where the members of the attribute set are restricted to the given interface.

Parameters
attributes:AttributeSet

set of attribute values to initialise the set. If null, an empty attribute set is constructed.

interfaceName:Class<?>

The interface of which all members of this attribute set must be an instance. It is assumed to be interface Attribute or a subinterface thereof.

Exceptions
ClassCastException:
if any element of attributes is not an instance of interfaceName

Method Detail

addback to summary
public boolean add(Attribute attribute)

Implements javax.print.attribute.AttributeSet.add.

Adds the specified attribute to this attribute set if it is not already present, first removing any existing in the same attribute category as the specified attribute value.

Parameters
attribute:Attribute

attribute value to be added to this attribute set

Returns:boolean

true if this attribute set changed as a result of the call, i.e., the given attribute value was not already a member of this attribute set

Annotations
@Override
Exceptions
NullPointerException:
if the attribute is null
UnmodifiableSetException:
if this attribute set does not support the add() operation
addAllback to summary
public boolean addAll(AttributeSet attributes)

Implements javax.print.attribute.AttributeSet.addAll.

Adds all of the elements in the specified set to this attribute. The outcome is the same as if the add(Attribute) operation had been applied to this attribute set successively with each element from the specified set. The behavior of the addAll(AttributeSet) operation is unspecified if the specified set is modified while the operation is in progress.

If the addAll(AttributeSet) operation throws an exception, the effect on this attribute set's state is implementation dependent; elements from the specified set before the point of the exception may or may not have been added to this attribute set.

Parameters
attributes:AttributeSet

whose elements are to be added to this attribute set

Returns:boolean

true if this attribute set changed as a result of the call

Annotations
@Override
Exceptions
UnmodifiableSetException:
if this attribute set does not support the addAll(AttributeSet) method
NullPointerException:
if some element in the specified set is null, or the set is null
See Also
add(Attribute)
clearback to summary
public void clear()

Implements javax.print.attribute.AttributeSet.clear.

Removes all attributes from this attribute set.

Annotations
@Override
Exceptions
UnmodifiableSetException:
if this attribute set does not support the clear() operation
containsKeyback to summary
public boolean containsKey(Class<?> category)

Implements javax.print.attribute.AttributeSet.containsKey.

Returns true if this attribute set contains an attribute for the specified category.

Parameters
category:Class<?>

whose presence in this attribute set is to be tested

Returns:boolean

true if this attribute set contains an attribute value for the specified category

Annotations
@Override
containsValueback to summary
public boolean containsValue(Attribute attribute)

Implements javax.print.attribute.AttributeSet.containsValue.

Returns true if this attribute set contains the given attribute.

Parameters
attribute:Attribute

value whose presence in this attribute set is to be tested

Returns:boolean

true if this attribute set contains the given attribute value

Annotations
@Override
equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Implements javax.print.attribute.AttributeSet.equals.

Compares the specified object with this attribute set for equality. Returns true if the given object is also an attribute set and the two attribute sets contain the same attribute category-attribute value mappings. This ensures that the equals() method works properly across different implementations of the AttributeSet interface.

Parameters
object:Object

to be compared for equality with this attribute set

Returns:boolean

true if the specified object is equal to this attribute set

Annotations
@Override
getback to summary
public Attribute get(Class<?> category)

Implements javax.print.attribute.AttributeSet.get.

Returns the attribute value which this attribute set contains in the given attribute category. Returns null if this attribute set does not contain any attribute value in the given attribute category.

Parameters
category:Class<?>

attribute category whose associated attribute value is to be returned. It must be a Class that implements interface Attribute.

Returns:Attribute

the attribute value in the given attribute category contained in this attribute set, or null if this attribute set does not contain any attribute value in the given attribute category

Annotations
@Override
Exceptions
NullPointerException:
if the category is null
ClassCastException:
if the category is not a Class that implements interface Attribute
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements javax.print.attribute.AttributeSet.hashCode.

Returns the hash code value for this attribute set. The hash code of an attribute set is defined to be the sum of the hash codes of each entry in the AttributeSet. This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two attribute sets t1 and t2, as required by the general contract of Object.hashCode().

Returns:int

the hash code value for this attribute set

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements javax.print.attribute.AttributeSet.isEmpty.

Returns true if this attribute set contains no attributes.

Returns:boolean

true if this attribute set contains no attributes

Annotations
@Override
readObjectback to summary
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException

Reconstitute an instance from a stream that is, deserialize it).

Parameters
s:ObjectInputStream

the input stream

Annotations
@Serial
Exceptions
ClassNotFoundException:
if the class is not found
IOException:
if an I/O exception has occurred
removeback to summary
public boolean remove(Class<?> category)

Implements javax.print.attribute.AttributeSet.remove.

Removes any attribute for this category from this attribute set if present. If category is null, then remove() does nothing and returns false.

Parameters
category:Class<?>

attribute category to be removed from this attribute set

Returns:boolean

true if this attribute set changed as a result of the call, i.e., the given attribute category had been a member of this attribute set

Annotations
@Override
Exceptions
UnmodifiableSetException:
if this attribute set does not support the remove() operation
removeback to summary
public boolean remove(Attribute attribute)

Implements javax.print.attribute.AttributeSet.remove.

Removes the specified attribute from this attribute set if present. If attribute is null, then remove() does nothing and returns false.

Parameters
attribute:Attribute

attribute value to be removed from this attribute set

Returns:boolean

true if this attribute set changed as a result of the call, i.e., the given attribute value had been a member of this attribute set

Annotations
@Override
Exceptions
UnmodifiableSetException:
if this attribute set does not support the remove() operation
sizeback to summary
public int size()

Implements javax.print.attribute.AttributeSet.size.

Returns the number of attributes in this attribute set. If this attribute set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of attributes in this attribute set

Annotations
@Override
toArrayback to summary
public Attribute[] toArray()

Implements javax.print.attribute.AttributeSet.toArray.

Returns an array of the attributes contained in this set.

Returns:Attribute[]

the attributes contained in this set as an array, zero length if the AttributeSet is empty

Annotations
@Override
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Write the instance to a stream (ie serialize the object).

Parameters
s:ObjectOutputStream

the output stream

Annotations
@Serial
Exceptions
IOException:
if an I/O exception has occurred
Serial data
The serialized form of an attribute set explicitly writes the number of attributes in the set, and each of the attributes. This does not guarantee equality of serialized forms since the order in which the attributes are written is not defined.