View Javadoc

1   // ========================================================================
2   // Copyright (c) 2011 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package org.eclipse.jetty.jndi;
15  
16  import java.util.Iterator;
17  
18  import javax.naming.Binding;
19  import javax.naming.NameClassPair;
20  import javax.naming.NamingEnumeration;
21  import javax.naming.NamingException;
22  
23  /** NameEnumeration
24   * <p>Implementation of NamingEnumeration interface.
25   *
26   * <p><h4>Notes</h4>
27   * <p>Used for returning results of Context.list();
28   *
29   * <p><h4>Usage</h4>
30   *
31   */
32  public class NameEnumeration implements NamingEnumeration<NameClassPair>
33  {
34      Iterator<Binding> _delegate;
35  
36      public NameEnumeration (Iterator<Binding> e)
37      {
38          _delegate = e;
39      }
40  
41      public void close()
42          throws NamingException
43      {
44      }
45  
46      public boolean hasMore ()
47          throws NamingException
48      {
49          return _delegate.hasNext();
50      }
51  
52      public NameClassPair next()
53          throws NamingException
54      {
55          Binding b = _delegate.next();
56          return new NameClassPair(b.getName(),b.getClassName(),true);
57      }
58  
59      public boolean hasMoreElements()
60      {
61          return _delegate.hasNext();
62      }
63  
64      public NameClassPair nextElement()
65      {
66          Binding b = _delegate.next();
67          return new NameClassPair(b.getName(),b.getClassName(),true);
68      }
69  }