Author: niallp
Date: Wed Nov  3 11:20:47 2004
New Revision: 56513

Added:
   struts/trunk/src/share/org/apache/struts/util/IteratorAdapter.java
Modified:
   struts/trunk/src/share/org/apache/struts/taglib/html/OptionsCollectionTag.java
   struts/trunk/src/share/org/apache/struts/taglib/html/OptionsTag.java
   struts/trunk/src/share/org/apache/struts/taglib/logic/IterateTag.java
Log:
Remove Collections dependency, revert to IteratorAdapter

Modified: 
struts/trunk/src/share/org/apache/struts/taglib/html/OptionsCollectionTag.java
==============================================================================
--- struts/trunk/src/share/org/apache/struts/taglib/html/OptionsCollectionTag.java     
 (original)
+++ struts/trunk/src/share/org/apache/struts/taglib/html/OptionsCollectionTag.java     
 Wed Nov  3 11:20:47 2004
@@ -29,7 +29,7 @@
 import javax.servlet.jsp.tagext.TagSupport;
 
 import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.collections.IteratorUtils;
+import org.apache.struts.util.IteratorAdapter;
 import org.apache.struts.taglib.TagUtils;
 import org.apache.struts.util.MessageResources;
 
@@ -343,7 +343,7 @@
             return (((Map) collection).entrySet().iterator());
 
         } else if (collection instanceof Enumeration) {
-            return IteratorUtils.asIterator((Enumeration) collection);
+            return new IteratorAdapter((Enumeration) collection);
 
         } else {
             throw new JspException(

Modified: struts/trunk/src/share/org/apache/struts/taglib/html/OptionsTag.java
==============================================================================
--- struts/trunk/src/share/org/apache/struts/taglib/html/OptionsTag.java        
(original)
+++ struts/trunk/src/share/org/apache/struts/taglib/html/OptionsTag.java        Wed 
Nov  3 11:20:47 2004
@@ -29,7 +29,7 @@
 import javax.servlet.jsp.tagext.TagSupport;
 
 import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.collections.IteratorUtils;
+import org.apache.struts.util.IteratorAdapter;
 import org.apache.struts.taglib.TagUtils;
 import org.apache.struts.util.MessageResources;
 
@@ -400,7 +400,7 @@
             return (((Map) collection).entrySet().iterator());
 
         } else if (collection instanceof Enumeration) {
-            return IteratorUtils.asIterator((Enumeration) collection);
+            return new IteratorAdapter((Enumeration) collection);
 
         } else {
             throw new JspException(

Modified: struts/trunk/src/share/org/apache/struts/taglib/logic/IterateTag.java
==============================================================================
--- struts/trunk/src/share/org/apache/struts/taglib/logic/IterateTag.java       
(original)
+++ struts/trunk/src/share/org/apache/struts/taglib/logic/IterateTag.java       Wed 
Nov  3 11:20:47 2004
@@ -29,7 +29,7 @@
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.BodyTagSupport;
 
-import org.apache.commons.collections.IteratorUtils;
+import org.apache.struts.util.IteratorAdapter;
 import org.apache.struts.taglib.TagUtils;
 import org.apache.struts.util.MessageResources;
 
@@ -260,7 +260,7 @@
         } else if (collection instanceof Map) {
             iterator = ((Map) collection).entrySet().iterator();
         } else if (collection instanceof Enumeration) {
-            iterator = IteratorUtils.asIterator((Enumeration) collection);
+            iterator = new IteratorAdapter((Enumeration) collection);
         } else {
             JspException e = new 
JspException(messages.getMessage("iterate.iterator"));
             TagUtils.getInstance().saveException(pageContext, e);

Added: struts/trunk/src/share/org/apache/struts/util/IteratorAdapter.java
==============================================================================
--- (empty file)
+++ struts/trunk/src/share/org/apache/struts/util/IteratorAdapter.java  Wed Nov  3 
11:20:47 2004
@@ -0,0 +1,54 @@
+/*

+ * $Id$ 

+ *

+ * Copyright 2002-2004 The Apache Software Foundation.

+ * 

+ * Licensed 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.struts.util;

+

+import java.util.Iterator;

+import java.util.NoSuchElementException;

+

+

+/**

+ * Utility method for converting Enumeration to an Iterator

+ * class.  If you attempt to remove() an Object from the iterator, it will

+ * throw an UnsupportedOperationException. Added for use by TagLib so

+ * Enumeration can be supported

+ *

+ * @version $Rev$ $Date$ 

+ */

+

+public class IteratorAdapter implements Iterator {

+    private java.util.Enumeration enum;

+

+    public IteratorAdapter(java.util.Enumeration enum) {

+        this.enum = enum;

+    }

+

+    public boolean hasNext() {

+        return enum.hasMoreElements();

+   }

+

+    public Object next() {

+        if (!enum.hasMoreElements()) {

+            throw new NoSuchElementException("IteratorAdaptor.next() has no more 
elements");

+        }

+        return enum.nextElement();

+    }

+    public void remove() {

+        throw new java.lang.UnsupportedOperationException("Method 
IteratorAdaptor.remove() not implemented");

+    }

+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to