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