OGNL - Interpreting Objects as Collections

Interpreting Objects as Collections

The projection and selection operators (e1.{e2} and e1.{?e2}), and the in operator, all treat one of their arguments as a collection and walk it. This is done differently depending on the class of the argument:

  • Java arrays are walked from front to back

  • Members of java.util.Collection are walked by walking their iterators

  • Members of java.util.Map are walked by walking iterators over their values

  • Members of java.util.Iterator and java.util.Enumeration are walked by iterating them

  • Members of java.lang.Number are "walked" by returning integers less than the given number starting with zero

  • All other objects are treated as singleton collections containing only themselves