You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by yo...@apache.org on 2005/11/10 04:24:12 UTC

svn commit: r332214 - /lucene/java/trunk/src/java/org/apache/lucene/document/Field.java

Author: yonik
Date: Wed Nov  9 19:24:03 2005
New Revision: 332214

URL: http://svn.apache.org/viewcvs?rev=332214&view=rev
Log:
use instanceof instead of catching exception: LUCENE-392

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/document/Field.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/document/Field.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/document/Field.java?rev=332214&r1=332213&r2=332214&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/document/Field.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/document/Field.java Wed Nov  9 19:24:03 2005
@@ -264,17 +264,17 @@
   /** 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