1 50 package org.apache.avalon.excalibur.naming; 51 52 import java.util.NoSuchElementException ; 53 54 import javax.naming.Binding ; 55 import javax.naming.Context ; 56 import javax.naming.NamingException ; 57 58 65 final class ArrayNamingEnumeration 66 extends AbstractNamingEnumeration 67 { 68 protected Object [] m_items; 69 protected int m_index; 70 71 public ArrayNamingEnumeration( final Context owner, 72 final Namespace namespace, 73 final Object [] items ) 74 { 75 super( owner, namespace ); 76 m_items = items; 77 } 79 80 public boolean hasMoreElements() 81 { 82 return m_index < m_items.length; 83 } 84 85 public Object next() 86 throws NamingException 87 { 88 if( !hasMore() ) throw new NoSuchElementException (); 89 90 final Object object = m_items[ m_index++ ]; 91 92 if( object instanceof Binding ) 93 { 94 final Binding binding = (Binding )object; 95 final Object resolvedObject = resolve( binding.getName(), binding.getObject() ); 96 binding.setObject( resolvedObject ); 97 } 98 99 return object; 100 } 101 102 public void close() 103 { 104 super.close(); 105 m_items = null; 106 } 107 } 108 | Popular Tags |