Search in sources :

Example 1 with EnumAsIt

use of lucee.runtime.type.it.EnumAsIt in project Lucee by lucee.

the class ForEachUtil method _toIterator.

private static Iterator _toIterator(Object o) {
    if (o instanceof Iteratorable) {
        return ((Iteratorable) o).keysAsStringIterator();
    }
    if (o instanceof Iterator) {
        return (Iterator) o;
    }
    if (o instanceof Enumeration) {
        return new EnumAsIt((Enumeration) o);
    }
    if (o instanceof JavaObject) {
        Collection coll = Caster.toCollection(((JavaObject) o).getEmbededObject(null), null);
        if (coll != null)
            return coll.getIterator();
        String[] names = ClassUtil.getFieldNames(((JavaObject) o).getClazz());
        return new ArrayIterator(names);
    } else if (o instanceof CharSequence) {
        return ListUtil.listToArray(o.toString(), ',').getIterator();
    }
    return null;
}
Also used : Enumeration(java.util.Enumeration) JavaObject(lucee.runtime.java.JavaObject) ForEachIteratorable(lucee.runtime.type.ForEachIteratorable) Iteratorable(lucee.runtime.type.Iteratorable) Iterator(java.util.Iterator) Collection(lucee.runtime.type.Collection) EnumAsIt(lucee.runtime.type.it.EnumAsIt)

Aggregations

Enumeration (java.util.Enumeration)1 Iterator (java.util.Iterator)1 JavaObject (lucee.runtime.java.JavaObject)1 Collection (lucee.runtime.type.Collection)1 ForEachIteratorable (lucee.runtime.type.ForEachIteratorable)1 Iteratorable (lucee.runtime.type.Iteratorable)1 EnumAsIt (lucee.runtime.type.it.EnumAsIt)1