KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > print > attribute > standard > Media


1 /*
2  * @(#)Media.java 1.9 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package javax.print.attribute.standard;
8
9 import javax.print.attribute.Attribute JavaDoc;
10 import javax.print.attribute.DocAttribute JavaDoc;
11 import javax.print.attribute.EnumSyntax JavaDoc;
12 import javax.print.attribute.PrintRequestAttribute JavaDoc;
13 import javax.print.attribute.PrintJobAttribute JavaDoc;
14
15 /**
16  * Class Media is a printing attribute class that specifies the
17  * medium on which to print.
18  * <p>
19  * Media may be specified in different ways.
20  * <ul>
21  * <li> it may be specified by paper source - eg paper tray
22  * <li> it may be specified by a standard size - eg "A4"
23  * <li> it may be specified by a name - eg "letterhead"
24  * </ul>
25  * Each of these corresponds to the IPP "media" attribute.
26  * The current API does not support describing media by characteristics
27  * (eg colour, opacity).
28  * This may be supported in a later revision of the specification.
29  * <p>
30  * A Media object is constructed with a value which represents
31  * one of the ways in which the Media attribute can be specified.
32  * <p>
33  * <B>IPP Compatibility:</B> The category name returned by
34  * <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
35  * integer value is the IPP enum value. The <code>toString()</code> method
36  * returns the IPP string representation of the attribute value.
37  * <P>
38  *
39  * @author Phil Race
40  */

41 public abstract class Media extends EnumSyntax JavaDoc
42     implements DocAttribute JavaDoc, PrintRequestAttribute JavaDoc, PrintJobAttribute JavaDoc {
43
44     private static final long serialVersionUID = -2823970704630722439L;
45      
46     /**
47      * Constructs a new media attribute specified by name.
48      *
49      * @param value a value
50      */

51     protected Media(int value) {
52        super (value);
53     }
54   
55     /**
56      * Returns whether this media attribute is equivalent to the passed in
57      * object. To be equivalent, all of the following conditions must be true:
58      * <OL TYPE=1>
59      * <LI>
60      * <CODE>object</CODE> is not null.
61      * <LI>
62      * <CODE>object</CODE> is of the same subclass of Media as this object.
63      * <LI>
64      * The values are equal.
65      * </OL>
66      *
67      * @param object Object to compare to.
68      *
69      * @return True if <CODE>object</CODE> is equivalent to this media
70      * attribute, false otherwise.
71      */

72     public boolean equals(Object JavaDoc object) {
73     return(object != null && object instanceof Media JavaDoc &&
74            object.getClass() == this.getClass() &&
75            ((Media JavaDoc)object).getValue() == this.getValue());
76     }
77
78     /**
79      * Get the printing attribute class which is to be used as the "category"
80      * for this printing attribute value.
81      * <P>
82      * For class Media and any vendor-defined subclasses, the category is
83      * class Media itself.
84      *
85      * @return Printing attribute class (category), an instance of class
86      * {@link java.lang.Class java.lang.Class}.
87      */

88     public final Class JavaDoc<? extends Attribute JavaDoc> getCategory() {
89     return Media JavaDoc.class;
90     }
91
92     /**
93      * Get the name of the category of which this attribute value is an
94      * instance.
95      * <P>
96      * For class Media and any vendor-defined subclasses, the category name is
97      * <CODE>"media"</CODE>.
98      *
99      * @return Attribute category name.
100      */

101     public final String JavaDoc getName() {
102     return "media";
103     }
104     
105 }
106
Popular Tags