| 187 | |
| 188 | |
| 189 | @Override |
| 190 | public void unbind(Name name) throws NamingException { |
| 191 | |
| 192 | if (!checkWritable()) { |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | while ((!name.isEmpty()) && (name.get(0).isEmpty())) { |
| 197 | name = name.getSuffix(1); |
| 198 | } |
| 199 | if (name.isEmpty()) { |
| 200 | throw new NamingException(sm.getString("namingContext.invalidName")); |
| 201 | } |
| 202 | |
| 203 | NamingEntry entry = bindings.get(name.get(0)); |
| 204 | |
| 205 | if (entry == null) { |
| 206 | throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0))); |
| 207 | } |
| 208 | |
| 209 | if (name.size() > 1) { |
| 210 | if (entry.type == NamingEntry.CONTEXT) { |
| 211 | ((Context) entry.value).unbind(name.getSuffix(1)); |
| 212 | } else { |
| 213 | throw new NamingException(sm.getString("namingContext.contextExpected", name.get(0))); |
| 214 | } |
| 215 | } else { |
| 216 | bindings.remove(name.get(0)); |
| 217 | } |
| 218 | |
| 219 | } |
| 220 | |
| 221 | |
| 222 | @Override |