use of lucee.runtime.type.QueryImpl in project Lucee by lucee.
the class Query_ method call.
public static Query call(PageContext pc, Object[] arr) throws DatabaseException {
String[] names = new String[arr.length];
Array[] columns = new Array[arr.length];
int count = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] instanceof FunctionValue) {
FunctionValue vf = (FunctionValue) arr[i];
if (vf.getValue() instanceof Array) {
names[count] = vf.getNameAsString();
columns[count] = (Array) vf.getValue();
count++;
} else
throw new DatabaseException("invalid argument for function query, only array as value are allowed", "example: query(column1:array(1,2,3))", null, null);
} else
throw new DatabaseException("invalid argument for function query, only named argument are allowed", "example: query(column1:array(1,2,3))", null, null);
}
Query query = new QueryImpl(names, columns, "query");
return query;
}
use of lucee.runtime.type.QueryImpl in project Lucee by lucee.
the class MacAddressWrap method getMemoryUsageAsQuery.
public static Query getMemoryUsageAsQuery(int type) throws DatabaseException {
java.util.List<MemoryPoolMXBean> manager = ManagementFactory.getMemoryPoolMXBeans();
Iterator<MemoryPoolMXBean> it = manager.iterator();
Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._name, KeyConstants._type, KeyConstants._used, KeyConstants._max, KeyConstants._init }, 0, "memory");
int row = 0;
MemoryPoolMXBean bean;
MemoryUsage usage;
MemoryType _type;
while (it.hasNext()) {
bean = it.next();
usage = bean.getUsage();
_type = bean.getType();
if (type == MEMORY_TYPE_HEAP && _type != MemoryType.HEAP)
continue;
if (type == MEMORY_TYPE_NON_HEAP && _type != MemoryType.NON_HEAP)
continue;
row++;
qry.addRow();
qry.setAtEL(KeyConstants._name, row, bean.getName());
qry.setAtEL(KeyConstants._type, row, _type.name());
qry.setAtEL(KeyConstants._max, row, Caster.toDouble(usage.getMax()));
qry.setAtEL(KeyConstants._used, row, Caster.toDouble(usage.getUsed()));
qry.setAtEL(KeyConstants._init, row, Caster.toDouble(usage.getInit()));
}
return qry;
}
Aggregations