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 mi...@apache.org on 2008/12/09 00:27:34 UTC
svn commit: r724552 -
/lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java
Author: mikemccand
Date: Mon Dec 8 15:27:34 2008
New Revision: 724552
URL: http://svn.apache.org/viewvc?rev=724552&view=rev
Log:
LUCENE-1478: small cosmetic cleanups
Modified:
lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java?rev=724552&r1=724551&r2=724552&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java Mon Dec 8 15:27:34 2008
@@ -169,34 +169,19 @@
* subclass an existing numeric parser, or field is null
*/
public SortField (String field, FieldCache.Parser parser, boolean reverse) {
-
- if (parser instanceof FieldCache.IntParser) this.type=INT;
- else if (parser instanceof FieldCache.FloatParser) this.type=FLOAT;
- else if (parser instanceof FieldCache.ShortParser) this.type=SHORT;
- else if (parser instanceof FieldCache.ByteParser) this.type=BYTE;
- else if (parser instanceof ExtendedFieldCache.LongParser) this.type=LONG;
- else if (parser instanceof ExtendedFieldCache.DoubleParser) this.type=DOUBLE;
+ if (parser instanceof FieldCache.IntParser) initFieldType(field, INT);
+ else if (parser instanceof FieldCache.FloatParser) initFieldType(field, FLOAT);
+ else if (parser instanceof FieldCache.ShortParser) initFieldType(field, SHORT);
+ else if (parser instanceof FieldCache.ByteParser) initFieldType(field, BYTE);
+ else if (parser instanceof ExtendedFieldCache.LongParser) initFieldType(field, LONG);
+ else if (parser instanceof ExtendedFieldCache.DoubleParser) initFieldType(field, DOUBLE);
else
- throw new IllegalArgumentException("Parser instance does not subclass existing numeric parser from FieldCache or ExtendedFieldCache (got" + parser + ")");
-
- initFieldType(field, type);
+ throw new IllegalArgumentException("Parser instance does not subclass existing numeric parser from FieldCache or ExtendedFieldCache (got " + parser + ")");
this.reverse = reverse;
this.parser = parser;
}
- // Sets field & type, and ensures field is not NULL unless
- // type is SCORE or DOC
- private void initFieldType(String field, int type) {
- this.type = type;
- if (field == null) {
- if (type != SCORE && type != DOC)
- throw new IllegalArgumentException("field can only be null when type is SCORE or DOC");
- } else {
- this.field = field.intern();
- }
- }
-
/** Creates a sort by terms in the given field sorted
* according to the given locale.
* @param field Name of field to sort by, cannot be <code>null</code>.
@@ -238,6 +223,18 @@
this.factory = comparator;
}
+ // Sets field & type, and ensures field is not NULL unless
+ // type is SCORE or DOC
+ private void initFieldType(String field, int type) {
+ this.type = type;
+ if (field == null) {
+ if (type != SCORE && type != DOC)
+ throw new IllegalArgumentException("field can only be null when type is SCORE or DOC");
+ } else {
+ this.field = field.intern();
+ }
+ }
+
/** Returns the name of the field. Could return <code>null</code>
* if the sort is by SCORE or DOC.
* @return Name of field, possibly <code>null</code>.