Search in sources :

Example 11 with Array

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

the class Feed method propTag.

private void propTag(Struct props, StringBuffer xml, int count, String[] srcNames, String trgName, String[][] attrNames, boolean childrenAsTag) throws PageException {
    Object value;
    for (int i = 0; i < srcNames.length; i++) {
        value = props.get(srcNames[i], null);
        if (value instanceof Array) {
            Array arr = (Array) value;
            int size = arr.size();
            for (int y = 1; y <= size; y++) {
                propTag(xml, count, arr.get(y, null), trgName, attrNames, childrenAsTag);
            }
            break;
        }
        if (value != null) {
            propTag(xml, count, value, trgName, attrNames, childrenAsTag);
            break;
        }
    }
}
Also used : Array(lucee.runtime.type.Array)

Example 12 with Array

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

the class FileTag method actionUploadAll.

public static Array actionUploadAll(PageContext pageContext, lucee.runtime.security.SecurityManager securityManager, String strDestination, int nameconflict, String accept, boolean strict, int mode, String attributes, Object acl, String serverPassword) throws PageException {
    FormItem[] items = getFormItems(pageContext);
    Struct sct = null;
    Array arr = new ArrayImpl();
    for (int i = 0; i < items.length; i++) {
        sct = _actionUpload(pageContext, securityManager, items[i], strDestination, nameconflict, accept, strict, mode, attributes, acl, serverPassword);
        arr.appendEL(sct);
    }
    return arr;
}
Also used : Array(lucee.runtime.type.Array) FormItem(lucee.runtime.type.scope.FormItem) ArrayImpl(lucee.runtime.type.ArrayImpl) Struct(lucee.runtime.type.Struct)

Example 13 with Array

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

the class FileTag method actionUploadAll.

public void actionUploadAll() throws PageException {
    Array arr = actionUploadAll(pageContext, securityManager, strDestination, nameconflict, accept, strict, mode, attributes, acl, serverPassword);
    if (StringUtil.isEmpty(result)) {
        Struct sct;
        if (arr != null && arr.size() > 0)
            sct = (Struct) arr.getE(1);
        else
            sct = new StructImpl();
        pageContext.undefinedScope().set(KeyConstants._file, sct);
        pageContext.undefinedScope().set("cffile", sct);
    } else {
        pageContext.setVariable(result, arr);
    }
}
Also used : Array(lucee.runtime.type.Array) StructImpl(lucee.runtime.type.StructImpl) Struct(lucee.runtime.type.Struct)

Example 14 with Array

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

the class ThreadTag method setRetryinterval.

public void setRetryinterval(Object obj) throws PageException {
    if (StringUtil.isEmpty(obj))
        return;
    Array arr = Caster.toArray(obj, null);
    if (arr == null) {
        plans = new ExecutionPlan[] { toExecutionPlan(obj, 1) };
    } else {
        Iterator<Object> it = arr.valueIterator();
        plans = new ExecutionPlan[arr.size()];
        int index = 0;
        while (it.hasNext()) {
            plans[index++] = toExecutionPlan(it.next(), index == 1 ? 1 : 0);
        }
    }
}
Also used : Array(lucee.runtime.type.Array)

Example 15 with Array

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

the class FeedQuery method toStruct.

private static Struct toStruct(Object value) {
    if (value instanceof Struct)
        return (Struct) value;
    if (value instanceof Array) {
        Struct sct = new StructImpl(), row;
        Array arr = (Array) value;
        int len = arr.size();
        // Key[] keys;
        Iterator<Entry<Key, Object>> it;
        Entry<Key, Object> e;
        String nw;
        Object ext;
        for (int i = 1; i <= len; i++) {
            row = Caster.toStruct(arr.get(i, null), null, false);
            if (row == null)
                continue;
            it = row.entryIterator();
            // keys = row.keys();
            while (it.hasNext()) {
                e = it.next();
                ext = sct.get(e.getKey(), null);
                nw = Caster.toString(e.getValue(), null);
                if (nw != null) {
                    if (ext == null)
                        sct.setEL(e.getKey(), nw);
                    else if (ext instanceof CastableArray) {
                        ((CastableArray) ext).appendEL(nw);
                    } else {
                        CastableArray ca = new CastableArray();
                        ca.appendEL(Caster.toString(ext, null));
                        ca.appendEL(nw);
                        sct.setEL(e.getKey(), ca);
                    }
                }
            }
        }
        return sct;
    }
    return null;
}
Also used : CastableArray(lucee.runtime.type.CastableArray) Array(lucee.runtime.type.Array) Entry(java.util.Map.Entry) StructImpl(lucee.runtime.type.StructImpl) CastableArray(lucee.runtime.type.CastableArray) Key(lucee.runtime.type.Collection.Key) Struct(lucee.runtime.type.Struct)

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