use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class StructFindValue method call.
public static Array call(PageContext pc, Struct struct, String value, String scope) throws PageException {
// Scope
boolean all = false;
if (scope.equalsIgnoreCase("one"))
all = false;
else if (scope.equalsIgnoreCase("all"))
all = true;
else
throw new FunctionException(pc, "structFindValue", 3, "scope", "invalid scope definition [" + scope + "], valid scopes are [one, all]");
Array array = new ArrayImpl();
getValues(pc, array, struct, value, all, "");
return array;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class StructSort method call.
public static Array call(PageContext pc, Struct base, String sortType, String sortOrder, String pathToSubElement) throws PageException {
boolean isAsc = true;
PageException ee = null;
if (sortOrder.equalsIgnoreCase("asc"))
isAsc = true;
else if (sortOrder.equalsIgnoreCase("desc"))
isAsc = false;
else
throw new ExpressionException("invalid sort order type [" + sortOrder + "], sort order types are [asc and desc]");
Collection.Key[] keys = CollectionUtil.keys(base);
SortRegister[] arr = new SortRegister[keys.length];
boolean hasSubDef = pathToSubElement != null;
for (int i = 0; i < keys.length; i++) {
Object value = base.get(keys[i], null);
if (hasSubDef) {
value = VariableInterpreter.getVariable(pc, Caster.toCollection(value), pathToSubElement);
}
arr[i] = new SortRegister(i, value);
}
ExceptionComparator comp = null;
// text
if (sortType.equalsIgnoreCase("text"))
comp = new SortRegisterComparator(pc, isAsc, false, true);
else // text no case
if (sortType.equalsIgnoreCase("textnocase"))
comp = new SortRegisterComparator(pc, isAsc, true, true);
else // numeric
if (sortType.equalsIgnoreCase("numeric"))
comp = new NumberSortRegisterComparator(isAsc);
else {
throw new ExpressionException("invalid sort type [" + sortType + "], sort types are [text, textNoCase, numeric]");
}
Arrays.sort(arr, 0, arr.length, comp);
ee = comp.getPageException();
if (ee != null) {
throw ee;
}
Array rtn = new ArrayImpl();
for (int i = 0; i < arr.length; i++) {
rtn.append(keys[arr[i].getOldPosition()].getString());
}
return rtn;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class BundleInfo method toArray2.
private static Array toArray2(List<PackageQuery> list) {
Struct sct, _sct;
Array arr = new ArrayImpl(), _arr;
Iterator<PackageQuery> it = list.iterator();
PackageQuery pd;
Iterator<VersionDefinition> _it;
VersionDefinition vd;
while (it.hasNext()) {
pd = it.next();
sct = new StructImpl();
sct.setEL(KeyConstants._package, pd.getName());
sct.setEL("versions", _arr = new ArrayImpl());
_it = pd.getVersionDefinitons().iterator();
while (_it.hasNext()) {
vd = _it.next();
_sct = new StructImpl();
_sct.setEL(KeyConstants._bundleVersion, vd.getVersion().toString());
_sct.setEL("operator", vd.getOpAsString());
_arr.appendEL(_sct);
}
arr.appendEL(sct);
}
return arr;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class BundleInfo method toArray1.
private static Array toArray1(List<BundleDefinition> list) {
Struct sct;
Array arr = new ArrayImpl();
Iterator<BundleDefinition> it = list.iterator();
BundleDefinition bd;
VersionDefinition vd;
while (it.hasNext()) {
bd = it.next();
sct = new StructImpl();
sct.setEL(KeyConstants._bundleName, bd.getName());
vd = bd.getVersionDefiniton();
if (vd != null) {
sct.setEL(KeyConstants._bundleVersion, vd.getVersionAsString());
sct.setEL("operator", vd.getOpAsString());
}
arr.appendEL(sct);
}
return arr;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class CallStackGet method call.
public static Object call(PageContext pc) {
Array arr = new ArrayImpl();
_getTagContext(pc, arr, new Exception("Stack trace"), LINE_NUMBER);
return arr;
}
Aggregations