KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > api > Document


1 package org.enhydra.snapper.api;
2
3 /**
4
5  */

6
7 import java.util.Enumeration JavaDoc;
8 import java.util.Iterator JavaDoc;
9 import java.util.List JavaDoc;
10 import java.util.ArrayList JavaDoc;
11 import java.util.Vector JavaDoc;
12
13
14 /** Documents are the unit of indexing and search.
15  *
16  * A Document is a set of fields. Each field has a name and a textual value.
17  * A field may be {@link Field#isStored() stored} with the document, in which
18  * case it is returned with search hits on the document. Thus each document
19  * should typically contain one or more stored fields which uniquely identify
20  * it.
21  *
22  * <p>Note that fields which are <i>not</i> {@link Field#isStored() stored} are
23  * <i>not</i> available in documents retrieved from the index, e.g. with {@link
24  * Hits#doc(int)}, {@link Searcher#doc(int)} or {@link
25  * IndexReader#document(int)}.
26  */

27
28 public interface Document {
29
30
31
32
33   /** Sets a boost factor for hits on any field of this document. This value
34    * will be multiplied into the score of all hits on this document.
35    *
36    * <p>Values are multiplied into the value of {@link Field#getBoost()} of
37    * each field in this document. Thus, this method in effect sets a default
38    * boost for the fields of this document.
39    *
40    * @see Field#setBoost(float)
41    */

42   public void setBoost(float boost);
43
44   /** Returns the boost factor for hits on any field of this document.
45    *
46    * <p>The default value is 1.0.
47    *
48    * <p>Note: This value is not stored directly with the document in the index.
49    * Documents returned from {@link IndexReader#document(int)} and
50    * {@link Hits#doc(int)} may thus not have the same value present as when
51    * this document was indexed.
52    *
53    * @see #setBoost(float)
54    */

55   public float getBoost();
56
57   /**
58    * <p>Adds a field to a document. Several fields may be added with
59    * the same name. In this case, if the fields are indexed, their text is
60    * treated as though appended for the purposes of search.</p>
61    * <p> Note that add like the removeField(s) methods only makes sense
62    * prior to adding a document to an index. These methods cannot
63    * be used to change the content of an existing index! In order to achieve this,
64    * a document has to be deleted from an index and a new changed version of that
65    * document has to be added.</p>
66    */

67   public void add(Field field);
68   
69   /**
70    * <p>Removes field with the specified name from the document.
71    * If multiple fields exist with this name, this method removes the first field that has been added.
72    * If there is no field with the specified name, the document remains unchanged.</p>
73    * <p> Note that the removeField(s) methods like the add method only make sense
74    * prior to adding a document to an index. These methods cannot
75    * be used to change the content of an existing index! In order to achieve this,
76    * a document has to be deleted from an index and a new changed version of that
77    * document has to be added.</p>
78    */

79   public void removeField(String JavaDoc name);
80   
81   /**
82    * <p>Removes all fields with the given name from the document.
83    * If there is no field with the specified name, the document remains unchanged.</p>
84    * <p> Note that the removeField(s) methods like the add method only make sense
85    * prior to adding a document to an index. These methods cannot
86    * be used to change the content of an existing index! In order to achieve this,
87    * a document has to be deleted from an index and a new changed version of that
88    * document has to be added.</p>
89    */

90   public void removeFields(String JavaDoc name);
91
92   /** Returns a field with the given name if any exist in this document, or
93    * null. If multiple fields exists with this name, this method returns the
94    * first value added.
95    */

96   public Field getField(String JavaDoc name);
97
98   /** Returns the string value of the field with the given name if any exist in
99    * this document, or null. If multiple fields exist with this name, this
100    * method returns the first value added.
101    */

102   public String JavaDoc get(String JavaDoc name);
103
104   /** Returns an Enumeration of all the fields in a document. */
105   public Enumeration JavaDoc fields();
106   /**
107    * Returns an array of {@link Field}s with the given name.
108    * This method can return <code>null</code>.
109    *
110    * @param name the name of the field
111    * @return a <code>Field[]</code> array
112    */

113    public Field[] getFields(String JavaDoc name);
114
115   /**
116    * Returns an array of values of the field specified as the method parameter.
117    * This method can return <code>null</code>.
118    *
119    * @param name the name of the field
120    * @return a <code>String[]</code> of field values
121    */

122   public String JavaDoc[] getValues(String JavaDoc name);
123
124   /** Prints the fields of a document for human consumption. */
125   public String JavaDoc toString();
126 }
127
128
Popular Tags