use instanceof instead of catching exception: LUCENE-392

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@332214 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2005-11-10 03:24:03 +00:00
parent 7208772e69
commit 6adbae3dc2
1 changed files with 3 additions and 3 deletions
src/java/org/apache/lucene/document

View File

@ -264,17 +264,17 @@ public final class Field implements Serializable {
/** The value of the field as a String, or null. If null, the Reader value
* or binary value is used. Exactly one of stringValue(), readerValue(), and
* binaryValue() must be set. */
public String stringValue() { try { return (String)fieldsData; } catch (ClassCastException ignore) { return null; } }
public String stringValue() { return fieldsData instanceof String ? (String)fieldsData : null; }
/** The value of the field as a Reader, or null. If null, the String value
* or binary value is used. Exactly one of stringValue(), readerValue(),
* and binaryValue() must be set. */
public Reader readerValue() { try { return (Reader)fieldsData; } catch (ClassCastException ignore) { return null; } }
public Reader readerValue() { return fieldsData instanceof Reader ? (Reader)fieldsData : null; }
/** The value of the field in Binary, or null. If null, the Reader or
* String value is used. Exactly one of stringValue(), readerValue() and
* binaryValue() must be set. */
public byte[] binaryValue() { try { return (byte[])fieldsData; } catch (ClassCastException ignore) { return null; } }
public byte[] binaryValue() { return fieldsData instanceof byte[] ? (byte[])fieldsData : null; }
/**
* Create a field by specifying its name, value and how it will