use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class ComponentUtil method getMetaData.
public static Struct getMetaData(PageContext pc, UDFPropertiesBase udf) throws PageException {
StructImpl func = new StructImpl();
pc = ThreadLocalPageContext.get(pc);
// TODO func.set("roles", value);
// TODO func.set("userMetadata", value); neo unterstuetzt irgendwelche a
// meta data
Struct meta = udf.getMeta();
if (meta != null)
StructUtil.copy(meta, func, true);
func.setEL(KeyConstants._closure, Boolean.FALSE);
func.set(KeyConstants._access, ComponentUtil.toStringAccess(udf.getAccess()));
String hint = udf.getHint();
if (!StringUtil.isEmpty(hint))
func.set(KeyConstants._hint, hint);
String displayname = udf.getDisplayName();
if (!StringUtil.isEmpty(displayname))
func.set(KeyConstants._displayname, displayname);
func.set(KeyConstants._name, udf.getFunctionName());
func.set(KeyConstants._output, Caster.toBoolean(udf.getOutput()));
func.set(KeyConstants._returntype, udf.getReturnTypeAsString());
func.set("modifier", udf.getModifier() == Component.MODIFIER_NONE ? "" : ComponentUtil.toModifier(udf.getModifier(), ""));
func.set(KeyConstants._description, udf.getDescription());
if (udf.getLocalMode() != null)
func.set("localMode", AppListenerUtil.toLocalMode(udf.getLocalMode().intValue(), ""));
if (udf.getPageSource() != null)
func.set(KeyConstants._owner, udf.getPageSource().getDisplayPath());
if (udf.getStartLine() > 0 && udf.getEndLine() > 0) {
Struct pos = new StructImpl();
pos.set("start", udf.getStartLine());
pos.set("end", udf.getEndLine());
func.setEL("position", pos);
}
int format = udf.getReturnFormat();
if (format < 0 || format == UDF.RETURN_FORMAT_WDDX)
func.set(KeyConstants._returnFormat, "wddx");
else if (format == UDF.RETURN_FORMAT_PLAIN)
func.set(KeyConstants._returnFormat, "plain");
else if (format == UDF.RETURN_FORMAT_JSON)
func.set(KeyConstants._returnFormat, "json");
else if (format == UDF.RETURN_FORMAT_SERIALIZE)
func.set(KeyConstants._returnFormat, "cfml");
FunctionArgument[] args = udf.getFunctionArguments();
Array params = new ArrayImpl();
// Object defaultValue;
Struct m;
// Object defaultValue;
for (int y = 0; y < args.length; y++) {
StructImpl param = new StructImpl();
param.set(KeyConstants._name, args[y].getName().getString());
param.set(KeyConstants._required, Caster.toBoolean(args[y].isRequired()));
param.set(KeyConstants._type, args[y].getTypeAsString());
displayname = args[y].getDisplayName();
if (!StringUtil.isEmpty(displayname))
param.set(KeyConstants._displayname, displayname);
int defType = args[y].getDefaultType();
if (defType == FunctionArgument.DEFAULT_TYPE_RUNTIME_EXPRESSION) {
param.set(KeyConstants._default, "[runtime expression]");
} else if (defType == FunctionArgument.DEFAULT_TYPE_LITERAL) {
Page p = udf.getPage(pc);
param.set(KeyConstants._default, p.udfDefaultValue(pc, udf.getIndex(), y, null));
}
hint = args[y].getHint();
if (!StringUtil.isEmpty(hint))
param.set(KeyConstants._hint, hint);
// TODO func.set("userMetadata", value); neo unterstuetzt irgendwelche attr, die dann hier ausgebenen werden bloedsinn
// meta data
m = args[y].getMetaData();
if (m != null)
StructUtil.copy(m, param, true);
params.append(param);
}
func.set(KeyConstants._parameters, params);
return func;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class ListUtil method listToArrayRemoveEmpty.
public static Array listToArrayRemoveEmpty(String list, String delimiter) {
if (delimiter.length() == 1)
return listToArrayRemoveEmpty(list, delimiter.charAt(0));
int len = list.length();
ArrayImpl array = new ArrayImpl();
if (len == 0)
return array;
if (delimiter.length() == 0) {
for (int i = 0; i < len; i++) {
array.appendEL(String.valueOf(list.charAt(i)));
}
return array;
}
int last = 0;
char[] del = delimiter.toCharArray();
char c;
for (int i = 0; i < len; i++) {
c = list.charAt(i);
for (int y = 0; y < del.length; y++) {
if (c == del[y]) {
if (last < i)
array.appendEL(list.substring(last, i));
last = i + 1;
break;
}
}
}
if (last < len)
array.appendEL(list.substring(last));
return array;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class ListUtil method listToArrayTrim.
/**
* casts a list to Array object, remove all empty items at start and end of the list
* @param list list to cast
* @param delimiter delimter of the list
* @param info
* @return Array Object
*/
public static Array listToArrayTrim(String list, char delimiter, int[] info) {
if (list.length() == 0)
return new ArrayImpl();
// remove at start
while (list.indexOf(delimiter) == 0) {
info[0]++;
list = list.substring(1);
}
int len = list.length();
if (len == 0)
return new ArrayImpl();
while (list.lastIndexOf(delimiter) == len - 1) {
info[1]++;
list = list.substring(0, len - 1 < 0 ? 0 : len - 1);
len = list.length();
}
return listToArray(list, delimiter);
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class ListUtil method listToArrayTrim.
/**
* casts a list to Array object, remove all empty items at start and end of the list and store count to info
* @param list list to cast
* @param delimiter delimter of the list
* @param info
* @return Array Object
*/
public static Array listToArrayTrim(String list, String delimiter, int[] info) {
if (delimiter.length() == 1)
return listToArrayTrim(list, delimiter.charAt(0), info);
if (list.length() == 0)
return new ArrayImpl();
char[] del = delimiter.toCharArray();
char c;
// remove at start
outer: while (list.length() > 0) {
c = list.charAt(0);
for (int i = 0; i < del.length; i++) {
if (c == del[i]) {
info[0]++;
list = list.substring(1);
continue outer;
}
}
break;
}
int len;
outer: while (list.length() > 0) {
c = list.charAt(list.length() - 1);
for (int i = 0; i < del.length; i++) {
if (c == del[i]) {
info[1]++;
len = list.length();
list = list.substring(0, len - 1 < 0 ? 0 : len - 1);
continue outer;
}
}
break;
}
return listToArray(list, delimiter);
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class ListUtil method listToArrayRemoveEmpty.
/**
* casts a list to Array object remove Empty Elements
* @param list list to cast
* @param delimiter delimter of the list
* @return Array Object
*/
public static Array listToArrayRemoveEmpty(String list, char delimiter) {
int len = list.length();
ArrayImpl array = new ArrayImpl();
if (len == 0)
return array;
int last = 0;
for (int i = 0; i < len; i++) {
if (list.charAt(i) == delimiter) {
if (last < i)
array.appendEL(list.substring(last, i));
last = i + 1;
}
}
if (last < len)
array.appendEL(list.substring(last));
return array;
}
Aggregations