001 /* ResolveResult.java -- 002 Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 039 package javax.naming.spi; 040 041 import java.io.Serializable; 042 043 import javax.naming.CompositeName; 044 import javax.naming.InvalidNameException; 045 import javax.naming.Name; 046 047 /** 048 * Stores the partial resolution of the name. This class contains the 049 * object to which part of the name has been resolved and the remaining, 050 * unresolved part of this name. 051 * 052 * @author Warren Levy (warrenl@redhat.com) 053 */ 054 055 public class ResolveResult implements Serializable 056 { 057 private static final long serialVersionUID = - 4552108072002407559L; 058 059 // Serialized fields. 060 /** 061 * The object, to that part of the name has been resolved. 062 */ 063 protected Object resolvedObj; 064 065 /** 066 * The remaining, unresolved part of the name. 067 */ 068 protected Name remainingName; 069 070 /** 071 * Create the unitialised instance with both parts being null. 072 */ 073 protected ResolveResult() 074 { 075 } 076 077 /** 078 * Create the initialised instance 079 * 080 * @param resolved the object, to that the name is partially resolved 081 * @param remaining the remaining unresolved part of the name. 082 */ 083 public ResolveResult(Object resolved, String remaining) 084 { 085 if (resolved == null || remaining == null) 086 throw new IllegalArgumentException (); 087 resolvedObj = resolved; 088 remainingName = new CompositeName (); 089 try 090 { 091 remainingName.add (remaining); 092 } 093 catch (InvalidNameException _) 094 { 095 } 096 } 097 098 /** 099 * Create the initialised instance 100 * 101 * @param resolved the object, to that the name is partially resolved 102 * @param remaining the remaining unresolved part of the name. 103 */ 104 public ResolveResult(Object resolved, Name remaining) 105 { 106 resolvedObj = resolved; 107 remainingName = remaining; 108 } 109 110 /** 111 * Get the remaining unresolved part of the name 112 * 113 * @return the remaining unresolved part of the name. 114 */ 115 public Name getRemainingName() 116 { 117 return remainingName; 118 } 119 120 /** 121 * Get the object to that the name was partially resolved 122 * 123 * @return the object, to that the name is partially resolved 124 */ 125 public Object getResolvedObj() 126 { 127 return resolvedObj; 128 } 129 130 /** 131 * Set the remaining unresolved name. 132 * 133 * @param name the name being set. The passed parameter is cloned, so the 134 * caller can reuse or modify it after the method returns. 135 */ 136 public void setRemainingName(Name name) 137 { 138 remainingName = (Name) name.clone(); 139 } 140 141 /** 142 * Append the name to the end of the resolved name. 143 * 144 * @param name the name to append 145 */ 146 public void appendRemainingName(Name name) 147 { 148 try 149 { 150 remainingName.addAll(name); 151 } 152 catch (InvalidNameException _) 153 { 154 } 155 } 156 157 /** 158 * Append the name to the end of the resolved name. 159 * 160 * @param name the name to append 161 */ 162 public void appendRemainingComponent(String name) 163 { 164 try 165 { 166 remainingName.add(name); 167 } 168 catch (InvalidNameException _) 169 { 170 } 171 } 172 173 /** 174 * Set the object to that the part of the name has been resolved. 175 * 176 * @param obj the object, to that the name has been partially resolved. 177 */ 178 public void setResolvedObj(Object obj) 179 { 180 resolvedObj = obj; 181 } 182 }