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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations