1 |
/* AttributeSet.java -- |
/* AttributeSet.java -- |
2 |
Copyright (C) 2002 Free Software Foundation, Inc. |
Copyright (C) 2002, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
38 |
package javax.print.attribute; |
package javax.print.attribute; |
39 |
|
|
40 |
/** |
/** |
41 |
* @author Michael Koch |
* <code>AttributeSet</code> is the top-level interface for sets of printing |
42 |
|
* attributes in the Java Print Service API. |
43 |
|
* <p> |
44 |
|
* There are no duplicate values allowed in an attribute set and there is |
45 |
|
* at most one attribute object contained per category type. Based on the |
46 |
|
* {@link java.util.Map} interface the values of attribute sets are objects |
47 |
|
* of type {@link javax.print.attribute.Attribute} and the entries are the |
48 |
|
* categories as {@link java.lang.Class} instances. |
49 |
|
* </p> |
50 |
|
* <p> |
51 |
|
* The following specialized types of <code>AttributeSet</code> are available: |
52 |
|
* <ul> |
53 |
|
* <li>{@link javax.print.attribute.DocAttributeSet}</li> |
54 |
|
* <li>{@link javax.print.attribute.PrintRequestAttributeSet}</li> |
55 |
|
* <li>{@link javax.print.attribute.PrintJobAttributeSet}</li> |
56 |
|
* <li>{@link javax.print.attribute.PrintServiceAttributeSet}</li> |
57 |
|
* </ul> |
58 |
|
* </p> |
59 |
|
* <p> |
60 |
|
* Attribute sets may be unmodifiable depending on the context of usage. If |
61 |
|
* used as read-only attribute set modifying operations throw an |
62 |
|
* {@link javax.print.attribute.UnmodifiableSetException}. |
63 |
|
* </p> |
64 |
|
* <p> |
65 |
|
* The Java Print Service API provides implementation classes for the existing |
66 |
|
* attribute set interfaces but applications may use their own implementations. |
67 |
|
* </p> |
68 |
|
* |
69 |
|
* @author Michael Koch (konqueror@gmx.de) |
70 |
*/ |
*/ |
71 |
public interface AttributeSet |
public interface AttributeSet |
72 |
{ |
{ |
73 |
/** |
/** |
74 |
* Adds the specified attribute value to this attribute set |
* Adds the specified attribute value to this attribute set |
75 |
* if it is not already present. |
* if it is not already present. |
76 |
|
* |
77 |
|
* This operation removes any existing attribute of the same category |
78 |
|
* before adding the given attribute to the set. |
79 |
|
* |
80 |
|
* @param attribute the attribute to add. |
81 |
|
* @return <code>true</code> if the set is changed, false otherwise. |
82 |
|
* @throws NullPointerException if the attribute is <code>null</code>. |
83 |
|
* @throws UnmodifiableSetException if the set does not support modification. |
84 |
*/ |
*/ |
85 |
boolean add (Attribute attribute); |
boolean add (Attribute attribute); |
86 |
|
|
87 |
/** |
/** |
88 |
* Adds all of the elements in the specified set to this attribute. |
* Adds all of the elements in the specified set to this attribute set. |
89 |
|
* |
90 |
|
* @param attributes the set of attributes to add. |
91 |
|
* @return <code>true</code> if the set is changed, false otherwise. |
92 |
|
* @throws UnmodifiableSetException if the set does not support modification. |
93 |
|
* |
94 |
|
* @see #add(Attribute) |
95 |
*/ |
*/ |
96 |
boolean addAll (AttributeSet attributes); |
boolean addAll (AttributeSet attributes); |
97 |
|
|
98 |
|
/** |
99 |
|
* Removes all attributes from this attribute set. |
100 |
|
* |
101 |
|
* @throws UnmodifiableSetException if the set does not support modification. |
102 |
|
*/ |
103 |
void clear (); |
void clear (); |
104 |
|
|
105 |
|
/** |
106 |
|
* Checks if this attributes set contains an attribute with the given |
107 |
|
* category. |
108 |
|
* |
109 |
|
* @param category the category to test for. |
110 |
|
* @return <code>true</code> if an attribute of the category is contained |
111 |
|
* in the set, <code>false</code> otherwise. |
112 |
|
*/ |
113 |
boolean containsKey (Class category); |
boolean containsKey (Class category); |
114 |
|
|
115 |
|
/** |
116 |
|
* Checks if this attribute set contains the given attribute. |
117 |
|
* |
118 |
|
* @param attribute the attribute to test for. |
119 |
|
* @return <code>true</code> if the attribute is contained in the set, |
120 |
|
* <code>false</code> otherwise. |
121 |
|
*/ |
122 |
boolean containsValue (Attribute attribute); |
boolean containsValue (Attribute attribute); |
123 |
|
|
124 |
|
/** |
125 |
|
* Tests this set for equality with the given object. <code>true</code> is |
126 |
|
* returned, if the given object is also of type <code>AttributeSet</code> |
127 |
|
* and the contained attributes are the same as in this set. |
128 |
|
* |
129 |
|
* @param obj the Object to test. |
130 |
|
* @return <code>true</code> if equal, false otherwise. |
131 |
|
*/ |
132 |
boolean equals (Object obj); |
boolean equals (Object obj); |
133 |
|
|
134 |
Attribute get (Class Category); |
/** |
135 |
|
* Returns the attribute object contained in this set for the given attribute |
136 |
|
* category. |
137 |
|
* |
138 |
|
* @param category the category of the attribute. A <code>Class</code> |
139 |
|
* instance of a class implementing the <code>Attribute</code> interface. |
140 |
|
* @return The attribute for this category or <code>null</code> if no |
141 |
|
* attribute is contained for the given category. |
142 |
|
* @throws NullPointerException if category is null. |
143 |
|
* @throws ClassCastException if category is not implementing |
144 |
|
* <code>Attribute</code>. |
145 |
|
*/ |
146 |
|
Attribute get (Class category); |
147 |
|
|
148 |
|
/** |
149 |
|
* Returns the hashcode value. The hashcode value is the sum of all hashcodes |
150 |
|
* of the attributes contained in this set. |
151 |
|
* |
152 |
|
* @return The hashcode for this attribute set. |
153 |
|
*/ |
154 |
int hashCode (); |
int hashCode (); |
155 |
|
|
156 |
|
/** |
157 |
|
* Checks if the attribute set is empty. |
158 |
|
* |
159 |
|
* @return <code>true</code> if the attribute set is empty, false otherwise. |
160 |
|
*/ |
161 |
boolean isEmpty (); |
boolean isEmpty (); |
162 |
|
|
163 |
|
/** |
164 |
|
* Removes the given attribute from the set. If the given attribute is <code>null</code> |
165 |
|
* nothing is done and <code>false</code> is returned. |
166 |
|
* |
167 |
|
* @param attribute the attribute to remove. |
168 |
|
* @return <code>true</code> if removed, false in all other cases. |
169 |
|
* @throws UnmodifiableSetException if the set does not support modification. |
170 |
|
*/ |
171 |
boolean remove (Attribute attribute); |
boolean remove (Attribute attribute); |
172 |
|
|
173 |
|
/** |
174 |
|
* Removes the attribute entry of the given category from the set. If the given |
175 |
|
* category is <code>null</code> nothing is done and <code>false</code> is returned. |
176 |
|
* |
177 |
|
* @param category the category of the entry to be removed. |
178 |
|
* @return <code>true</code> if an attribute is removed, false in all other cases. |
179 |
|
* @throws UnmodifiableSetException if the set does not support modification. |
180 |
|
*/ |
181 |
boolean remove (Class category); |
boolean remove (Class category); |
182 |
|
|
183 |
|
/** |
184 |
|
* Returns the number of elements in this attribute set. |
185 |
|
* |
186 |
|
* @return The number of elements. |
187 |
|
*/ |
188 |
int size (); |
int size (); |
189 |
|
|
190 |
|
/** |
191 |
|
* Returns the content of the attribute set as an array |
192 |
|
* |
193 |
|
* @return An array of attributes. |
194 |
|
*/ |
195 |
Attribute[] toArray (); |
Attribute[] toArray (); |
196 |
} |
} |