- java.lang.Object
-
- javax.print.attribute.AttributeSetUtilities
-
public final class AttributeSetUtilities extends Object
Class 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
An unmodifiable view U of an 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
Methods Modifier and Type Method and Description static AttributeSet
synchronizedView(AttributeSet attributeSet)
Creates a synchronized view of the given attribute set.static DocAttributeSet
synchronizedView(DocAttributeSet attributeSet)
Creates a synchronized view of the given doc attribute set.static PrintJobAttributeSet
synchronizedView(PrintJobAttributeSet attributeSet)
Creates a synchronized view of the given print job attribute set.static PrintRequestAttributeSet
synchronizedView(PrintRequestAttributeSet attributeSet)
Creates a synchronized view of the given print request attribute set.static PrintServiceAttributeSet
synchronizedView(PrintServiceAttributeSet attributeSet)
Creates a synchronized view of the given print service attribute set.static AttributeSet
unmodifiableView(AttributeSet attributeSet)
Creates an unmodifiable view of the given attribute set.static DocAttributeSet
unmodifiableView(DocAttributeSet attributeSet)
Creates an unmodifiable view of the given doc attribute set.static PrintJobAttributeSet
unmodifiableView(PrintJobAttributeSet attributeSet)
Creates an unmodifiable view of the given print job attribute set.static PrintRequestAttributeSet
unmodifiableView(PrintRequestAttributeSet attributeSet)
Creates an unmodifiable view of the given print request attribute set.static PrintServiceAttributeSet
unmodifiableView(PrintServiceAttributeSet attributeSet)
Creates an unmodifiable view of the given print service attribute set.static Class<?>
verifyAttributeCategory(Object object, Class<?> interfaceName)
static Attribute
verifyAttributeValue(Object object, Class<?> interfaceName)
Verify that the given object is an instance of the given interface, which is assumed to be interfaceAttribute
or a subinterface thereof.static void
verifyCategoryForValue(Class<?> category, Attribute attribute)
Verify that the given attribute category object is equal to the category of the given attribute value object.
-
-
-
Method Detail
-
unmodifiableView
public static AttributeSet unmodifiableView(AttributeSet attributeSet)
Creates an unmodifiable view of the given attribute set.- Parameters:
attributeSet
- Underlying attribute set.- Returns:
- Unmodifiable view of
attributeSet
. - Throws:
NullPointerException
- Thrown ifattributeSet
is null. Null is never a
-
unmodifiableView
public static DocAttributeSet unmodifiableView(DocAttributeSet attributeSet)
Creates an unmodifiable view of the given doc attribute set.- Parameters:
attributeSet
- Underlying doc attribute set.- Returns:
- Unmodifiable view of
attributeSet
. - Throws:
NullPointerException
- Thrown ifattributeSet
is null.
-
unmodifiableView
public static PrintRequestAttributeSet unmodifiableView(PrintRequestAttributeSet attributeSet)
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
- Thrown ifattributeSet
is null.
-
unmodifiableView
public static PrintJobAttributeSet unmodifiableView(PrintJobAttributeSet attributeSet)
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
- Thrown ifattributeSet
is null.
-
unmodifiableView
public static PrintServiceAttributeSet unmodifiableView(PrintServiceAttributeSet attributeSet)
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
- Thrown ifattributeSet
is null.
-
synchronizedView
public static AttributeSet synchronizedView(AttributeSet attributeSet)
Creates a synchronized view of the given attribute set.- Parameters:
attributeSet
- Underlying attribute set.- Returns:
- Synchronized view of
attributeSet
. - Throws:
NullPointerException
- Thrown ifattributeSet
is null.
-
synchronizedView
public static DocAttributeSet synchronizedView(DocAttributeSet attributeSet)
Creates a synchronized view of the given doc attribute set.- Parameters:
attributeSet
- Underlying doc attribute set.- Returns:
- Synchronized view of
attributeSet
. - Throws:
NullPointerException
- Thrown ifattributeSet
is null.
-
synchronizedView
public static PrintRequestAttributeSet synchronizedView(PrintRequestAttributeSet attributeSet)
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
- Thrown ifattributeSet
is null.
-
synchronizedView
public static PrintJobAttributeSet synchronizedView(PrintJobAttributeSet attributeSet)
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
- Thrown ifattributeSet
is null.
-
synchronizedView
public static PrintServiceAttributeSet synchronizedView(PrintServiceAttributeSet attributeSet)
Creates a synchronized view of the given print service attribute set.- Parameters:
attributeSet
- Underlying print service attribute set.- Returns:
- Synchronized view of
attributeSet
.
-
verifyAttributeCategory
public static Class<?> verifyAttributeCategory(Object object, Class<?> interfaceName)
Verify that the given object is aClass
that implements the given interface, which is assumed to be interfaceAttribute
or a subinterface thereof.- Parameters:
object
- Object to test.interfaceName
- Interface the object must implement.- Returns:
- If
object
is aClass
that implementsinterfaceName
,object
is returned downcast to typeClass
; otherwise an exception is thrown. - Throws:
NullPointerException
- (unchecked exception) Thrown ifobject
is null.ClassCastException
- (unchecked exception) Thrown ifobject
is not aClass
that implementsinterfaceName
.
-
verifyAttributeValue
public static Attribute verifyAttributeValue(Object object, Class<?> interfaceName)
Verify that the given object is an instance of the given interface, which is assumed to be interfaceAttribute
or a subinterface thereof.- Parameters:
object
- Object to test.interfaceName
- Interface of which the object must be an instance.- Returns:
- If
object
is an instance ofinterfaceName
,object
is returned downcast to typeAttribute
; otherwise an exception is thrown. - Throws:
NullPointerException
- (unchecked exception) Thrown ifobject
is null.ClassCastException
- (unchecked exception) Thrown ifobject
is not an instance ofinterfaceName
.
-
verifyCategoryForValue
public static void verifyCategoryForValue(Class<?> category, Attribute attribute)
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 test.attribute
- Attribute value to test.- Throws:
NullPointerException
- (unchecked exception) Thrown if thecategory
is null or if theattribute
is null.IllegalArgumentException
- (unchecked exception) Thrown if thecategory
is not equal to the category of theattribute
.
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/print/attribute/AttributeSetUtilities.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.