1 8 package org.codehaus.spice.jndikit; 9 10 import java.util.NoSuchElementException ; 11 import javax.naming.Binding ; 12 import javax.naming.Context ; 13 import javax.naming.NamingException ; 14 15 21 final class ArrayNamingEnumeration 22 extends AbstractNamingEnumeration 23 { 24 protected Object [] m_items; 25 protected int m_index; 26 27 public ArrayNamingEnumeration( final Context owner, 28 final Namespace namespace, 29 final Object [] items ) 30 { 31 super( owner, namespace ); 32 m_items = items; 33 } 35 36 public boolean hasMoreElements() 37 { 38 return m_index < m_items.length; 39 } 40 41 public Object next() 42 throws NamingException 43 { 44 if( !hasMore() ) 45 { 46 throw new NoSuchElementException (); 47 } 48 49 final Object object = m_items[ m_index++ ]; 50 51 if( object instanceof Binding ) 52 { 53 final Binding binding = (Binding )object; 54 final Object resolvedObject = resolve( binding.getName(), binding.getObject() ); 55 binding.setObject( resolvedObject ); 56 } 57 58 return object; 59 } 60 61 public void close() 62 { 63 super.close(); 64 m_items = null; 65 } 66 } 67 | Popular Tags |