Author: remy.maucherat(a)jboss.com
Date: 2009-11-08 12:11:18 -0500 (Sun, 08 Nov 2009)
New Revision: 1253
Added:
trunk/java/org/apache/naming/NamingEnumerationImpl.java
Modified:
trunk/java/org/apache/naming/resources/ProxyDirContext.java
Log:
- Fix type oops when merging the enums.
Added: trunk/java/org/apache/naming/NamingEnumerationImpl.java
===================================================================
--- trunk/java/org/apache/naming/NamingEnumerationImpl.java (rev
0)
+++ trunk/java/org/apache/naming/NamingEnumerationImpl.java 2009-11-08 17:11:18 UTC (rev
1253)
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.naming;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+/**
+ * Naming enumeration implementation.
+ *
+ * @author Remy Maucherat
+ * @version $Revision: 515 $ $Date: 2008-03-17 22:02:23 +0100 (Mon, 17 Mar 2008) $
+ */
+
+public class NamingEnumerationImpl<T>
+ implements NamingEnumeration<T> {
+
+
+ // ----------------------------------------------------------- Constructors
+
+
+ public NamingEnumerationImpl(Collection<T> entries) {
+ this.iterator = entries.iterator();
+ }
+
+
+ // -------------------------------------------------------------- Variables
+
+
+ /**
+ * Underlying collection.
+ */
+ protected Iterator<T> iterator;
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Retrieves the next element in the enumeration.
+ */
+ public T next()
+ throws NamingException {
+ return nextElement();
+ }
+
+
+ /**
+ * Determines whether there are any more elements in the enumeration.
+ */
+ public boolean hasMore()
+ throws NamingException {
+ return iterator.hasNext();
+ }
+
+
+ /**
+ * Closes this enumeration.
+ */
+ public void close()
+ throws NamingException {
+ }
+
+
+ public boolean hasMoreElements() {
+ return iterator.hasNext();
+ }
+
+
+ public T nextElement() {
+ return iterator.next();
+ }
+
+
+}
+
Modified: trunk/java/org/apache/naming/resources/ProxyDirContext.java
===================================================================
--- trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-11-07 01:30:50 UTC
(rev 1252)
+++ trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-11-08 17:11:18 UTC
(rev 1253)
@@ -75,6 +75,7 @@
import org.apache.naming.NamingContextBindingsEnumeration;
import org.apache.naming.NamingContextEnumeration;
+import org.apache.naming.NamingEnumerationImpl;
import org.apache.naming.StringManager;
/**
@@ -540,7 +541,7 @@
if (main == null && merged == null) {
throw notFound;
} else if (merged != null) {
- return new NamingContextEnumeration(merged.values().iterator());
+ return new NamingEnumerationImpl<NameClassPair>(merged.values());
} else {
return main;
}
@@ -599,7 +600,7 @@
if (main == null && merged == null) {
throw notFound;
} else if (merged != null) {
- return new NamingContextEnumeration(merged.values().iterator());
+ return new NamingEnumerationImpl<NameClassPair>(merged.values());
} else {
return main;
}
@@ -662,7 +663,7 @@
if (main == null && merged == null) {
throw notFound;
} else if (merged != null) {
- return new NamingContextBindingsEnumeration(merged.values().iterator(),
this);
+ return new NamingEnumerationImpl<Binding>(merged.values());
} else {
return main;
}
@@ -721,7 +722,7 @@
if (main == null && merged == null) {
throw notFound;
} else if (merged != null) {
- return new NamingContextBindingsEnumeration(merged.values().iterator(),
this);
+ return new NamingEnumerationImpl<Binding>(merged.values());
} else {
return main;
}