add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / src / java / org / apache / lucene / search / FieldDoc.java
1 package org.apache.lucene.search;
2
3 /**
4  * Licensed to the Apache Software Foundation (ASF) under one or more
5  * contributor license agreements.  See the NOTICE file distributed with
6  * this work for additional information regarding copyright ownership.
7  * The ASF licenses this file to You under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with
9  * the License.  You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 /**
21  * Expert: A ScoreDoc which also contains information about
22  * how to sort the referenced document.  In addition to the
23  * document number and score, this object contains an array
24  * of values for the document from the field(s) used to sort.
25  * For example, if the sort criteria was to sort by fields
26  * "a", "b" then "c", the <code>fields</code> object array
27  * will have three elements, corresponding respectively to
28  * the term values for the document in fields "a", "b" and "c".
29  * The class of each element in the array will be either
30  * Integer, Float or String depending on the type of values
31  * in the terms of each field.
32  *
33  * <p>Created: Feb 11, 2004 1:23:38 PM
34  *
35  * @since   lucene 1.4
36  * @see ScoreDoc
37  * @see TopFieldDocs
38  */
39 public class FieldDoc extends ScoreDoc {
40
41   /** Expert: The values which are used to sort the referenced document.
42    * The order of these will match the original sort criteria given by a
43    * Sort object.  Each Object will have been returned from
44    * the <code>value</code> method corresponding
45    * FieldComparator used to sort this field.
46    * @see Sort
47    * @see Searcher#search(Query,Filter,int,Sort)
48    */
49   public Object[] fields;
50
51   /** Expert: Creates one of these objects with empty sort information. */
52   public FieldDoc(int doc, float score) {
53     super (doc, score);
54   }
55
56   /** Expert: Creates one of these objects with the given sort information. */
57   public FieldDoc(int doc, float score, Object[] fields) {
58     super (doc, score);
59     this.fields = fields;
60   }
61   
62   /** Expert: Creates one of these objects with the given sort information. */
63   public FieldDoc(int doc, float score, Object[] fields, int shardIndex) {
64     super (doc, score, shardIndex);
65     this.fields = fields;
66   }
67   
68   // A convenience method for debugging.
69   @Override
70   public String toString() {
71     // super.toString returns the doc and score information, so just add the
72           // fields information
73     StringBuilder sb = new StringBuilder(super.toString());
74     sb.append("[");
75     for (int i = 0; i < fields.length; i++) {
76             sb.append(fields[i]).append(", ");
77           }
78     sb.setLength(sb.length() - 2); // discard last ", "
79     sb.append("]");
80     return sb.toString();
81   }
82 }