< prev index next >

src/java.naming/share/classes/com/sun/jndi/toolkit/ctx/AtomicContext.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()


 226 
 227     protected void a_destroySubcontext_nns(String name, Continuation cont)
 228         throws NamingException {
 229             a_processJunction_nns(name, cont);
 230         }
 231 
 232     protected void a_rename_nns(String oldname, Name newname, Continuation cont)
 233         throws NamingException {
 234             a_processJunction_nns(oldname, cont);
 235         }
 236 
 237     protected NameParser a_getNameParser_nns(Continuation cont)
 238         throws NamingException {
 239             a_processJunction_nns(cont);
 240             return null;
 241         }
 242 
 243 
 244 
 245     protected boolean isEmpty(String name) {
 246         return name == null || name.equals("");
 247     }
 248 
 249 // ------ implementations of c_  and c_*_nns methods using
 250 // ------ the corresponding a_ and a_*_nns methods
 251 
 252     /* Equivalent to methods in  Context interface */
 253 
 254     protected Object c_lookup(Name name, Continuation cont)
 255         throws NamingException {
 256             Object ret = null;
 257             if (resolve_to_penultimate_context(name, cont)) {
 258                 ret = a_lookup(name.toString(), cont);
 259                 if (ret != null && ret instanceof LinkRef) {
 260                     cont.setContinue(ret, name, this);
 261                     ret = null;
 262                 }
 263             }
 264             return ret;
 265         }
 266 


 493         }
 494 
 495 // --------------    internal methods used by this class
 496 
 497     /* Handles nns for junctions */
 498     /**
 499       * This function is used when implementing a naming system that
 500       * supports junctions.  For example, when the a_bind_nns(name, newobj)
 501       * method is invoked, that means the caller is attempting to bind the
 502       * object 'newobj' to the nns of 'name'.  For context that supports
 503       * junctions, 'name' names a junction and is pointing to the root
 504       * of another naming system, which in turn might have an nns.
 505       * This means that a_bind_nns() should first resolve 'name' and attempt to
 506       * continue the operation in the context named by 'name'.  (i.e. bind
 507       * to the nns of the context named by 'name').
 508       * If name is already empty, then throw NameNotFoundException because
 509       * this context by default does not have any nns.
 510       */
 511     protected void a_processJunction_nns(String name, Continuation cont)
 512         throws NamingException {
 513             if (name.equals("")) {
 514                 NameNotFoundException e = new NameNotFoundException();
 515                 cont.setErrorNNS(this, name);
 516                 throw cont.fillInException(e);
 517             }
 518             try {
 519                 // lookup name to continue operation in nns
 520                 Object target = a_lookup(name, cont);
 521                 if (cont.isContinue())
 522                     cont.appendRemainingComponent("");  // add nns back
 523                 else {
 524                     cont.setContinueNNS(target, name, this);
 525                 }
 526             } catch (NamingException e) {
 527                 e.appendRemainingComponent(""); // add nns back
 528                 throw e;
 529             }
 530         }
 531 
 532     /**
 533       * This function is used when implementing a naming system that




 226 
 227     protected void a_destroySubcontext_nns(String name, Continuation cont)
 228         throws NamingException {
 229             a_processJunction_nns(name, cont);
 230         }
 231 
 232     protected void a_rename_nns(String oldname, Name newname, Continuation cont)
 233         throws NamingException {
 234             a_processJunction_nns(oldname, cont);
 235         }
 236 
 237     protected NameParser a_getNameParser_nns(Continuation cont)
 238         throws NamingException {
 239             a_processJunction_nns(cont);
 240             return null;
 241         }
 242 
 243 
 244 
 245     protected boolean isEmpty(String name) {
 246         return name == null || name.isEmpty();
 247     }
 248 
 249 // ------ implementations of c_  and c_*_nns methods using
 250 // ------ the corresponding a_ and a_*_nns methods
 251 
 252     /* Equivalent to methods in  Context interface */
 253 
 254     protected Object c_lookup(Name name, Continuation cont)
 255         throws NamingException {
 256             Object ret = null;
 257             if (resolve_to_penultimate_context(name, cont)) {
 258                 ret = a_lookup(name.toString(), cont);
 259                 if (ret != null && ret instanceof LinkRef) {
 260                     cont.setContinue(ret, name, this);
 261                     ret = null;
 262                 }
 263             }
 264             return ret;
 265         }
 266 


 493         }
 494 
 495 // --------------    internal methods used by this class
 496 
 497     /* Handles nns for junctions */
 498     /**
 499       * This function is used when implementing a naming system that
 500       * supports junctions.  For example, when the a_bind_nns(name, newobj)
 501       * method is invoked, that means the caller is attempting to bind the
 502       * object 'newobj' to the nns of 'name'.  For context that supports
 503       * junctions, 'name' names a junction and is pointing to the root
 504       * of another naming system, which in turn might have an nns.
 505       * This means that a_bind_nns() should first resolve 'name' and attempt to
 506       * continue the operation in the context named by 'name'.  (i.e. bind
 507       * to the nns of the context named by 'name').
 508       * If name is already empty, then throw NameNotFoundException because
 509       * this context by default does not have any nns.
 510       */
 511     protected void a_processJunction_nns(String name, Continuation cont)
 512         throws NamingException {
 513             if (name.isEmpty()) {
 514                 NameNotFoundException e = new NameNotFoundException();
 515                 cont.setErrorNNS(this, name);
 516                 throw cont.fillInException(e);
 517             }
 518             try {
 519                 // lookup name to continue operation in nns
 520                 Object target = a_lookup(name, cont);
 521                 if (cont.isContinue())
 522                     cont.appendRemainingComponent("");  // add nns back
 523                 else {
 524                     cont.setContinueNNS(target, name, this);
 525                 }
 526             } catch (NamingException e) {
 527                 e.appendRemainingComponent(""); // add nns back
 528                 throw e;
 529             }
 530         }
 531 
 532     /**
 533       * This function is used when implementing a naming system that


< prev index next >