Annotation of java/classes/org/w3c/jigsaw/servlet/ServletEnumeration.java, revision 1.4.4.1

1.1       abaird      1: // ServletEnumeration.java
1.4.4.1 ! bmahe       2: // $Id: ServletEnumeration.java,v 1.5 2000/08/16 21:37:45 ylafon Exp $
1.1       abaird      3: // (c) COPYRIGHT MIT and INRIA, 1996.
                      4: // Please first read the full copyright statement in file COPYRIGHT.html
                      5: 
1.4       bmahe       6: package org.w3c.jigsaw.servlet;
1.1       abaird      7: 
1.4.4.1 ! bmahe       8: import java.util.Enumeration;
        !             9: import java.util.NoSuchElementException;
1.1       abaird     10: 
1.4.4.1 ! bmahe      11: import javax.servlet.Servlet;
1.2       abaird     12: 
                     13: /**
                     14:  *  @author Alexandre Rafalovitch <alex@access.com.au>
                     15:  *  @author Anselm Baird-Smith <abaird@w3.org>
                     16:  */
1.1       abaird     17: 
                     18: public class ServletEnumeration implements Enumeration {
1.4       bmahe      19:     Enumeration           children = null;
                     20:     Servlet               next     = null;
                     21:     ServletDirectoryFrame dir      = null;
1.1       abaird     22: 
1.4       bmahe      23:     ServletEnumeration(ServletDirectoryFrame dir, Enumeration children) {
1.1       abaird     24:        this.dir      = dir;
1.4       bmahe      25:        this.children = children; //was null ???
1.1       abaird     26:     }
1.4.4.1 ! bmahe      27: 
1.1       abaird     28:     private final synchronized Servlet computeNext() {
                     29:        if ( next != null )
                     30:            return next;
                     31:        while ( children.hasMoreElements() ) {
                     32:            next = dir.getServlet((String) children.nextElement());
                     33:            if ( next != null )
                     34:                return next;
                     35:        }
                     36:        return null;
                     37:     }
                     38:                                  
                     39:            
                     40:     public synchronized boolean hasMoreElements() {
                     41:        return (next != null) || ((next = computeNext()) != null);
                     42:     }
                     43: 
                     44:     public synchronized Object nextElement() {
                     45:        if ( next == null ) 
                     46:            next = computeNext();
                     47:        if ( next != null ) {
                     48:            Object ret = next;
                     49:            next = null;
                     50:            return ret;
                     51:        }  else {
                     52:            throw new NoSuchElementException("NextElement");
                     53:        }
                     54:     }
                     55: }

Webmaster