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.standard; 27 28 import javax.print.attribute.Attribute; 29 import javax.print.attribute.DocAttribute; 30 import javax.print.attribute.EnumSyntax; 31 import javax.print.attribute.PrintJobAttribute; 32 import javax.print.attribute.PrintRequestAttribute; 33 34 /** 35 * Class {@code Media} is a printing attribute class that specifies the medium 36 * on which to print. 37 * <p> 38 * Media may be specified in different ways. 39 * <ul> 40 * <li>it may be specified by paper source - eg paper tray 41 * <li>it may be specified by a standard size - eg "A4" 42 * <li>it may be specified by a name - eg "letterhead" 43 * </ul> 44 * Each of these corresponds to the IPP "media" attribute. The current API does 45 * not support describing media by characteristics (eg colour, opacity). This 46 * may be supported in a later revision of the specification. 47 * <p> 48 * A {@code Media} object is constructed with a value which represents one of 49 * the ways in which the Media attribute can be specified. 50 * <p> 51 * <b>IPP Compatibility:</b> The category name returned by {@code getName()} is 52 * the IPP attribute name. The enumeration's integer value is the IPP enum 53 * value. The {@code toString()} method returns the IPP string representation of 54 * the attribute value. 55 * 56 * @author Phil Race 57 */ 58 public abstract class Media extends EnumSyntax 59 implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { 60 61 /** 62 * Use serialVersionUID from JDK 1.4 for interoperability. 63 */ 64 private static final long serialVersionUID = -2823970704630722439L; 65 66 /** 67 * Constructs a new media attribute specified by name. 68 * 69 * @param value a value 70 */ 71 protected Media(int value) { 72 super (value); 73 } 74 75 /** 76 * Returns whether this media attribute is equivalent to the passed in 77 * object. To be equivalent, all of the following conditions must be true: 78 * <ol type=1> 79 * <li>{@code object} is not {@code null}. 80 * <li>{@code object} is of the same subclass of {@code Media} as this 81 * object. 82 * <li>The values are equal. 83 * </ol> 84 * 85 * @param object {@code Object} to compare to 86 * @return {@code true} if {@code object} is equivalent to this media 87 * attribute, {@code false} otherwise 88 */ 89 public boolean equals(Object object) { 90 return(object != null && object instanceof Media && 91 object.getClass() == this.getClass() && 92 ((Media)object).getValue() == this.getValue()); 93 } 94 95 /** 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 {@code Media} and any vendor-defined subclasses, the category 100 * is class {@code Media} itself. 101 * 102 * @return printing attribute class (category), an instance of class 103 * {@link Class java.lang.Class} 104 */ 105 public final Class<? extends Attribute> getCategory() { 106 return Media.class; 107 } 108 109 /** 110 * Get the name of the category of which this attribute value is an 111 * instance. 112 * <p> 113 * For class {@code Media} and any vendor-defined subclasses, the category 114 * name is {@code "media"}. 115 * 116 * @return attribute category name 117 */ 118 public final String getName() { 119 return "media"; 120 } 121 }