mirror of https://github.com/apache/lucene.git
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:
parent
76bca80bc2
commit
6952e96648
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue