Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 95914 invoked from network); 8 Dec 2008 23:27:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Dec 2008 23:27:55 -0000 Received: (qmail 19742 invoked by uid 500); 8 Dec 2008 23:28:07 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 19716 invoked by uid 500); 8 Dec 2008 23:28:07 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 19707 invoked by uid 99); 8 Dec 2008 23:28:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Dec 2008 15:28:07 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Dec 2008 23:26:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B750F23888AF; Mon, 8 Dec 2008 15:27:34 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r724552 - /lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java Date: Mon, 08 Dec 2008 23:27:34 -0000 To: java-commits@lucene.apache.org From: mikemccand@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081208232734.B750F23888AF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 null. @@ -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 null * if the sort is by SCORE or DOC. * @return Name of field, possibly null.