use of lucee.runtime.type.Array in project Lucee by lucee.
the class QueryNew method call.
public static lucee.runtime.type.Query call(PageContext pc, Object columnNames, Object columnTypes, Object data) throws PageException {
Array cn = toArray(pc, columnNames, 1);
lucee.runtime.type.Query qry;
if (StringUtil.isEmpty(columnTypes))
qry = new QueryImpl(cn, 0, "query");
else
qry = new QueryImpl(cn, toArray(pc, columnTypes, 2), 0, "query");
if (data == null)
return qry;
return populate(pc, qry, data);
}
use of lucee.runtime.type.Array in project Lucee by lucee.
the class QuerySetColumn method call.
public static String call(PageContext pc, Query query, String columnName, String newColumnName) throws PageException {
columnName = columnName.trim();
newColumnName = newColumnName.trim();
Collection.Key src = KeyImpl.getInstance(columnName);
Collection.Key trg = KeyImpl.getInstance(newColumnName);
Query qp = Caster.toQuery(query, null);
if (qp != null)
qp.rename(src, trg);
else {
QueryColumn qc = query.removeColumn(src);
Array content = new ArrayImpl();
int len = qc.size();
for (int i = 1; i <= len; i++) {
content.setE(i, qc.get(i, null));
}
query.addColumn(trg, content, qc.getType());
}
return null;
}
use of lucee.runtime.type.Array in project Lucee by lucee.
the class ValueArray method call.
public static Array call(PageContext pc, QueryColumn column) throws PageException {
Array arr = new ArrayImpl();
int size = column.size();
Object obj;
short type = SQLCaster.toCFType(column.getType(), lucee.commons.lang.CFTypes.TYPE_UNDEFINED);
for (int i = 1; i <= size; i++) {
obj = column.get(i, null);
try {
obj = Caster.castTo(pc, type, column.getTypeAsString(), obj);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
arr.append(obj);
}
return arr;
}
use of lucee.runtime.type.Array in project Lucee by lucee.
the class Metadata method val.
private static Object val(Object value) {
if (value == null)
return null;
if (value instanceof CharSequence)
return value.toString();
if (value instanceof Number)
return ((Number) value).doubleValue();
if (Decision.isNativeArray(value) && !(value instanceof Object[]))
return value;
if (value instanceof Object[]) {
Array trg = new ArrayImpl();
Object[] arr = (Object[]) value;
for (Object obj : arr) {
trg.appendEL(val(obj));
}
return trg;
}
if (value instanceof RationalNumber) {
RationalNumber rn = (RationalNumber) value;
return rn.toDisplayString();
}
return value;
}
use of lucee.runtime.type.Array in project Lucee by lucee.
the class ListRemoveDuplicates method call.
public static String call(PageContext pc, String list, String delimiter, boolean ignoreCase) throws PageException {
if (list == null)
return "";
if (delimiter == null)
delimiter = ",";
Array array = ListUtil.listToArrayRemoveEmpty(list, delimiter);
Set<String> existing;
if (ignoreCase)
existing = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
else
existing = new HashSet<String>();
StringBuilder sb = new StringBuilder();
// Key[] keys = array.keys();
Iterator<Object> it = array.valueIterator();
String value;
while (it.hasNext()) {
value = Caster.toString(it.next());
if (!existing.contains(value)) {
if (sb.length() > 0)
sb.append(delimiter);
sb.append(value);
existing.add(value);
}
}
return sb.toString();
}
Aggregations