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  
15  package org.eclipse.jetty.jndi;
16  
17  import java.util.Iterator;
18  
19  import javax.naming.Binding;
20  import javax.naming.NamingEnumeration;
21  import javax.naming.NamingException;
22  
23  /** BindingEnumeration
24   * <p>Implementation of NamingEnumeration
25   *
26   * <p><h4>Notes</h4>
27   * <p>Used to return results of Context.listBindings();
28   *
29   * <p><h4>Usage</h4>
30   * 
31   */
32  public class BindingEnumeration implements NamingEnumeration<Binding>
33  {       
34      Iterator<Binding> _delegate;
35  
36      public BindingEnumeration (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 Binding next()
53          throws NamingException
54      {
55          Binding b = (Binding)_delegate.next();
56          return new Binding (b.getName(), b.getClassName(), b.getObject(), true);
57      }
58  
59      public boolean hasMoreElements()
60      {
61          return _delegate.hasNext();
62      }
63  
64      public Binding nextElement()
65      {
66          Binding b = (Binding)_delegate.next();
67          return new Binding (b.getName(), b.getClassName(), b.getObject(),true);
68      }
69  }