use of lucee.runtime.type.Array in project Lucee by lucee.
the class ListUtil method listToStringArray.
public static String[] listToStringArray(String list, String delimiter) {
Array array = ListUtil.listToArrayRemoveEmpty(list, delimiter);
String[] arr = new String[array.size()];
for (int i = 0; i < arr.length; i++) {
arr[i] = Caster.toString(array.get(i + 1, ""), "");
}
return arr;
}
use of lucee.runtime.type.Array in project Lucee by lucee.
the class ListUtil method listContains.
/* *
* returns if a value of the list contains given value, ignore case, ignore empty values
* @param list list to search in
* @param value value to serach
* @param delimiter delimiter of the list
* @return position in list or 0
public static int listContainsIgnoreEmptyNoCase(String list, String value, String delimiter) {
if(StringUtil.isEmpty(value)) return -1;
Array arr=listToArrayRemoveEmpty(list,delimiter);
int count=0;
int len=arr.size();
for(int i=1;i<=len;i++) {
String item=arr.get(i,"").toString();
if(StringUtil.indexOfIgnoreCase(item, value)!=-1) return count;
count++;
}
return -1;
} */
/**
* returns if a value of the list contains given value, case sensitive
* @param list list to search in
* @param value value to serach
* @param delimiter delimiter of the list
* @return position in list or 0
*/
public static int listContains(String list, String value, String delimiter, boolean includeEmptyFields, boolean multiCharacterDelimiter) {
if (StringUtil.isEmpty(value))
return -1;
Array arr = listToArray(list, delimiter, includeEmptyFields, multiCharacterDelimiter);
int len = arr.size();
for (int i = 1; i <= len; i++) {
if (arr.get(i, "").toString().indexOf(value) != -1)
return i - 1;
}
return -1;
}
use of lucee.runtime.type.Array 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.Array in project Lucee by lucee.
the class ReplaceList method _call.
static String _call(PageContext pc, String str, String list1, String list2, String delimiter_list1, String delimiter_list2, boolean ignoreCase, boolean includeEmptyFields) {
if (delimiter_list1 == null)
delimiter_list1 = ",";
if (delimiter_list2 == null)
delimiter_list2 = ",";
Array arr1 = ListUtil.listToArray(list1, delimiter_list1, includeEmptyFields, false);
Array arr2 = ListUtil.listToArray(list2, delimiter_list2, includeEmptyFields, false);
Iterator<Object> it1 = arr1.valueIterator();
Iterator<Object> it2 = arr2.valueIterator();
while (it1.hasNext()) {
str = StringUtil.replace(str, Caster.toString(it1.next(), null), ((it2.hasNext()) ? Caster.toString(it2.next(), null) : ""), false, ignoreCase);
}
return str;
}
use of lucee.runtime.type.Array in project Lucee by lucee.
the class StructCopy method call.
public static Object call(PageContext pc, Struct src) throws PageException {
Collection trg = (Collection) Duplicator.duplicate(src, false);
Collection.Key[] keys = CollectionUtil.keys(trg);
Collection.Key key;
Object o;
for (int i = 0; i < keys.length; i++) {
key = keys[i];
o = src.get(key, null);
if (o instanceof Array)
trg.set(key, Duplicator.duplicate(o, false));
}
return trg;
}
Aggregations