/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A class for recursively enumerating the contents of a Context;
*
* @author Jon Ruiz
*/
private static boolean debug = false;
private boolean currentReturned = false;
private boolean currentChildExpanded = false;
private boolean rootProcessed = false;
}
throws NamingException {
// return this object except when searching single-level
}
boolean returnSelf)
throws NamingException {
throw new IllegalArgumentException("null context passed");
}
// No need to list children if we're only searching object
}
this.contextName = contextName;
// pretend root is processed, if we're not supposed to return ourself
}
// Subclass should override if it wants to avoid calling obj factory
throws NamingException {
}
// Subclass should overrride so that instance is of same type as subclass
}
return !rootProcessed ||
}
public boolean hasMoreElements() {
try {
return hasMore();
} catch (NamingException e) {
return false;
}
}
try {
return next();
} catch (NamingException e) {
throw new NoSuchElementException(e.toString());
}
}
if (!rootProcessed) {
rootProcessed = true;
root, true);
}
return getNextDescendant();
}
throw new NoSuchElementException();
}
}
}
// if the name is relative, we need to add it to the name of this
// context to keep it relative w.r.t. the root context we are
// enumerating
if(debug) {
}
oldBinding.isRelative());
} else {
if(debug) {
}
}
return newBinding;
}
// if the current child is expanded, see if it has more elements
if (!currentReturned) {
(currentChild != null) ); }
return currentChild != null;
"true");}
return true;
} else {
"hasMoreChildren");}
return hasMoreChildren();
}
}
if (!currentReturned) {
// returning parent
currentReturned = true;
return currentChild;
// if the current child is expanded, use it's enumerator
} else {
// Ready to go onto next child
return getNextDescendant();
}
}
if(hasMoreChildren()) {
try {
currentChild = getNextChild();
currentReturned = false;
} catch (NamingException e){
if (debug) e.printStackTrace();
}
} else {
currentChild = null;
return;
}
false);
currentChildExpanded = true;
} else {
currentChildExpanded = false;
}
}
}