Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/Media.java
41171 views
/*1* Copyright (c) 2000, 2021, 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*/2425package javax.print.attribute.standard;2627import java.io.Serial;2829import javax.print.attribute.Attribute;30import javax.print.attribute.DocAttribute;31import javax.print.attribute.EnumSyntax;32import javax.print.attribute.PrintJobAttribute;33import javax.print.attribute.PrintRequestAttribute;3435/**36* Class {@code Media} is a printing attribute class that specifies the medium37* on which to print.38* <p>39* Media may be specified in different ways.40* <ul>41* <li>it may be specified by paper source - eg paper tray42* <li>it may be specified by a standard size - eg "A4"43* <li>it may be specified by a name - eg "letterhead"44* </ul>45* Each of these corresponds to the IPP "media" attribute. The current API does46* not support describing media by characteristics (eg colour, opacity). This47* may be supported in a later revision of the specification.48* <p>49* A {@code Media} object is constructed with a value which represents one of50* the ways in which the Media attribute can be specified.51* <p>52* <b>IPP Compatibility:</b> The category name returned by {@code getName()} is53* the IPP attribute name. The enumeration's integer value is the IPP enum54* value. The {@code toString()} method returns the IPP string representation of55* the attribute value.56*57* @author Phil Race58*/59public abstract class Media extends EnumSyntax60implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {6162/**63* Use serialVersionUID from JDK 1.4 for interoperability.64*/65@Serial66private static final long serialVersionUID = -2823970704630722439L;6768/**69* Constructs a new media attribute specified by name.70*71* @param value a value72*/73protected Media(int value) {74super (value);75}7677/**78* Returns whether this media attribute is equivalent to the passed in79* object. To be equivalent, all of the following conditions must be true:80* <ol type=1>81* <li>{@code object} is not {@code null}.82* <li>{@code object} is of the same subclass of {@code Media} as this83* object.84* <li>The values are equal.85* </ol>86*87* @param object {@code Object} to compare to88* @return {@code true} if {@code object} is equivalent to this media89* attribute, {@code false} otherwise90*/91public boolean equals(Object object) {92return(object != null && object instanceof Media &&93object.getClass() == this.getClass() &&94((Media)object).getValue() == this.getValue());95}9697/**98* Get the printing attribute class which is to be used as the "category"99* for this printing attribute value.100* <p>101* For class {@code Media} and any vendor-defined subclasses, the category102* is class {@code Media} itself.103*104* @return printing attribute class (category), an instance of class105* {@link Class java.lang.Class}106*/107public final Class<? extends Attribute> getCategory() {108return Media.class;109}110111/**112* Get the name of the category of which this attribute value is an113* instance.114* <p>115* For class {@code Media} and any vendor-defined subclasses, the category116* name is {@code "media"}.117*118* @return attribute category name119*/120public final String getName() {121return "media";122}123}124125126