Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/naming/LinkException.java
38829 views
/*1* Copyright (c) 1999, 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*/2425package javax.naming;2627/**28* This exception is used to describe problems encounter while resolving links.29* Addition information is added to the base NamingException for pinpointing30* the problem with the link.31*<p>32* Analogous to how NamingException captures name resolution information,33* LinkException captures "link"-name resolution information pinpointing34* the problem encountered while resolving a link. All these fields may35* be null.36* <ul>37* <li> Link Resolved Name. Portion of link name that has been resolved.38* <li> Link Resolved Object. Object to which resolution of link name proceeded.39* <li> Link Remaining Name. Portion of link name that has not been resolved.40* <li> Link Explanation. Detail explaining why link resolution failed.41*</ul>42*43*<p>44* A LinkException instance is not synchronized against concurrent45* multithreaded access. Multiple threads trying to access and modify46* a single LinkException instance should lock the object.47*48* @author Rosanna Lee49* @author Scott Seligman50*51* @see Context#lookupLink52* @see LinkRef53* @since 1.354*/555657/*<p>58* The serialized form of a LinkException object consists of the59* serialized fields of its NamingException superclass, the link resolved60* name (a Name object), the link resolved object, link remaining name61* (a Name object), and the link explanation String.62*/636465public class LinkException extends NamingException {66/**67* Contains the part of the link that has been successfully resolved.68* It is a composite name and can be null.69* This field is initialized by the constructors.70* You should access and manipulate this field71* through its get and set methods.72* @serial73* @see #getLinkResolvedName74* @see #setLinkResolvedName75*/76protected Name linkResolvedName;7778/**79* Contains the object to which resolution of the part of the link was successful.80* Can be null. This field is initialized by the constructors.81* You should access and manipulate this field82* through its get and set methods.83* @serial84* @see #getLinkResolvedObj85* @see #setLinkResolvedObj86*/87protected Object linkResolvedObj;8889/**90* Contains the remaining link name that has not been resolved yet.91* It is a composite name and can be null.92* This field is initialized by the constructors.93* You should access and manipulate this field94* through its get and set methods.95* @serial96* @see #getLinkRemainingName97* @see #setLinkRemainingName98*/99protected Name linkRemainingName;100101/**102* Contains the exception of why resolution of the link failed.103* Can be null. This field is initialized by the constructors.104* You should access and manipulate this field105* through its get and set methods.106* @serial107* @see #getLinkExplanation108* @see #setLinkExplanation109*/110protected String linkExplanation;111112/**113* Constructs a new instance of LinkException with an explanation114* All the other fields are initialized to null.115* @param explanation A possibly null string containing additional116* detail about this exception.117* @see java.lang.Throwable#getMessage118*/119public LinkException(String explanation) {120super(explanation);121linkResolvedName = null;122linkResolvedObj = null;123linkRemainingName = null;124linkExplanation = null;125}126127/**128* Constructs a new instance of LinkException.129* All the non-link-related and link-related fields are initialized to null.130*/131public LinkException() {132super();133linkResolvedName = null;134linkResolvedObj = null;135linkRemainingName = null;136linkExplanation = null;137}138139/**140* Retrieves the leading portion of the link name that was resolved141* successfully.142*143* @return The part of the link name that was resolved successfully.144* It is a composite name. It can be null, which means145* the link resolved name field has not been set.146* @see #getLinkResolvedObj147* @see #setLinkResolvedName148*/149public Name getLinkResolvedName() {150return this.linkResolvedName;151}152153/**154* Retrieves the remaining unresolved portion of the link name.155* @return The part of the link name that has not been resolved.156* It is a composite name. It can be null, which means157* the link remaining name field has not been set.158* @see #setLinkRemainingName159*/160public Name getLinkRemainingName() {161return this.linkRemainingName;162}163164/**165* Retrieves the object to which resolution was successful.166* This is the object to which the resolved link name is bound.167*168* @return The possibly null object that was resolved so far.169* If null, it means the link resolved object field has not been set.170* @see #getLinkResolvedName171* @see #setLinkResolvedObj172*/173public Object getLinkResolvedObj() {174return this.linkResolvedObj;175}176177/**178* Retrieves the explanation associated with the problem encounter179* when resolving a link.180*181* @return The possibly null detail string explaining more about the problem182* with resolving a link.183* If null, it means there is no184* link detail message for this exception.185* @see #setLinkExplanation186*/187public String getLinkExplanation() {188return this.linkExplanation;189}190191/**192* Sets the explanation associated with the problem encounter193* when resolving a link.194*195* @param msg The possibly null detail string explaining more about the problem196* with resolving a link. If null, it means no detail will be recorded.197* @see #getLinkExplanation198*/199public void setLinkExplanation(String msg) {200this.linkExplanation = msg;201}202203/**204* Sets the resolved link name field of this exception.205*<p>206* <tt>name</tt> is a composite name. If the intent is to set207* this field using a compound name or string, you must208* "stringify" the compound name, and create a composite209* name with a single component using the string. You can then210* invoke this method using the resulting composite name.211*<p>212* A copy of <code>name</code> is made and stored.213* Subsequent changes to <code>name</code> does not214* affect the copy in this NamingException and vice versa.215*216*217* @param name The name to set resolved link name to. This can be null.218* If null, it sets the link resolved name field to null.219* @see #getLinkResolvedName220*/221public void setLinkResolvedName(Name name) {222if (name != null) {223this.linkResolvedName = (Name)(name.clone());224} else {225this.linkResolvedName = null;226}227}228229/**230* Sets the remaining link name field of this exception.231*<p>232* <tt>name</tt> is a composite name. If the intent is to set233* this field using a compound name or string, you must234* "stringify" the compound name, and create a composite235* name with a single component using the string. You can then236* invoke this method using the resulting composite name.237*<p>238* A copy of <code>name</code> is made and stored.239* Subsequent changes to <code>name</code> does not240* affect the copy in this NamingException and vice versa.241*242* @param name The name to set remaining link name to. This can be null.243* If null, it sets the remaining name field to null.244* @see #getLinkRemainingName245*/246public void setLinkRemainingName(Name name) {247if (name != null)248this.linkRemainingName = (Name)(name.clone());249else250this.linkRemainingName = null;251}252253/**254* Sets the link resolved object field of this exception.255* This indicates the last successfully resolved object of link name.256* @param obj The object to set link resolved object to. This can be null.257* If null, the link resolved object field is set to null.258* @see #getLinkResolvedObj259*/260public void setLinkResolvedObj(Object obj) {261this.linkResolvedObj = obj;262}263264/**265* Generates the string representation of this exception.266* This string consists of the NamingException information plus267* the link's remaining name.268* This string is used for debugging and not meant to be interpreted269* programmatically.270* @return The non-null string representation of this link exception.271*/272public String toString() {273return super.toString() + "; Link Remaining Name: '" +274this.linkRemainingName + "'";275}276277/**278* Generates the string representation of this exception.279* This string consists of the NamingException information plus280* the additional information of resolving the link.281* If 'detail' is true, the string also contains information on282* the link resolved object. If false, this method is the same283* as the form of toString() that accepts no parameters.284* This string is used for debugging and not meant to be interpreted285* programmatically.286*287* @param detail If true, add information about the link resolved288* object.289* @return The non-null string representation of this link exception.290*/291public String toString(boolean detail) {292if (!detail || this.linkResolvedObj == null)293return this.toString();294295return this.toString() + "; Link Resolved Object: " +296this.linkResolvedObj;297}298299/**300* Use serialVersionUID from JNDI 1.1.1 for interoperability301*/302private static final long serialVersionUID = -7967662604076777712L;303};304305306