Search in sources :

Example 41 with Array

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

the class Filter method invoke.

private static Array invoke(PageContext pc, Enumeration e, UDF udf, ExecutorService es, List<Future<Data<Pair<Object, Object>>>> futures) throws PageException {
    Array rtn = new ArrayImpl();
    Object v;
    boolean async = es != null;
    Object res;
    int count = 0;
    ArgumentIntKey k;
    while (e.hasMoreElements()) {
        v = e.nextElement();
        k = ArgumentIntKey.init(++count);
        res = _inv(pc, udf, new Object[] { v }, k, v, es, futures);
        if (!async && Caster.toBooleanValue(res))
            rtn.append(v);
    }
    return rtn;
}
Also used : Array(lucee.runtime.type.Array) ArrayImpl(lucee.runtime.type.ArrayImpl) ArgumentIntKey(lucee.runtime.type.scope.ArgumentIntKey)

Example 42 with Array

use of lucee.runtime.type.Array 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 43 with Array

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

the class Filter method invoke.

private static Collection invoke(PageContext pc, List list, UDF udf, ExecutorService es, List<Future<Data<Pair<Object, Object>>>> futures) throws CasterException, PageException {
    Array rtn = new ArrayImpl();
    ListIterator it = list.listIterator();
    boolean async = es != null;
    Object res, v;
    int index;
    ArgumentIntKey k;
    while (it.hasNext()) {
        index = it.nextIndex();
        k = ArgumentIntKey.init(index);
        v = it.next();
        res = _inv(pc, udf, new Object[] { v, Caster.toDoubleValue(k.getString()), list }, k, v, es, futures);
        if (!async && Caster.toBooleanValue(res))
            rtn.append(v);
    }
    return rtn;
}
Also used : Array(lucee.runtime.type.Array) ArrayImpl(lucee.runtime.type.ArrayImpl) ArgumentIntKey(lucee.runtime.type.scope.ArgumentIntKey) ListIterator(java.util.ListIterator)

Example 44 with Array

use of lucee.runtime.type.Array 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)

Example 45 with Array

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

the class Map method invoke.

private static Array invoke(PageContext pc, Iterator it, UDF udf, ExecutorService es, List<Future<Data<Object>>> futures) throws PageException {
    Array rtn = new ArrayImpl();
    Object v;
    boolean async = es != null;
    Object res;
    int count = 0;
    ArgumentIntKey k;
    while (it.hasNext()) {
        v = it.next();
        k = ArgumentIntKey.init(++count);
        res = _inv(pc, udf, new Object[] { v }, k, es, futures);
        if (!async)
            rtn.set(k, res);
    }
    return rtn;
}
Also used : Array(lucee.runtime.type.Array) ArrayImpl(lucee.runtime.type.ArrayImpl) ArgumentIntKey(lucee.runtime.type.scope.ArgumentIntKey)

Aggregations

Array (lucee.runtime.type.Array)169 ArrayImpl (lucee.runtime.type.ArrayImpl)79 Struct (lucee.runtime.type.Struct)49 StructImpl (lucee.runtime.type.StructImpl)25 Iterator (java.util.Iterator)24 PageException (lucee.runtime.exp.PageException)23 Entry (java.util.Map.Entry)22 ArrayList (java.util.ArrayList)20 Key (lucee.runtime.type.Collection.Key)20 ListIterator (java.util.ListIterator)16 Query (lucee.runtime.type.Query)16 List (java.util.List)14 ApplicationException (lucee.runtime.exp.ApplicationException)14 FunctionException (lucee.runtime.exp.FunctionException)14 ForEachQueryIterator (lucee.runtime.type.it.ForEachQueryIterator)14 Resource (lucee.commons.io.res.Resource)13 IOException (java.io.IOException)12 Collection (lucee.runtime.type.Collection)10 QueryImpl (lucee.runtime.type.QueryImpl)10 JavaObject (lucee.runtime.java.JavaObject)8