| 1 |
772 |
jeremybenn |
/* AttributeSet.java --
|
| 2 |
|
|
Copyright (C) 2002, 2005 Free Software Foundation, Inc.
|
| 3 |
|
|
|
| 4 |
|
|
This file is part of GNU Classpath.
|
| 5 |
|
|
|
| 6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
| 7 |
|
|
it under the terms of the GNU General Public License as published by
|
| 8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
| 9 |
|
|
any later version.
|
| 10 |
|
|
|
| 11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
| 12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
|
|
General Public License for more details.
|
| 15 |
|
|
|
| 16 |
|
|
You should have received a copy of the GNU General Public License
|
| 17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
| 18 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
| 19 |
|
|
02110-1301 USA.
|
| 20 |
|
|
|
| 21 |
|
|
Linking this library statically or dynamically with other modules is
|
| 22 |
|
|
making a combined work based on this library. Thus, the terms and
|
| 23 |
|
|
conditions of the GNU General Public License cover the whole
|
| 24 |
|
|
combination.
|
| 25 |
|
|
|
| 26 |
|
|
As a special exception, the copyright holders of this library give you
|
| 27 |
|
|
permission to link this library with independent modules to produce an
|
| 28 |
|
|
executable, regardless of the license terms of these independent
|
| 29 |
|
|
modules, and to copy and distribute the resulting executable under
|
| 30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
| 31 |
|
|
independent module, the terms and conditions of the license of that
|
| 32 |
|
|
module. An independent module is a module which is not derived from
|
| 33 |
|
|
or based on this library. If you modify this library, you may extend
|
| 34 |
|
|
this exception to your version of the library, but you are not
|
| 35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
| 36 |
|
|
exception statement from your version. */
|
| 37 |
|
|
|
| 38 |
|
|
package javax.print.attribute;
|
| 39 |
|
|
|
| 40 |
|
|
/**
|
| 41 |
|
|
* <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
|
| 72 |
|
|
{
|
| 73 |
|
|
/**
|
| 74 |
|
|
* Adds the specified attribute value to this attribute set
|
| 75 |
|
|
* 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);
|
| 86 |
|
|
|
| 87 |
|
|
/**
|
| 88 |
|
|
* 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);
|
| 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 ();
|
| 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);
|
| 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);
|
| 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);
|
| 133 |
|
|
|
| 134 |
|
|
/**
|
| 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 ();
|
| 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 ();
|
| 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);
|
| 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);
|
| 182 |
|
|
|
| 183 |
|
|
/**
|
| 184 |
|
|
* Returns the number of elements in this attribute set.
|
| 185 |
|
|
*
|
| 186 |
|
|
* @return The number of elements.
|
| 187 |
|
|
*/
|
| 188 |
|
|
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 ();
|
| 196 |
|
|
}
|