SOLR-621: add getAll(name) to NamedList

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@674899 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2008-07-08 17:54:46 +00:00
parent 229229a3c0
commit d26e5638f1
1 changed files with 17 additions and 0 deletions

View File

@ -170,6 +170,23 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
return null;
}
/**
* Gets the values for the the specified name
* @param name Name
* @return List of values
*/
public List<T> getAll(String name) {
List<T> result = new ArrayList<T>();
int sz = size();
for (int i = 0; i < sz; i++) {
String n = getName(i);
if (name==n || (name!=null && name.equals(n))) {
result.add(getVal(i));
}
}
return result;
}
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append('{');