Search in sources :

Example 91 with StructImpl

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

the class AbsSystemStruct method duplicate.

@Override
public final Collection duplicate(boolean deepCopy) {
    Struct sct = new StructImpl();
    StructImpl.copy(this, sct, deepCopy);
    return sct;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) Struct(lucee.runtime.type.Struct)

Example 92 with StructImpl

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

the class ComponentUtil method getPropertiesAsStruct.

public static Struct getPropertiesAsStruct(Component c, boolean onlyPersistent) {
    Property[] props = c.getProperties(onlyPersistent);
    Struct sct = new StructImpl();
    if (props != null)
        for (int i = 0; i < props.length; i++) {
            sct.setEL(KeyImpl.getInstance(props[i].getName()), props[i]);
        }
    return sct;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) Property(lucee.runtime.component.Property) ASMProperty(lucee.transformer.bytecode.util.ASMProperty) Struct(lucee.runtime.type.Struct)

Example 93 with StructImpl

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

the class StructUtil method copyToStruct.

public static Struct copyToStruct(Map map) throws PageException {
    Struct sct = new StructImpl();
    Iterator it = map.entrySet().iterator();
    Map.Entry entry;
    while (it.hasNext()) {
        entry = (Entry) it.next();
        sct.setEL(Caster.toString(entry.getKey()), entry.getValue());
    }
    return sct;
}
Also used : Entry(java.util.Map.Entry) StructImpl(lucee.runtime.type.StructImpl) Iterator(java.util.Iterator) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) WeakHashMap(java.util.WeakHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SyncMap(lucee.commons.collection.SyncMap) Struct(lucee.runtime.type.Struct)

Example 94 with StructImpl

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

the class StructUtil method merge.

public static Struct merge(Struct[] scts) {
    Struct sct = new StructImpl();
    for (int i = scts.length - 1; i >= 0; i--) {
        Iterator<Entry<Key, Object>> it = scts[i].entryIterator();
        Entry<Key, Object> e;
        while (it.hasNext()) {
            e = it.next();
            sct.setEL(e.getKey(), e.getValue());
        }
    }
    return sct;
}
Also used : Entry(java.util.Map.Entry) StructImpl(lucee.runtime.type.StructImpl) Key(lucee.runtime.type.Collection.Key) Struct(lucee.runtime.type.Struct)

Example 95 with StructImpl

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

the class StructFindKey method getValues.

/**
 * @param coll
 * @param value
 * @param all
 * @param buffer
 * @return
 * @throws PageException
 */
private static boolean getValues(Array array, Collection coll, String value, boolean all, String path) throws PageException {
    // Collection.Key[] keys=coll.keys();
    Iterator<Entry<Key, Object>> it = coll.entryIterator();
    Entry<Key, Object> e;
    boolean abort = false;
    Collection.Key key;
    while (it.hasNext()) {
        e = it.next();
        if (abort)
            break;
        key = e.getKey();
        Object o = e.getValue();
        // matching value  (this function search first for base)
        if (key.getString().equalsIgnoreCase(value)) {
            Struct sct = new StructImpl();
            sct.setEL(KeyConstants._value, o);
            sct.setEL(KeyConstants._path, createKey(coll, path, key));
            sct.setEL(KeyConstants._owner, coll);
            array.append(sct);
            if (!all)
                abort = true;
        }
        // Collection
        if (!abort) {
            if (o instanceof Collection) {
                abort = getValues(array, ((Collection) o), value, all, createKey(coll, path, key));
            } else if (o instanceof List) {
                abort = getValues(array, ListAsArray.toArray((List<?>) o), value, all, createKey(coll, path, key));
            } else if (o instanceof Map) {
                abort = getValues(array, MapAsStruct.toStruct((Map<?, ?>) o), value, all, createKey(coll, path, key));
            }
        }
    }
    return abort;
}
Also used : Key(lucee.runtime.type.Collection.Key) Entry(java.util.Map.Entry) StructImpl(lucee.runtime.type.StructImpl) Collection(lucee.runtime.type.Collection) List(java.util.List) Map(java.util.Map) Key(lucee.runtime.type.Collection.Key) Struct(lucee.runtime.type.Struct) MapAsStruct(lucee.runtime.type.wrap.MapAsStruct)

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