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/URISyntax.java
41159 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;
27
28
import java.io.Serial;
29
import java.io.Serializable;
30
import java.net.URI;
31
32
/**
33
* Class {@code URISyntax} is an abstract base class providing the common
34
* implementation of all attributes whose value is a Uniform Resource Identifier
35
* (URI). Once constructed, a {@code URI} attribute's value is immutable.
36
*
37
* @author Alan Kaminsky
38
*/
39
public abstract class URISyntax implements Serializable, Cloneable {
40
41
/**
42
* Use serialVersionUID from JDK 1.4 for interoperability.
43
*/
44
@Serial
45
private static final long serialVersionUID = -7842661210486401678L;
46
47
/**
48
* {@code URI} value of this {@code URI} attribute.
49
*
50
* @serial
51
*/
52
private URI uri;
53
54
/**
55
* Constructs a {@code URI} attribute with the specified {@code URI}.
56
*
57
* @param uri the {@code URI}
58
* @throws NullPointerException if {@code uri} is {@code null}
59
*/
60
protected URISyntax(URI uri) {
61
this.uri = verify (uri);
62
}
63
64
private static URI verify(URI uri) {
65
if (uri == null) {
66
throw new NullPointerException(" uri is null");
67
}
68
return uri;
69
}
70
71
/**
72
* Returns this {@code URI} attribute's {@code URI} value.
73
*
74
* @return the {@code URI}
75
*/
76
public URI getURI() {
77
return uri;
78
}
79
80
/**
81
* Returns a hashcode for this {@code URI} attribute.
82
*
83
* @return a hashcode value for this object
84
*/
85
public int hashCode() {
86
return uri.hashCode();
87
}
88
89
/**
90
* Returns whether this {@code URI} attribute is equivalent to the passed in
91
* object. To be equivalent, all of the following conditions must be true:
92
* <ol type=1>
93
* <li>{@code object} is not {@code null}.
94
* <li>{@code object} is an instance of class {@code URISyntax}.
95
* <li>This {@code URI} attribute's underlying {@code URI} and
96
* {@code object}'s underlying {@code URI} are equal.
97
* </ol>
98
*
99
* @param object {@code Object} to compare to
100
* @return {@code true} if {@code object} is equivalent to this {@code URI}
101
* attribute, {@code false} otherwise
102
*/
103
public boolean equals(Object object) {
104
return(object != null &&
105
object instanceof URISyntax &&
106
this.uri.equals (((URISyntax) object).uri));
107
}
108
109
/**
110
* Returns a {@code String} identifying this {@code URI} attribute. The
111
* {@code String} is the string representation of the attribute's underlying
112
* {@code URI}.
113
*
114
* @return a {@code String} identifying this object
115
*/
116
public String toString() {
117
return uri.toString();
118
}
119
}
120
121