< prev index next >

src/java.naming/share/classes/com/sun/jndi/toolkit/dir/ContextEnumerator.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


 121         }
 122 
 123         throw new NoSuchElementException();
 124     }
 125 
 126     public void close() throws NamingException {
 127         root = null;
 128     }
 129 
 130     private boolean hasMoreChildren() throws NamingException {
 131         return children != null && children.hasMore();
 132     }
 133 
 134     private Binding getNextChild() throws NamingException {
 135         Binding oldBinding = children.next();
 136         Binding newBinding = null;
 137 
 138         // if the name is relative, we need to add it to the name of this
 139         // context to keep it relative w.r.t. the root context we are
 140         // enumerating
 141         if(oldBinding.isRelative() && !contextName.equals("")) {
 142             NameParser parser = root.getNameParser("");
 143             Name newName = parser.parse(contextName);
 144             newName.add(oldBinding.getName());
 145             if(debug) {
 146                 System.out.println("ContextEnumerator: adding " + newName);
 147             }
 148             newBinding = new Binding(newName.toString(),
 149                                      oldBinding.getClassName(),
 150                                      oldBinding.getObject(),
 151                                      oldBinding.isRelative());
 152         } else {
 153             if(debug) {
 154                 System.out.println("ContextEnumerator: using old binding");
 155             }
 156             newBinding = oldBinding;
 157         }
 158 
 159         return newBinding;
 160     }
 161 




 121         }
 122 
 123         throw new NoSuchElementException();
 124     }
 125 
 126     public void close() throws NamingException {
 127         root = null;
 128     }
 129 
 130     private boolean hasMoreChildren() throws NamingException {
 131         return children != null && children.hasMore();
 132     }
 133 
 134     private Binding getNextChild() throws NamingException {
 135         Binding oldBinding = children.next();
 136         Binding newBinding = null;
 137 
 138         // if the name is relative, we need to add it to the name of this
 139         // context to keep it relative w.r.t. the root context we are
 140         // enumerating
 141         if(oldBinding.isRelative() && !contextName.isEmpty()) {
 142             NameParser parser = root.getNameParser("");
 143             Name newName = parser.parse(contextName);
 144             newName.add(oldBinding.getName());
 145             if(debug) {
 146                 System.out.println("ContextEnumerator: adding " + newName);
 147             }
 148             newBinding = new Binding(newName.toString(),
 149                                      oldBinding.getClassName(),
 150                                      oldBinding.getObject(),
 151                                      oldBinding.isRelative());
 152         } else {
 153             if(debug) {
 154                 System.out.println("ContextEnumerator: using old binding");
 155             }
 156             newBinding = oldBinding;
 157         }
 158 
 159         return newBinding;
 160     }
 161 


< prev index next >