// props is an array of my custom class. <logic:iterate id="aAttr" collection="<%=props%>"> From the logic:iterate documentation
The collection to be iterated over MUST conform to one of the following requirements in order for iteration to be successful: -An array of Java objects or primitives. -An implementation of java.util.Collection, including ArrayList and Vector. -An implementation of java.util.Enumeration. -An implementation of java.util.Iterator. -An implementation of java.util.Map, including HashMap, Hashtable, and TreeMap.
I am wondering how can a parameter accepts all those different type of Classes/Arrays at the same time? Is it that in the source code, there are many overloaded functions?
Bear Bibeault
Author and opinionated walrus
Marshal
I am wondering how can a parameter accepts all those different type of Classes/Arrays at the same time? Is it that in the source code, there are many overloaded functions?
Well, if I were writing it, I probably would have a single method that takes an argument of type Object, then do reflection inside my method. Cheers- - Marty
Java training and consulting<br /><a href="http://www.coreservlets.com/" target="_blank" rel="nofollow">http://www.coreservlets.com/</a>
David Hibbs
Ranch Hand
Joined: Dec 19, 2002
Posts: 374
posted
0
Originally posted by Chu Tan: Is it that in the source code, there are many overloaded functions?
If you look at the code, the answer is 'no' -- it simply uses instanceof several times in order to create an iterator of the appropriate type. The beauty of open source is that the source is exactly that--open. Download it and look through it. You might learn something.
"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.