private static ListData getFilteredList(DataRepository data,
String forParam,
String[] conditions,
String orderBy,
String basePrefix) {
ListData result;
// if the "for" parameter is missing or is simply ".", then
// return a list containing only one element - the base prefix.
if (forParam == null ||
forParam.length() == 0 ||
forParam.equals(".")) {
result = new ListData();
result.add(basePrefix);
// if the for parameter specifies a data list rather than
// a tag name, or if the base prefix is empty, return all the
// items in the list in question.
} else if (basePrefix == null || basePrefix.length() == 0 ||
!forParamIsTagName(forParam)) {
result =
getList(data, forParam, conditions, orderBy, basePrefix);
// otherwise, get the appropriate prefix list, and create
// a filtered copy containing only those prefixes that
// start with the base prefix.
} else {
ListData fullPrefixList =
getList(data, forParam, conditions, orderBy, basePrefix);
result = new ListData();
String item;
for (int i = 0; i < fullPrefixList.size(); i++) {
item = (String) fullPrefixList.get(i);
if (item.equals(basePrefix) ||
item.startsWith(basePrefix + "/"))
result.add(item);
}
}