Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/URISyntax.java
41159 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;2627import java.io.Serial;28import java.io.Serializable;29import java.net.URI;3031/**32* Class {@code URISyntax} is an abstract base class providing the common33* implementation of all attributes whose value is a Uniform Resource Identifier34* (URI). Once constructed, a {@code URI} attribute's value is immutable.35*36* @author Alan Kaminsky37*/38public abstract class URISyntax implements Serializable, Cloneable {3940/**41* Use serialVersionUID from JDK 1.4 for interoperability.42*/43@Serial44private static final long serialVersionUID = -7842661210486401678L;4546/**47* {@code URI} value of this {@code URI} attribute.48*49* @serial50*/51private URI uri;5253/**54* Constructs a {@code URI} attribute with the specified {@code URI}.55*56* @param uri the {@code URI}57* @throws NullPointerException if {@code uri} is {@code null}58*/59protected URISyntax(URI uri) {60this.uri = verify (uri);61}6263private static URI verify(URI uri) {64if (uri == null) {65throw new NullPointerException(" uri is null");66}67return uri;68}6970/**71* Returns this {@code URI} attribute's {@code URI} value.72*73* @return the {@code URI}74*/75public URI getURI() {76return uri;77}7879/**80* Returns a hashcode for this {@code URI} attribute.81*82* @return a hashcode value for this object83*/84public int hashCode() {85return uri.hashCode();86}8788/**89* Returns whether this {@code URI} attribute is equivalent to the passed in90* object. To be equivalent, all of the following conditions must be true:91* <ol type=1>92* <li>{@code object} is not {@code null}.93* <li>{@code object} is an instance of class {@code URISyntax}.94* <li>This {@code URI} attribute's underlying {@code URI} and95* {@code object}'s underlying {@code URI} are equal.96* </ol>97*98* @param object {@code Object} to compare to99* @return {@code true} if {@code object} is equivalent to this {@code URI}100* attribute, {@code false} otherwise101*/102public boolean equals(Object object) {103return(object != null &&104object instanceof URISyntax &&105this.uri.equals (((URISyntax) object).uri));106}107108/**109* Returns a {@code String} identifying this {@code URI} attribute. The110* {@code String} is the string representation of the attribute's underlying111* {@code URI}.112*113* @return a {@code String} identifying this object114*/115public String toString() {116return uri.toString();117}118}119120121