handy toString methods for the new Sort classes. feel free to adjust the aesthetics

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150278 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2004-04-04 15:28:14 +00:00
parent 7176a6a488
commit 6e7df0fa69
2 changed files with 30 additions and 0 deletions

View File

@ -202,4 +202,16 @@ implements Serializable {
public void setSort (SortField[] fields) {
this.fields = fields;
}
public String toString() {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < fields.length; i++) {
buffer.append(fields[i].toString());
if ((i +1) < fields.length)
buffer.append(',');
}
return buffer.toString();
}
}

View File

@ -133,4 +133,22 @@ implements Serializable {
public boolean getReverse() {
return reverse;
}
public String toString() {
StringBuffer buffer = new StringBuffer();
switch (type) {
case SCORE: buffer.append("<score>");
break;
case DOC: buffer.append("<doc>");
break;
default: buffer.append("\"" + field + "\"");
break;
}
buffer.append(reverse ? " DESC" : " ASC");
return buffer.toString();
}
}