webwork/src/main/webwork/view/taglib IteratorTag.java,1.6,1.7

[email protected] Sun, 14 Jul 2002 21:21:02 -0700
Newsgroups gmane.comp.java.webwork.cvs
Message-ID <[email protected]>
Update of /cvsroot/webwork/webwork/src/main/webwork/view/taglib
In directory usw-pr-cvs1:/tmp/cvs-serv25884/src/main/webwork/view/taglib

Modified Files:
	IteratorTag.java 
Log Message:
added preliminary support for JasperReports

Index: IteratorTag.java
===================================================================
RCS file: /cvsroot/webwork/webwork/src/main/webwork/view/taglib/IteratorTag.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- IteratorTag.java	1 Jul 2002 05:22:50 -0000	1.6
+++ IteratorTag.java	15 Jul 2002 04:20:59 -0000	1.7
@@ -7,6 +7,7 @@
 package webwork.view.taglib;
 
 import org.apache.log4j.Category;
+import webwork.util.MakeIterator;
 
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.JspTagException;
@@ -72,41 +73,8 @@
       if(value != null)
       {
          // Make sure it is iterable
-         if(value instanceof Map)
-         {
-            value = ((Map)value).entrySet();
-         }
-
-         if(value instanceof Collection)
-         {
-            iterator = ((Collection)value).iterator();
-         }
-         else if(value.getClass().isArray())
-         {
-            //need ability to support primitives; therefore, cannot
-            //use Object[] casting.
-            Object a = Array.newInstance(value.getClass().getComponentType(), (Array.getLength(value)));
-            ArrayList list = new ArrayList(Array.getLength(value));
-            for(int j = 0; j < Array.getLength(value); j++) {
-               list.add(Array.get(value, j));
-            }
-            iterator = list.iterator();
-         }
-         else if(value instanceof Enumeration)
-         {
-            Enumeration enum = (Enumeration)value;
-            ArrayList list = new ArrayList();
-            while(enum.hasMoreElements())
-            {
-               list.add(enum.nextElement());
-            }
-            iterator = list.iterator();
-         }
-         else
-         {
-            iterator = (Iterator)value;
-         }
-
+         iterator = MakeIterator.convert(value);
+         
          // Get first item
          if(iterator.hasNext())
          {




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf