1 /* 2 * @(#)DocAttributeSet.java 1.5 03/12/19 3 * 4 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 6 */ 7 8 9 package javax.print.attribute; 10 11 /** 12 * Interface DocAttributeSet specifies the interface for a set of doc 13 * attributes, i.e. printing attributes that implement interface {@link 14 * DocAttribute DocAttribute}. In the Print Service API, the client uses a 15 * DocAttributeSet to specify the characteristics of an individual doc and 16 * the print job settings to be applied to an individual doc. 17 * <P> 18 * A DocAttributeSet is just an {@link AttributeSet AttributeSet} whose 19 * constructors and mutating operations guarantee an additional invariant, 20 * namely that all attribute values in the DocAttributeSet must be instances 21 * of interface {@link DocAttribute DocAttribute}. 22 * The {@link #add(Attribute) <CODE>add(Attribute)</CODE>}, and 23 * {@link #addAll(AttributeSet) <CODE>addAll(AttributeSet)</CODE>} operations 24 * are respecified below to guarantee this additional invariant. 25 * <P> 26 * 27 * @author Alan Kaminsky 28 */ 29 public interface DocAttributeSet extends AttributeSet { 30 31 32 /** 33 * Adds the specified attribute value to this attribute set if it is not 34 * already present, first removing any existing value in the same 35 * attribute category as the specified attribute value (optional 36 * operation). 37 * 38 * @param attribute Attribute value to be added to this attribute set. 39 * 40 * @return <tt>true</tt> if this attribute set changed as a result of 41 * the call, i.e., the given attribute value was not already a 42 * member of this attribute set. 43 * 44 * @throws UnmodifiableSetException 45 * (unchecked exception) Thrown if this attribute set does not 46 * support the <CODE>add()</CODE> operation. 47 * @throws ClassCastException 48 * (unchecked exception) Thrown if the <CODE>attribute</CODE> is 49 * not an instance of interface 50 * {@link DocAttribute DocAttribute}. 51 * @throws NullPointerException 52 * (unchecked exception) Thrown if the <CODE>attribute</CODE> is null. 53 */ 54 public boolean add(Attribute attribute); 55 56 /** 57 * Adds all of the elements in the specified set to this attribute. 58 * The outcome is the same as if the 59 * {@link #add(Attribute) <CODE>add(Attribute)</CODE>} 60 * operation had been applied to this attribute set successively with 61 * each element from the specified set. If none of the categories in the 62 * specified set are the same as any categories in this attribute set, 63 * the <tt>addAll()</tt> operation effectively modifies this attribute 64 * set so that its value is the <i>union</i> of the two sets. 65 * <P> 66 * The behavior of the <CODE>addAll()</CODE> operation is unspecified if 67 * the specified set is modified while the operation is in progress. 68 * <P> 69 * If the <CODE>addAll()</CODE> operation throws an exception, the effect 70 * on this attribute set's state is implementation dependent; elements 71 * from the specified set before the point of the exception may or 72 * may not have been added to this attribute set. 73 * 74 * @param attributes whose elements are to be added to this attribute 75 * set. 76 * 77 * @return <tt>true</tt> if this attribute set changed as a result of 78 * the call. 79 * 80 * @throws UnmodifiableSetException 81 * (Unchecked exception) Thrown if this attribute set does not 82 * support the <tt>addAll()</tt> method. 83 * @throws ClassCastException 84 * (Unchecked exception) Thrown if some element in the specified 85 * set is not an instance of interface {@link DocAttribute 86 * DocAttribute}. 87 * @throws NullPointerException 88 * (Unchecked exception) Thrown if the specified set is null. 89 * 90 * @see #add(Attribute) 91 */ 92 public boolean addAll(AttributeSet attributes); 93 } 94