Search in sources :

Example 6 with Iteratorable

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

the class Filter method _call.

public static Collection _call(PageContext pc, Object obj, UDF udf, boolean parallel, int maxThreads, short type) throws PageException {
    ExecutorService execute = null;
    List<Future<Data<Pair<Object, Object>>>> futures = null;
    if (parallel) {
        execute = Executors.newFixedThreadPool(maxThreads);
        futures = new ArrayList<Future<Data<Pair<Object, Object>>>>();
    }
    Collection coll;
    // Array
    if (type == TYPE_ARRAY) {
        coll = invoke(pc, (Array) obj, udf, execute, futures);
    } else // Query
    if (type == TYPE_QUERY) {
        coll = invoke(pc, (Query) obj, udf, execute, futures);
    } else // Struct
    if (type == TYPE_STRUCT) {
        coll = invoke(pc, (Struct) obj, udf, execute, futures);
    } else // Array
    if (obj instanceof Array) {
        coll = invoke(pc, (Array) obj, udf, execute, futures);
    } else // Query
    if (obj instanceof Query) {
        coll = invoke(pc, (Query) obj, udf, execute, futures);
    } else // Struct
    if (obj instanceof Struct) {
        coll = invoke(pc, (Struct) obj, udf, execute, futures);
    } else // other Iteratorable
    if (obj instanceof Iteratorable) {
        coll = invoke(pc, (Iteratorable) obj, udf, execute, futures);
    } else // Map
    if (obj instanceof java.util.Map) {
        coll = invoke(pc, (java.util.Map) obj, udf, execute, futures);
    } else // List
    if (obj instanceof List) {
        coll = invoke(pc, (List) obj, udf, execute, futures);
    } else // Iterator
    if (obj instanceof Iterator) {
        coll = invoke(pc, (Iterator) obj, udf, execute, futures);
    } else // Enumeration
    if (obj instanceof Enumeration) {
        coll = invoke(pc, (Enumeration) obj, udf, execute, futures);
    } else // String List
    if (obj instanceof StringListData) {
        coll = invoke(pc, (StringListData) obj, udf, execute, futures);
    } else
        throw new FunctionException(pc, "Filter", 1, "data", "cannot iterate througth this type " + Caster.toTypeName(obj.getClass()));
    if (parallel)
        afterCall(pc, coll, futures, execute);
    return coll;
}
Also used : Enumeration(java.util.Enumeration) Query(lucee.runtime.type.Query) FunctionException(lucee.runtime.exp.FunctionException) Struct(lucee.runtime.type.Struct) Array(lucee.runtime.type.Array) StringListData(lucee.runtime.type.util.StringListData) Iteratorable(lucee.runtime.type.Iteratorable) ExecutorService(java.util.concurrent.ExecutorService) ListIterator(java.util.ListIterator) ForEachQueryIterator(lucee.runtime.type.it.ForEachQueryIterator) Iterator(java.util.Iterator) Future(java.util.concurrent.Future) Collection(lucee.runtime.type.Collection) ArrayList(java.util.ArrayList) List(java.util.List) Pair(lucee.commons.lang.Pair)

Aggregations

Enumeration (java.util.Enumeration)6 Iterator (java.util.Iterator)6 Iteratorable (lucee.runtime.type.Iteratorable)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 ListIterator (java.util.ListIterator)5 ExecutorService (java.util.concurrent.ExecutorService)5 Future (java.util.concurrent.Future)5 FunctionException (lucee.runtime.exp.FunctionException)5 Array (lucee.runtime.type.Array)5 Query (lucee.runtime.type.Query)5 ForEachQueryIterator (lucee.runtime.type.it.ForEachQueryIterator)5 StringListData (lucee.runtime.type.util.StringListData)5 Struct (lucee.runtime.type.Struct)4 Collection (lucee.runtime.type.Collection)3 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Pair (lucee.commons.lang.Pair)1 JavaObject (lucee.runtime.java.JavaObject)1 ForEachIteratorable (lucee.runtime.type.ForEachIteratorable)1