Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/print/attribute/standard/Media.java
38918 views
/*1* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package javax.print.attribute.standard;2526import javax.print.attribute.Attribute;27import javax.print.attribute.DocAttribute;28import javax.print.attribute.EnumSyntax;29import javax.print.attribute.PrintRequestAttribute;30import javax.print.attribute.PrintJobAttribute;3132/**33* Class Media is a printing attribute class that specifies the34* medium on which to print.35* <p>36* Media may be specified in different ways.37* <ul>38* <li> it may be specified by paper source - eg paper tray39* <li> it may be specified by a standard size - eg "A4"40* <li> it may be specified by a name - eg "letterhead"41* </ul>42* Each of these corresponds to the IPP "media" attribute.43* The current API does not support describing media by characteristics44* (eg colour, opacity).45* This may be supported in a later revision of the specification.46* <p>47* A Media object is constructed with a value which represents48* one of the ways in which the Media attribute can be specified.49* <p>50* <B>IPP Compatibility:</B> The category name returned by51* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's52* integer value is the IPP enum value. The <code>toString()</code> method53* returns the IPP string representation of the attribute value.54* <P>55*56* @author Phil Race57*/58public abstract class Media extends EnumSyntax59implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {6061private static final long serialVersionUID = -2823970704630722439L;6263/**64* Constructs a new media attribute specified by name.65*66* @param value a value67*/68protected Media(int value) {69super (value);70}7172/**73* Returns whether this media attribute is equivalent to the passed in74* object. To be equivalent, all of the following conditions must be true:75* <OL TYPE=1>76* <LI>77* <CODE>object</CODE> is not null.78* <LI>79* <CODE>object</CODE> is of the same subclass of Media as this object.80* <LI>81* The values are equal.82* </OL>83*84* @param object Object to compare to.85*86* @return True if <CODE>object</CODE> is equivalent to this media87* attribute, false otherwise.88*/89public boolean equals(Object object) {90return(object != null && object instanceof Media &&91object.getClass() == this.getClass() &&92((Media)object).getValue() == this.getValue());93}9495/**96* Get the printing attribute class which is to be used as the "category"97* for this printing attribute value.98* <P>99* For class Media and any vendor-defined subclasses, the category is100* class Media itself.101*102* @return Printing attribute class (category), an instance of class103* {@link java.lang.Class java.lang.Class}.104*/105public final Class<? extends Attribute> getCategory() {106return Media.class;107}108109/**110* Get the name of the category of which this attribute value is an111* instance.112* <P>113* For class Media and any vendor-defined subclasses, the category name is114* <CODE>"media"</CODE>.115*116* @return Attribute category name.117*/118public final String getName() {119return "media";120}121122}123124125