Search in sources :

Example 31 with StructImpl

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

Example 32 with StructImpl

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

the class _GetElement method toStruct.

@Override
public Object toStruct() {
    Resource[] locs = getCfcLocations();
    Array arrLocs = new ArrayImpl();
    if (locs != null)
        for (int i = 0; i < locs.length; i++) {
            arrLocs.appendEL(getAbsolutePath(locs[i]));
        }
    Struct sct = new StructImpl();
    sct.setEL(AUTO_GEN_MAP, this.autogenmap());
    sct.setEL(CATALOG, StringUtil.emptyIfNull(getCatalog()));
    sct.setEL(CFC_LOCATION, arrLocs);
    sct.setEL(IS_DEFAULT_CFC_LOCATION, isDefaultCfcLocation());
    sct.setEL(DB_CREATE, dbCreateAsString(getDbCreate()));
    sct.setEL(DIALECT, StringUtil.emptyIfNull(getDialect()));
    sct.setEL(EVENT_HANDLING, eventHandling());
    sct.setEL(EVENT_HANDLER, eventHandler());
    sct.setEL(NAMING_STRATEGY, namingStrategy());
    sct.setEL(FLUSH_AT_REQUEST_END, flushAtRequestEnd());
    sct.setEL(LOG_SQL, logSQL());
    sct.setEL(SAVE_MAPPING, saveMapping());
    sct.setEL(SCHEMA, StringUtil.emptyIfNull(getSchema()));
    sct.setEL(SECONDARY_CACHE_ENABLED, secondaryCacheEnabled());
    sct.setEL(SQL_SCRIPT, StringUtil.toStringEmptyIfNull(getSqlScript()));
    sct.setEL(USE_DB_FOR_MAPPING, useDBForMapping());
    sct.setEL(CACHE_CONFIG, getAbsolutePath(getCacheConfig()));
    sct.setEL(CACHE_PROVIDER, StringUtil.emptyIfNull(getCacheProvider()));
    sct.setEL(ORM_CONFIG, getAbsolutePath(getOrmConfig()));
    return sct;
}
Also used : Array(lucee.runtime.type.Array) StructImpl(lucee.runtime.type.StructImpl) ArrayImpl(lucee.runtime.type.ArrayImpl) Resource(lucee.commons.io.res.Resource) Struct(lucee.runtime.type.Struct)

Example 33 with StructImpl

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

the class ORMUtil method convertToSimpleMap.

public static Struct convertToSimpleMap(String paramsStr) {
    paramsStr = paramsStr.trim();
    if (!StringUtil.startsWith(paramsStr, '{') || !StringUtil.endsWith(paramsStr, '}'))
        return null;
    paramsStr = paramsStr.substring(1, paramsStr.length() - 1);
    String[] items = ListUtil.listToStringArray(paramsStr, ',');
    Struct params = new StructImpl();
    String[] arr$ = items;
    int index;
    for (int i = 0; i < arr$.length; i++) {
        String pair = arr$[i];
        index = pair.indexOf('=');
        if (index == -1)
            return null;
        params.setEL(KeyImpl.init(deleteQuotes(pair.substring(0, index).trim()).trim()), deleteQuotes(pair.substring(index + 1).trim()));
    }
    return params;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) Struct(lucee.runtime.type.Struct)

Example 34 with StructImpl

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

the class BundleInfo method info.

public Object info() {
    Struct sct = new StructImpl();
    sct.setEL(KeyConstants._Name, getBundleName());
    sct.setEL("Fragment-Host", getFragementHost());
    sct.setEL("Activator", getActivator());
    sct.setEL("ClassPath", getClassPath());
    sct.setEL("Description", getDescription());
    sct.setEL("DynamicImportPackage", getDynamicImportPackage());
    sct.setEL("ExportPackage", getExportPackage());
    sct.setEL("ImportPackage", getImportPackage());
    sct.setEL("SymbolicName", getSymbolicName());
    sct.setEL(KeyConstants._Version, getVersionAsString());
    sct.setEL("ManifestVersion", getManifestVersion());
    sct.setEL("RequireBundle", getRequireBundle());
    return sct;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) Struct(lucee.runtime.type.Struct)

Example 35 with StructImpl

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

the class WeakFieldStorage method store.

/**
 * store a class with his methods
 * @param clazz
 * @return returns stored Struct
 */
private StructImpl store(Class clazz) {
    Field[] fieldsArr = clazz.getFields();
    StructImpl fieldsMap = new StructImpl();
    for (int i = 0; i < fieldsArr.length; i++) {
        storeField(fieldsArr[i], fieldsMap);
    }
    map.put(clazz, fieldsMap);
    return fieldsMap;
}
Also used : Field(java.lang.reflect.Field) StructImpl(lucee.runtime.type.StructImpl)

Aggregations

StructImpl (lucee.runtime.type.StructImpl)251 Struct (lucee.runtime.type.Struct)216 PageException (lucee.runtime.exp.PageException)40 Entry (java.util.Map.Entry)34 Key (lucee.runtime.type.Collection.Key)28 Array (lucee.runtime.type.Array)25 ArrayImpl (lucee.runtime.type.ArrayImpl)24 ApplicationException (lucee.runtime.exp.ApplicationException)21 IOException (java.io.IOException)19 Map (java.util.Map)19 Resource (lucee.commons.io.res.Resource)18 Iterator (java.util.Iterator)17 PageContextImpl (lucee.runtime.PageContextImpl)14 QueryImpl (lucee.runtime.type.QueryImpl)13 Collection (lucee.runtime.type.Collection)11 Query (lucee.runtime.type.Query)11 DateTimeImpl (lucee.runtime.type.dt.DateTimeImpl)11 HashMap (java.util.HashMap)9 PageSource (lucee.runtime.PageSource)8 Element (org.w3c.dom.Element)8