FileDocCategorySizeDatePackage
NamingContextBindingsEnumeration.javaAPI DocApache Tomcat 6.0.143576Fri Jul 20 04:20:34 BST 2007org.apache.naming

NamingContextBindingsEnumeration

public class NamingContextBindingsEnumeration extends Object implements NamingEnumeration
Naming enumeration implementation.
author
Remy Maucherat
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
protected Iterator
iterator
Underlying enumeration.
private Context
ctx
The context for which this enumeration is being generated.
Constructors Summary
public NamingContextBindingsEnumeration(Iterator entries, Context ctx)

    	iterator = entries;
        this.ctx = ctx;
    
Methods Summary
public voidclose()
Closes this enumeration.

    
public booleanhasMore()
Determines whether there are any more elements in the enumeration.

        return iterator.hasNext();
    
public booleanhasMoreElements()

        return iterator.hasNext();
    
public java.lang.Objectnext()
Retrieves the next element in the enumeration.

        return nextElementInternal();
    
public java.lang.ObjectnextElement()

        try {
            return nextElementInternal();
        } catch (NamingException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    
private java.lang.ObjectnextElementInternal()

        NamingEntry entry = (NamingEntry) iterator.next();
        
        // If the entry is a reference, resolve it
        if (entry.type == NamingEntry.REFERENCE
                || entry.type == NamingEntry.LINK_REF) {
            try {
                // A lookup will resolve the entry
                ctx.lookup(new CompositeName(entry.name));
            } catch (NamingException e) {
                throw e;
            } catch (Exception e) {
                NamingException ne = new NamingException(e.getMessage());
                ne.initCause(e);
                throw ne;
            }
        }
        
        return new Binding(entry.name, entry.value.getClass().getName(), 
                           entry.value, true);