Class AttributeSetUtilities
AttributeSetUtilities provides static methods for manipulating
AttributeSets.
- Methods for creating unmodifiable and synchronized views of attribute sets.
- operations useful for building implementations of interface
AttributeSet
AttributeSet S
provides a client with "read-only" access to S. Query operations on
U "read through" to S; thus, changes in S are reflected
in U. However, any attempt to modify U, results in an
UnmodifiableSetException. The unmodifiable view object U will
be serializable if the attribute set object S is serializable.
A synchronized view V of an attribute set S provides a client with synchronized (multiple thread safe) access to S. Each operation of V is synchronized using V itself as the lock object and then merely invokes the corresponding operation of S. In order to guarantee mutually exclusive access, it is critical that all access to S is accomplished through V. The synchronized view object V will be serializable if the attribute set object S is serializable.
As mentioned in the package description of javax.print, a
null reference parameter to methods is incorrect unless explicitly
documented on the method as having a meaningful interpretation. Usage to the
contrary is incorrect coding and may result in a run time exception either
immediately or at some later time. IllegalArgumentException and
NullPointerException are examples of typical and acceptable run time
exceptions for such cases.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AttributeSetsynchronizedView(AttributeSet attributeSet) Creates a synchronized view of the given attribute set.static DocAttributeSetsynchronizedView(DocAttributeSet attributeSet) Creates a synchronized view of the given doc attribute set.static PrintJobAttributeSetsynchronizedView(PrintJobAttributeSet attributeSet) Creates a synchronized view of the given print job attribute set.static PrintRequestAttributeSetsynchronizedView(PrintRequestAttributeSet attributeSet) Creates a synchronized view of the given print request attribute set.static PrintServiceAttributeSetsynchronizedView(PrintServiceAttributeSet attributeSet) Creates a synchronized view of the given print service attribute set.static AttributeSetunmodifiableView(AttributeSet attributeSet) Creates an unmodifiable view of the given attribute set.static DocAttributeSetunmodifiableView(DocAttributeSet attributeSet) Creates an unmodifiable view of the given doc attribute set.static PrintJobAttributeSetunmodifiableView(PrintJobAttributeSet attributeSet) Creates an unmodifiable view of the given print job attribute set.static PrintRequestAttributeSetunmodifiableView(PrintRequestAttributeSet attributeSet) Creates an unmodifiable view of the given print request attribute set.static PrintServiceAttributeSetunmodifiableView(PrintServiceAttributeSet attributeSet) Creates an unmodifiable view of the given print service attribute set.static Class<?> verifyAttributeCategory(Object object, Class<?> interfaceName) static AttributeverifyAttributeValue(Object object, Class<?> interfaceName) Verify that the given object is an instance of the given interface, which is assumed to be interfaceAttributeor a subinterface thereof.static voidverifyCategoryForValue(Class<?> category, Attribute attribute) Verify that the given attribute category object is equal to the category of the given attribute value object.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Method Details
-
unmodifiableView
Creates an unmodifiable view of the given attribute set.- Parameters:
attributeSet- underlying attribute set- Returns:
- unmodifiable view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
unmodifiableView
Creates an unmodifiable view of the given doc attribute set.- Parameters:
attributeSet- underlying doc attribute set- Returns:
- unmodifiable view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
unmodifiableView
Creates an unmodifiable view of the given print request attribute set.- Parameters:
attributeSet- underlying print request attribute set- Returns:
- unmodifiable view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
unmodifiableView
Creates an unmodifiable view of the given print job attribute set.- Parameters:
attributeSet- underlying print job attribute set- Returns:
- unmodifiable view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
unmodifiableView
Creates an unmodifiable view of the given print service attribute set.- Parameters:
attributeSet- underlying print service attribute set- Returns:
- unmodifiable view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
synchronizedView
Creates a synchronized view of the given attribute set.- Parameters:
attributeSet- underlying attribute set- Returns:
- synchronized view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
synchronizedView
Creates a synchronized view of the given doc attribute set.- Parameters:
attributeSet- underlying doc attribute set- Returns:
- synchronized view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
synchronizedView
Creates a synchronized view of the given print request attribute set.- Parameters:
attributeSet- underlying print request attribute set- Returns:
- synchronized view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
synchronizedView
Creates a synchronized view of the given print job attribute set.- Parameters:
attributeSet- underlying print job attribute set- Returns:
- synchronized view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
synchronizedView
Creates a synchronized view of the given print service attribute set.- Parameters:
attributeSet- underlying print service attribute set- Returns:
- synchronized view of
attributeSet - Throws:
NullPointerException- ifattributeSetisnull
-
verifyAttributeCategory
Verify that the given object is aClassthat implements the given interface, which is assumed to be interfaceAttributeor a subinterface thereof.- Parameters:
object-Objectto testinterfaceName- interface the object must implement- Returns:
- if
objectis aClassthat implementsinterfaceName,objectis returned downcast to typeClass; otherwise an exception is thrown - Throws:
NullPointerException- ifobjectisnullClassCastException- ifobjectis not aClassthat implementsinterfaceName
-
verifyAttributeValue
Verify that the given object is an instance of the given interface, which is assumed to be interfaceAttributeor a subinterface thereof.- Parameters:
object-Objectto testinterfaceName- interface of which the object must be an instance- Returns:
- if
objectis an instance ofinterfaceName,objectis returned downcast to typeAttribute; otherwise an exception is thrown - Throws:
NullPointerException- ifobjectisnullClassCastException- ifobjectis not an instance ofinterfaceName
-
verifyCategoryForValue
Verify that the given attribute category object is equal to the category of the given attribute value object. If so, this method returns doing nothing. If not, this method throws an exception.- Parameters:
category- attribute category to testattribute- attribute value to test- Throws:
NullPointerException- if thecategoryorattributearenullIllegalArgumentException- if thecategoryis not equal to the category of theattribute
-