< prev index next >

src/java.desktop/share/classes/javax/print/attribute/PrintServiceAttributeSet.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 package javax.print.attribute;
  28 
  29 /**
  30  * Interface PrintServiceAttributeSet specifies the interface for a set of
  31  * print job attributes, i.e. printing attributes that implement interface
  32  * {@link
  33  * PrintServiceAttribute PrintServiceAttribute}. In the Print Service API,
  34  * the Print Service instance uses a PrintServiceAttributeSet to report the
  35  * status of the print service.
  36  * <P>
  37  * A PrintServiceAttributeSet is just an {@link AttributeSet AttributeSet}
  38  * whose constructors and mutating operations guarantee an additional
  39  * invariant,
  40  * namely that all attribute values in the PrintServiceAttributeSet must be
  41  * instances of interface {@link PrintServiceAttribute PrintServiceAttribute}.
  42  * The {@link #add(Attribute) add(Attribute)}, and
  43  * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations
  44  * are respecified below to guarantee this additional invariant.
  45  *
  46  * @author  Alan Kaminsky
  47  */
  48 public interface PrintServiceAttributeSet extends AttributeSet {
  49 
  50 
  51 
  52     /**
  53      * Adds the specified attribute value to this attribute set if it is not
  54      * already present, first removing any existing value in the same
  55      * attribute category as the specified attribute value (optional
  56      * operation).
  57      *
  58      * @param  attribute  Attribute value to be added to this attribute set.
  59      *
  60      * @return  {@code true} if this attribute set changed as a result of
  61      *          the call, i.e., the given attribute value was not already a
  62      *          member of this attribute set.
  63      *
  64      * @throws  UnmodifiableSetException
  65      *     (unchecked exception) Thrown if this attribute set does not
  66      *     support the {@code add()} operation.
  67      * @throws  ClassCastException
  68      *     (unchecked exception) Thrown if the {@code attribute} is
  69      *     not an instance of interface
  70      *     {@link PrintServiceAttribute PrintServiceAttribute}.
  71      * @throws  NullPointerException
  72      *    (unchecked exception) Thrown if the {@code attribute} is null.
  73      */
  74     public boolean add(Attribute attribute);
  75 
  76     /**
  77      * Adds all of the elements in the specified set to this attribute.
  78      * The outcome is  the same as if the
  79      * {@link #add(Attribute) add(Attribute)}
  80      * operation had been applied to this attribute set successively with
  81      * each element from the specified set. If none of the categories in the
  82      * specified set  are the same as any categories in this attribute set,
  83      * the {@code addAll()} operation effectively modifies this attribute
  84      * set so that its value is the <i>union</i> of the two sets.
  85      * <P>
  86      * The behavior of the {@code addAll()} operation is unspecified if
  87      * the specified set is modified while the operation is in progress.
  88      * <P>
  89      * If the {@code addAll()} operation throws an exception, the effect
  90      * on this attribute set's state is implementation dependent; elements
  91      * from the specified set before the point of the exception may or
  92      * may not have been added to this attribute set.
  93      *
  94      * @param  attributes  whose elements are to be added to this attribute
  95      *            set.
  96      *
  97      * @return  {@code true} if this attribute set changed as a result of
  98      *          the call.
  99      *
 100      * @throws  UnmodifiableSetException
 101      *     (Unchecked exception) Thrown if this attribute set does not
 102      *     support the {@code addAll()} method.
 103      * @throws  ClassCastException
 104      *     (Unchecked exception) Thrown if some element in the specified
 105      *     set is not an instance of interface {@link PrintServiceAttribute
 106      *     PrintServiceAttribute}.
 107      * @throws  NullPointerException
 108      *     (Unchecked exception) Thrown if the specified  set is null.
 109      *
 110      * @see #add(Attribute)
 111      */
 112     public boolean addAll(AttributeSet attributes);
 113 }
   1 /*
   2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 

  26 package javax.print.attribute;
  27 
  28 /**
  29  * Interface {@code PrintServiceAttributeSet} specifies the interface for a set
  30  * of print job attributes, i.e. printing attributes that implement interface
  31  * {@link PrintServiceAttribute PrintServiceAttribute}. In the Print Service
  32  * API, the Print Service instance uses a {@code PrintServiceAttributeSet} to
  33  * report the status of the print service.
  34  * <p>
  35  * A {@code PrintServiceAttributeSet} is just an
  36  * {@link AttributeSet AttributeSet} whose constructors and mutating operations
  37  * guarantee an additional invariant, namely that all attribute values in the
  38  * {@code PrintServiceAttributeSet} must be instances of interface
  39  * {@link PrintServiceAttribute PrintServiceAttribute}. The
  40  * {@link #add(Attribute) add(Attribute)}, and
  41  * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations are respecified
  42  * below to guarantee this additional invariant.

  43  *
  44  * @author Alan Kaminsky
  45  */
  46 public interface PrintServiceAttributeSet extends AttributeSet {
  47 


  48     /**
  49      * Adds the specified attribute value to this attribute set if it is not
  50      * already present, first removing any existing value in the same attribute
  51      * category as the specified attribute value (optional operation).
  52      *
  53      * @param  attribute attribute value to be added to this attribute set
  54      * @return {@code true} if this attribute set changed as a result of the
  55      *         call, i.e., the given attribute value was not already a member of
  56      *         this attribute set
  57      * @throws UnmodifiableSetException if this attribute set does not support
  58      *         the {@code add()} operation
  59      * @throws ClassCastException if the {@code attribute} is not an instance of
  60      *         interface {@link PrintServiceAttribute PrintServiceAttribute}
  61      * @throws NullPointerException if the {@code attribute} is {@code null}







  62      */
  63     public boolean add(Attribute attribute);
  64 
  65     /**
  66      * Adds all of the elements in the specified set to this attribute. The
  67      * outcome is the same as if the {@link #add(Attribute) add(Attribute)}
  68      * operation had been applied to this attribute set successively with each
  69      * element from the specified set. If none of the categories in the
  70      * specified set are the same as any categories in this attribute set, the
  71      * {@code addAll()} operation effectively modifies this attribute set so
  72      * that its value is the <i>union</i> of the two sets.
  73      * <p>
  74      * The behavior of the {@code addAll()} operation is unspecified if the
  75      * specified set is modified while the operation is in progress.
  76      * <p>
  77      * If the {@code addAll()} operation throws an exception, the effect on this
  78      * attribute set's state is implementation dependent; elements from the
  79      * specified set before the point of the exception may or may not have been
  80      * added to this attribute set.
  81      *
  82      * @param  attributes whose elements are to be added to this attribute set
  83      * @return {@code true} if this attribute set changed as a result of the
  84      *         call
  85      * @throws UnmodifiableSetException if this attribute set does not support
  86      *         the {@code addAll()} method
  87      * @throws ClassCastException if some element in the specified set is not an
  88      *         instance of interface
  89      *         {@link PrintServiceAttribute PrintServiceAttribute}
  90      * @throws NullPointerException if the specified set is {@code null}








  91      * @see #add(Attribute)
  92      */
  93     public boolean addAll(AttributeSet attributes);
  94 }
< prev index next >