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