1 16 17 package org.apache.naming.core; 18 19 20 import java.util.Enumeration; 21 22 import javax.naming.Binding; 23 import javax.naming.Context; 24 import javax.naming.NameClassPair; 25 import javax.naming.NamingEnumeration; 26 import javax.naming.NamingException; 27 28 37 public class NamingContextEnumeration 38 implements NamingEnumeration 39 { 40 52 public NamingContextEnumeration( Enumeration enum, Context ctx, 53 boolean bindings ) 54 { 55 this.ctx = ctx; 56 this.bindings=bindings; 57 this.enum = enum; 58 } 59 60 62 protected boolean bindings; 64 67 protected Enumeration enum; 68 69 protected Context ctx; 70 71 73 74 77 public Object next() 78 throws NamingException 79 { 80 return nextElement(); 81 } 82 83 84 87 public boolean hasMore() 88 throws NamingException 89 { 90 return enum.hasMoreElements(); 91 } 92 93 94 97 public void close() 98 throws NamingException 99 { 100 } 102 103 104 public boolean hasMoreElements() { 105 return enum.hasMoreElements(); 106 } 107 108 public Object nextElement() { 109 Object next=enum.nextElement(); 110 if( next instanceof NamingEntry ) { 111 NamingEntry entry = (NamingEntry) next; 112 return new ServerBinding(entry.name, ctx, true); 113 } else if( next instanceof NameClassPair ) { 114 NameClassPair ncp=(NameClassPair)next; 115 if( bindings ) 116 return new ServerBinding(ncp.getName(), ctx, true); 117 return next; 118 } else if( next instanceof Binding ) { 119 return next; 120 } else if( next instanceof String ) { 121 String name=(String)next; 122 return new ServerBinding( name, ctx, true ); 123 } 124 return null; 125 } 126 127 } 128 129 | Popular Tags |