pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / highlighter / src / java / org / apache / lucene / search / vectorhighlight / FragmentsBuilder.java
1 package org.apache.lucene.search.vectorhighlight;
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 import java.io.IOException;
21
22 import org.apache.lucene.index.IndexReader;
23 import org.apache.lucene.search.highlight.Encoder;
24
25 /**
26  * {@link org.apache.lucene.search.vectorhighlight.FragmentsBuilder} is an interface for fragments (snippets) builder classes.
27  * A {@link org.apache.lucene.search.vectorhighlight.FragmentsBuilder} class can be plugged in to
28  * {@link org.apache.lucene.search.vectorhighlight.FastVectorHighlighter}.
29  */
30 public interface FragmentsBuilder {
31
32   /**
33    * create a fragment.
34    * 
35    * @param reader IndexReader of the index
36    * @param docId document id to be highlighted
37    * @param fieldName field of the document to be highlighted
38    * @param fieldFragList FieldFragList object
39    * @return a created fragment or null when no fragment created
40    * @throws IOException
41    */
42   public String createFragment( IndexReader reader, int docId, String fieldName,
43       FieldFragList fieldFragList ) throws IOException;
44
45   /**
46    * create multiple fragments.
47    * 
48    * @param reader IndexReader of the index
49    * @param docId document id to be highlighter
50    * @param fieldName field of the document to be highlighted
51    * @param fieldFragList FieldFragList object
52    * @param maxNumFragments maximum number of fragments
53    * @return created fragments or null when no fragments created.
54    *         size of the array can be less than maxNumFragments
55    * @throws IOException
56    */
57   public String[] createFragments( IndexReader reader, int docId, String fieldName,
58       FieldFragList fieldFragList, int maxNumFragments ) throws IOException;
59
60   /**
61    * create a fragment.
62    * 
63    * @param reader IndexReader of the index
64    * @param docId document id to be highlighted
65    * @param fieldName field of the document to be highlighted
66    * @param fieldFragList FieldFragList object
67    * @param preTags pre-tags to be used to highlight terms
68    * @param postTags post-tags to be used to highlight terms
69    * @param encoder an encoder that generates encoded text
70    * @return a created fragment or null when no fragment created
71    * @throws IOException
72    */
73   public String createFragment( IndexReader reader, int docId, String fieldName,
74       FieldFragList fieldFragList, String[] preTags, String[] postTags,
75       Encoder encoder ) throws IOException;
76
77   /**
78    * create multiple fragments.
79    * 
80    * @param reader IndexReader of the index
81    * @param docId document id to be highlighter
82    * @param fieldName field of the document to be highlighted
83    * @param fieldFragList FieldFragList object
84    * @param maxNumFragments maximum number of fragments
85    * @param preTags pre-tags to be used to highlight terms
86    * @param postTags post-tags to be used to highlight terms
87    * @param encoder an encoder that generates encoded text
88    * @return created fragments or null when no fragments created.
89    *         size of the array can be less than maxNumFragments
90    * @throws IOException
91    */
92   public String[] createFragments( IndexReader reader, int docId, String fieldName,
93       FieldFragList fieldFragList, int maxNumFragments, String[] preTags, String[] postTags,
94       Encoder encoder ) throws IOException;
95 }