LUCENE-1478: small cosmetic cleanups

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@724552 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2008-12-08 23:27:34 +00:00
parent d53b6786c9
commit f92d3cc82f
1 changed files with 19 additions and 22 deletions

View File

@ -169,34 +169,19 @@ implements Serializable {
* 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 @@ implements Serializable {
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>.