add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / instantiated / src / java / org / apache / lucene / store / instantiated / InstantiatedTermDocumentInformation.java
1 package org.apache.lucene.store.instantiated;
2
3 import org.apache.lucene.index.TermVectorOffsetInfo;
4
5 import java.io.Serializable;
6 import java.util.Comparator;
7
8 /**
9  * Copyright 2006 The Apache Software Foundation
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *     http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23
24 /**
25  * There is one instance of this class per indexed term in a document
26  * and it contains the meta data about each occurrence of a term in a document.
27  *
28  * It is the inner glue of the inverted index.
29  *
30  * <pre>
31  * [Term]-- {0..*} | {0..*} --(field)[Document]
32  *            &lt;&lt;ordered>>
33  *                 |
34  *    [TermDocumentInformation]
35  *       +payloads
36  *       +termPositions
37  *       +termOffsets
38  * </pre>
39  * 
40  */
41 public class InstantiatedTermDocumentInformation
42     implements Serializable {
43
44   private static final long serialVersionUID = 1l;
45
46   public static final Comparator<InstantiatedTermDocumentInformation> termComparator = new Comparator<InstantiatedTermDocumentInformation>() {
47     public int compare(InstantiatedTermDocumentInformation instantiatedTermDocumentInformation, InstantiatedTermDocumentInformation instantiatedTermDocumentInformation1) {
48       return instantiatedTermDocumentInformation.getTerm().getTerm().compareTo(instantiatedTermDocumentInformation1.getTerm().getTerm());
49     }
50   };
51
52   public static final Comparator<InstantiatedTermDocumentInformation> documentNumberComparator = new Comparator<InstantiatedTermDocumentInformation>() {
53     public int compare(InstantiatedTermDocumentInformation instantiatedTermDocumentInformation, InstantiatedTermDocumentInformation instantiatedTermDocumentInformation1) {
54       return instantiatedTermDocumentInformation.getDocument().getDocumentNumber().compareTo(instantiatedTermDocumentInformation1.getDocument().getDocumentNumber());
55     }
56   };
57
58   public static final Comparator doumentNumberIntegerComparator = new Comparator() {
59     public int compare(Object o1, Object o2) {
60       InstantiatedTermDocumentInformation di = (InstantiatedTermDocumentInformation) o1;
61       Integer i = (Integer) o2;
62       return di.getDocument().getDocumentNumber().compareTo(i);
63     }
64   };
65
66
67   private byte[][] payloads;
68   private int[] termPositions;
69   private InstantiatedTerm term;
70   private InstantiatedDocument document;
71   private TermVectorOffsetInfo[] termOffsets;
72
73
74
75   public InstantiatedTermDocumentInformation(InstantiatedTerm term, InstantiatedDocument document, int[] termPositions, byte[][] payloads) {
76     this.term = term;
77     this.document = document;
78     this.termPositions = termPositions;
79     this.payloads = payloads;
80   }
81
82
83 // not quite sure why I wanted this.
84 //  /**
85 //   * [Term]--- {0..* ordered} ->[Info]
86 //   */
87 //  private int indexFromTerm;
88
89
90 //  public int getIndexFromTerm() {
91 //    return indexFromTerm;
92 //  }
93 //
94 //  void setIndexFromTerm(int indexFromTerm) {
95 //    this.indexFromTerm = indexFromTerm;
96 //  }
97
98
99   public int[] getTermPositions() {
100     return termPositions;
101   }
102
103
104   public byte[][] getPayloads() {
105     return payloads;
106   }
107
108   public InstantiatedDocument getDocument() {
109     return document;
110   }
111
112
113
114   public InstantiatedTerm getTerm() {
115     return term;
116   }
117
118
119   void setTermPositions(int[] termPositions) {
120     this.termPositions = termPositions;
121   }
122
123
124   void setTerm(InstantiatedTerm term) {
125     this.term = term;
126   }
127
128   void setDocument(InstantiatedDocument document) {
129     this.document = document;
130   }
131
132   public TermVectorOffsetInfo[] getTermOffsets() {
133     return termOffsets;
134   }
135
136   void setTermOffsets(TermVectorOffsetInfo[] termOffsets) {
137     this.termOffsets = termOffsets;
138   }
139 }