use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class ListUtil method listToArray.
/**
* casts a list to Array object
* @param list list to cast
* @param delimiter delimter of the list
* @return Array Object
*/
public static Array listToArray(String list, char delimiter) {
if (list.length() == 0)
return new ArrayImpl();
int len = list.length();
int last = 0;
Array array = new ArrayImpl();
try {
for (int i = 0; i < len; i++) {
if (list.charAt(i) == delimiter) {
array.append(list.substring(last, i));
last = i + 1;
}
}
if (last <= len)
array.append(list.substring(last));
} catch (PageException e) {
}
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
* @return Array Object
*/
public static Array listToArrayTrim(String list, char delimiter) {
if (list.length() == 0)
return new ArrayImpl();
// remove at start
while (list.indexOf(delimiter) == 0) {
list = list.substring(1);
}
int len = list.length();
if (len == 0)
return new ArrayImpl();
while (list.lastIndexOf(delimiter) == len - 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 listWithQuotesToArray.
/**
* casts a list to Array object, the list can be have quoted (",') arguments and delimter in this arguments are ignored. quotes are not removed
* example:
* listWithQuotesToArray("aab,a'a,b',a\"a,b\"",",","\"'") will be translated to ["aab","a'a,b'","a\"a,b\""]
*
* @param list list to cast
* @param delimiter delimter of the list
* @param quotes quotes of the list
* @return Array Object
*/
public static Array listWithQuotesToArray(String list, String delimiter, String quotes) {
if (list.length() == 0)
return new ArrayImpl();
int len = list.length();
int last = 0;
char[] del = delimiter.toCharArray();
char[] quo = quotes.toCharArray();
char c;
char inside = 0;
ArrayImpl array = new ArrayImpl();
// try{
for (int i = 0; i < len; i++) {
c = list.charAt(i);
for (int y = 0; y < quo.length; y++) {
if (c == quo[y]) {
if (c == inside)
inside = 0;
else if (inside == 0)
inside = c;
continue;
}
}
for (int y = 0; y < del.length; y++) {
if (inside == 0 && c == del[y]) {
array.appendEL(list.substring(last, i));
last = i + 1;
break;
}
}
}
if (last <= len)
array.appendEL(list.substring(last));
// }catch(PageException e){}
return array;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class QueryUtil method duplicate2QueryColumnImpl.
public static QueryColumnImpl duplicate2QueryColumnImpl(QueryImpl targetQuery, QueryColumn col, boolean deepCopy) {
if (col instanceof QueryColumnImpl)
return ((QueryColumnImpl) col).cloneColumnImpl(deepCopy);
// fill array for column
Array content = new ArrayImpl();
int len = col.size();
for (int i = 1; i <= len; i++) {
content.setEL(i, col.get(i, null));
}
// create and return column
try {
return new QueryColumnImpl(targetQuery, col.getKey(), content, col.getType());
} catch (PageException e) {
throw new PageRuntimeException(e);
}
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class StructFindKey method _call.
private static Array _call(PageContext pc, Struct struct, String value, boolean all) throws PageException {
Array array = new ArrayImpl();
getValues(array, struct, value, all, "");
return array;
}
Aggregations