revamp toString so as to not deal with potential IOException from fetching a document

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@164934 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2005-04-27 01:38:35 +00:00
parent 76bca80bc2
commit 6952e96648
1 changed files with 13 additions and 9 deletions

View File

@ -108,18 +108,22 @@ public class Hit implements java.io.Serializable {
}
/**
* Prints the fields of the underlying document for human consumption.
* <p/>
* If an IOException occurs whilst getting the document, returns null
*
* @see Document#toString()
* Prints the parameters to be used to discover the promised result.
*/
public String toString() {
try {
return getDocument().toString();
} catch (IOException e) {
return null;
StringBuffer buffer = new StringBuffer();
buffer.append("Hit<");
buffer.append(hits.toString());
buffer.append(" [");
buffer.append(hitNumber);
buffer.append("] ");
if (resolved) {
buffer.append("resolved");
} else {
buffer.append("unresolved");
}
buffer.append(">");
return buffer.toString();
}