Search in sources :

Example 1 with ArrayPro

use of lucee.runtime.type.ArrayPro in project Lucee by lucee.

the class Each method invoke.

public static void invoke(PageContext pc, Array array, UDF udf, ExecutorService execute, List<Future<Data<Object>>> futures) throws PageException {
    Iterator it = (array instanceof ArrayPro ? ((ArrayPro) array).entryArrayIterator() : array.entryIterator());
    Entry e;
    while (it.hasNext()) {
        e = (Entry) it.next();
        _call(pc, udf, new Object[] { e.getValue(), Caster.toDoubleValue(e.getKey()), array }, execute, futures);
    }
}
Also used : Entry(java.util.Map.Entry) ListIterator(java.util.ListIterator) ForEachQueryIterator(lucee.runtime.type.it.ForEachQueryIterator) Iterator(java.util.Iterator) ArrayPro(lucee.runtime.type.ArrayPro)

Example 2 with ArrayPro

use of lucee.runtime.type.ArrayPro in project Lucee by lucee.

the class Every method invoke.

private static boolean invoke(PageContext pc, StringListData sld, UDF udf, ExecutorService es, List<Future<Data<Object>>> futures) throws CasterException, PageException {
    Array arr = ListUtil.listToArray(sld.list, sld.delimiter, sld.includeEmptyFieldsx, sld.multiCharacterDelimiter);
    Iterator it = (arr instanceof ArrayPro ? ((ArrayPro) arr).entryArrayIterator() : arr.entryIterator());
    Entry e;
    boolean async = es != null;
    Object res;
    while (it.hasNext()) {
        e = (Entry) it.next();
        res = _inv(pc, udf, new Object[] { e.getValue(), Caster.toDoubleValue(e.getKey()), sld.list, sld.delimiter }, e.getKey(), e.getValue(), es, futures);
        if (!async && !Caster.toBooleanValue(res)) {
            return false;
        }
    }
    return true;
}
Also used : Array(lucee.runtime.type.Array) Entry(java.util.Map.Entry) ListIterator(java.util.ListIterator) ForEachQueryIterator(lucee.runtime.type.it.ForEachQueryIterator) Iterator(java.util.Iterator) ArrayPro(lucee.runtime.type.ArrayPro)

Example 3 with ArrayPro

use of lucee.runtime.type.ArrayPro in project Lucee by lucee.

the class Every method invoke.

private static boolean invoke(PageContext pc, Array arr, UDF udf, ExecutorService es, List<Future<Data<Object>>> futures) throws CasterException, PageException {
    Iterator it = (arr instanceof ArrayPro ? ((ArrayPro) arr).entryArrayIterator() : arr.entryIterator());
    Entry e;
    if (!it.hasNext())
        // array is empty or has only null values
        return false;
    boolean async = es != null;
    Object res;
    while (it.hasNext()) {
        e = (Entry) it.next();
        res = _inv(pc, udf, new Object[] { e.getValue(), Caster.toDoubleValue(e.getKey()), arr }, e.getKey(), e.getValue(), es, futures);
        if (!async && !Caster.toBooleanValue(res)) {
            return false;
        }
    }
    return true;
}
Also used : Entry(java.util.Map.Entry) ListIterator(java.util.ListIterator) ForEachQueryIterator(lucee.runtime.type.it.ForEachQueryIterator) Iterator(java.util.Iterator) ArrayPro(lucee.runtime.type.ArrayPro)

Example 4 with ArrayPro

use of lucee.runtime.type.ArrayPro in project Lucee by lucee.

the class Filter method invoke.

private static Collection invoke(PageContext pc, StringListData sld, UDF udf, ExecutorService es, List<Future<Data<Pair<Object, Object>>>> futures) throws CasterException, PageException {
    Array arr = ListUtil.listToArray(sld.list, sld.delimiter, sld.includeEmptyFieldsx, sld.multiCharacterDelimiter);
    Array rtn = new ArrayImpl();
    Iterator it = (arr instanceof ArrayPro ? ((ArrayPro) arr).entryArrayIterator() : arr.entryIterator());
    Entry e;
    KeyImpl k = null;
    boolean async = es != null;
    Object res;
    while (it.hasNext()) {
        e = (Entry) it.next();
        res = _inv(pc, udf, new Object[] { e.getValue(), Caster.toDoubleValue(e.getKey()), sld.list, sld.delimiter }, e.getKey(), e.getValue(), es, futures);
        if (!async && Caster.toBooleanValue(res)) {
            rtn.append(e.getValue());
        }
    }
    return rtn;
}
Also used : Array(lucee.runtime.type.Array) Entry(java.util.Map.Entry) ArrayImpl(lucee.runtime.type.ArrayImpl) KeyImpl(lucee.runtime.type.KeyImpl) ListIterator(java.util.ListIterator) ForEachQueryIterator(lucee.runtime.type.it.ForEachQueryIterator) Iterator(java.util.Iterator) ArrayPro(lucee.runtime.type.ArrayPro)

Example 5 with ArrayPro

use of lucee.runtime.type.ArrayPro in project Lucee by lucee.

the class Map method invoke.

private static Collection invoke(PageContext pc, Array arr, UDF udf, ExecutorService es, List<Future<Data<Object>>> futures) throws CasterException, PageException {
    Array rtn = new ArrayImpl();
    Iterator it = (arr instanceof ArrayPro ? ((ArrayPro) arr).entryArrayIterator() : arr.entryIterator());
    Entry e;
    boolean async = es != null;
    Object res;
    while (it.hasNext()) {
        e = (Entry) it.next();
        res = _inv(pc, udf, new Object[] { e.getValue(), Caster.toDoubleValue(e.getKey()), arr }, e.getKey(), es, futures);
        if (!async)
            rtn.set(Caster.toString(e.getKey()), res);
    }
    return rtn;
}
Also used : Array(lucee.runtime.type.Array) Entry(java.util.Map.Entry) ArrayImpl(lucee.runtime.type.ArrayImpl) ListIterator(java.util.ListIterator) ForEachQueryIterator(lucee.runtime.type.it.ForEachQueryIterator) Iterator(java.util.Iterator) ArrayPro(lucee.runtime.type.ArrayPro)

Aggregations

Iterator (java.util.Iterator)12 ListIterator (java.util.ListIterator)12 Entry (java.util.Map.Entry)12 ArrayPro (lucee.runtime.type.ArrayPro)12 ForEachQueryIterator (lucee.runtime.type.it.ForEachQueryIterator)12 Array (lucee.runtime.type.Array)8 ArrayImpl (lucee.runtime.type.ArrayImpl)4 KeyImpl (lucee.runtime.type.KeyImpl)1