Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/print/attribute/URISyntax.java
38918 views
/*1* Copyright (c) 2000, 2004, 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*/242526package javax.print.attribute;2728import java.io.Serializable;29import java.net.URI;3031/**32* Class URISyntax is an abstract base class providing the common33* implementation of all attributes whose value is a Uniform Resource34* Identifier (URI). Once constructed, a URI attribute's value is immutable.35* <P>36*37* @author Alan Kaminsky38*/39public abstract class URISyntax implements Serializable, Cloneable {4041private static final long serialVersionUID = -7842661210486401678L;4243/**44* URI value of this URI attribute.45* @serial46*/47private URI uri;4849/**50* Constructs a URI attribute with the specified URI.51*52* @param uri URI.53*54* @exception NullPointerException55* (unchecked exception) Thrown if <CODE>uri</CODE> is null.56*/57protected URISyntax(URI uri) {58this.uri = verify (uri);59}6061private static URI verify(URI uri) {62if (uri == null) {63throw new NullPointerException(" uri is null");64}65return uri;66}6768/**69* Returns this URI attribute's URI value.70* @return the URI.71*/72public URI getURI() {73return uri;74}7576/**77* Returns a hashcode for this URI attribute.78*79* @return A hashcode value for this object.80*/81public int hashCode() {82return uri.hashCode();83}8485/**86* Returns whether this URI attribute is equivalent to the passed in87* object.88* To be equivalent, all of the following conditions must be true:89* <OL TYPE=1>90* <LI>91* <CODE>object</CODE> is not null.92* <LI>93* <CODE>object</CODE> is an instance of class URISyntax.94* <LI>95* This URI attribute's underlying URI and <CODE>object</CODE>'s96* underlying URI are equal.97* </OL>98*99* @param object Object to compare to.100*101* @return True if <CODE>object</CODE> is equivalent to this URI102* attribute, false otherwise.103*/104public boolean equals(Object object) {105return(object != null &&106object instanceof URISyntax &&107this.uri.equals (((URISyntax) object).uri));108}109110/**111* Returns a String identifying this URI attribute. The String is the112* string representation of the attribute's underlying URI.113*114* @return A String identifying this object.115*/116public String toString() {117return uri.toString();118}119120}121122123