KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > storage > search > StringSearchConstraint


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.storage.search;
11
12 import java.util.*;
13
14 /**
15  * A constraint specifically for advanced types of text searches.
16  * <p>
17  * In addition to searchterms, a <em>search type</em> and a
18  * <em>match type</em> can be specified:
19  * <p>
20  * The search type specifies how the search is performed:
21  * Must be one of:
22  * <ul>
23  * <li>{@link #SEARCH_TYPE_WORD_ORIENTED SEARCH_TYPE_WORD_ORIENTED}
24  * - searches for the most occurrences of the words in the search terms.
25  * Order and proximity of words is not significant.
26  * <li>{@link #SEARCH_TYPE_PHRASE_ORIENTED SEARCH_TYPE_PHRASE_ORIENTED}
27  * - searches for occurrence of the sequence of words in the search terms.
28  * <li>{@link #SEARCH_TYPE_PROXIMITY_ORIENTED SEARCH_TYPE_PROXIMITY_ORIENTED}
29  * - searches for the most occurrences of the words within a given
30  * word distance.
31  * Order of words is not important.
32  * </ul>
33  * <p>
34  * The match type specifies how individual words in the
35  * search terms are matched with words in the searched text.
36  * <ul>
37  * <li>{@link #MATCH_TYPE_LITERAL MATCH_TYPE_LITERAL}
38  * - exact match only
39  * <li>{@link #MATCH_TYPE_FUZZY MATCH_TYPE_FUZZY}
40  * - fuzzy match: matches words within the specified number of
41  * typo's as well (specified by parameter <code>PARAM_FUZZINESS</code>)
42  * <li>{@link #MATCH_TYPE_SYNONYM MATCH_TYPE_SYNONYM}
43  * - matches synonyms as well
44  * </ul>
45  * <p>
46  * The searchterms may containt the following wildchard characters as well:
47  * <ul>
48  * <li>% for any string
49  * <li>_ for a single character
50  * </ul>
51  * <p>
52  * Depending on searchtype and searchmode, the following parameters
53  * can be set:
54  * <ul>
55  * <li>{@link #PARAM_FUZZINESS PARAM_FUZZINESS}
56  * - <code>Float</code>, specifies maximum allowed number of
57  * typo's per word, expressed as fraction of word length.
58  * (E.g. 0,2 means: maximum 2 typo's for 10 letter words.).<br />
59  * This parameter is only relevant when used with match type
60  * <code>MATCH_TYPE_FUZZY</code>.
61  * It can only be set for this match type, and is cleared when
62  * the match type is set to another value.
63  * <li>{@link #PARAM_PROXIMITY_LIMIT PARAM_PROXIMITY_LIMIT}
64  * - <code>Integer</code>, specifies maximum distance between
65  * searched words.<br />
66  * This parameter is only relevant when used with search type
67  * <code>SEARCH_TYPE_PROXIMITY_ORIENTED</code>.
68  * It can only be set for this search type, and is cleared when
69  * the search type is set to another value.
70  * </ul>
71  *
72  * @author Rob van Maris
73  * @version $Id: StringSearchConstraint.java,v 1.4 2005/04/25 14:56:57 pierre Exp $
74  * @since MMBase-1.7
75  */

76 public interface StringSearchConstraint extends FieldConstraint {
77
78     /** Search type for <em>word oriented</em> search. */
79     public final static int SEARCH_TYPE_WORD_ORIENTED = 1;
80
81     /** Search type for <em>phrase oriented</em> search. */
82     public final static int SEARCH_TYPE_PHRASE_ORIENTED = 2;
83
84     /** Search type for <em>proximity oriented</em> search. */
85     public final static int SEARCH_TYPE_PROXIMITY_ORIENTED = 3;
86
87     /**
88      * Search type descriptions corresponding to the search type values:
89      * {@link #SEARCH_TYPE_WORD_ORIENTED}, {@link #SEARCH_TYPE_PHRASE_ORIENTED}, and
90      * {@link #SEARCH_TYPE_PROXIMITY_ORIENTED}
91      */

92      String JavaDoc[] SEARCH_TYPE_DESCRIPTIONS = new String JavaDoc[] {
93          null, // not specified
94
"word oriented",
95          "phrase oriented",
96          "proximity oriented"
97     };
98
99     /** Match type for <em>literal</em> matching. */
100     public final static int MATCH_TYPE_LITERAL = 1;
101
102     /** Match type for <em>fuzzy</em> matching. */
103     public final static int MATCH_TYPE_FUZZY = 2;
104
105     /** Match type for <em>synonym</em> matching. */
106     public final static int MATCH_TYPE_SYNONYM = 3;
107
108     /**
109      * Match type descriptions corresponding to the match type values:
110      * {@link #MATCH_TYPE_LITERAL}, {@link #MATCH_TYPE_FUZZY}, and
111      * {@link #MATCH_TYPE_SYNONYM}
112      */

113     public final static String JavaDoc[] MATCH_TYPE_DESCRIPTIONS = new String JavaDoc[] {
114          null, // not specified
115
"literal",
116          "fuzzy",
117          "synonym"
118     };
119
120     /** Name for parameter specifying <em>fuzziness</em> for fuzzy matching. */
121     public final static String JavaDoc PARAM_FUZZINESS = "fuzziness";
122
123     /**
124      * Name for parameter specifying <em>proximity limit</em> for
125      * proximity oriented search.
126      */

127     public final static String JavaDoc PARAM_PROXIMITY_LIMIT = "proximityLimit";
128
129     /**
130      * Gets the search type, this specifies how the search is performed.
131      */

132     int getSearchType();
133
134     /**
135      * Gets value of additional parameters.
136      *
137      * @return The parameters, as an unmodifiable Map.
138      */

139     Map getParameters();
140
141     /**
142      * Gets the match type.
143      */

144     int getMatchType();
145
146     /**
147      * Gets the list of searchterms.
148      *
149      * @return The searchterms, as an unmodifiable List.
150      */

151     List getSearchTerms();
152
153     /**
154      * Returns a string representation of this StringSearchConstraint.
155      * The string representation has the form
156      * "StringSearchConstraint(inverse:&lt:inverse&gt;, field:&lt;field&gt;,
157      * casesensitive:&lt;casesensitive&gt;, searchtype:&lt;searchtype&gt;,
158      * matchtype:&lt;matchtype&gt;, parameters:&lt;parameters&gt;,
159      * searchterms:&lt;searchterms&gt;)"
160      * where
161      * <ul>
162      * <li><em>&lt;inverse&gt;</em>is the value returned by
163      * {@link #isInverse isInverse()}
164      * <li><em>&lt;field&gt;</em> is the field alias returned by
165      * <code>getField().getAlias()</code>
166      * <li><em>&lt;casesensitive&gt;</em> is the value returned by
167      * {@link FieldConstraint#isCaseSensitive isCaseSensitive()}
168      * <li><em>&lt;searchtype&gt;</em> is the value returned by
169      * {@link StringSearchConstraint#getSearchType getSearchType()}
170      * <li><em>&lt;matchtype&gt;</em> is the value returned by
171      * {@link StringSearchConstraint#getMatchType getMatchType()}
172      * <li><em>&lt;parameters&gt;</em> is the map returned by
173      * {@link StringSearchConstraint#getParameters getParameters()}
174      * <li><em>&lt;searchterms&gt;</em> is the list returned by
175      * {@link StringSearchConstraint#getSearchTerms getParameters()}
176      *
177      * @return A string representation of this FieldValueConstraint.
178      */

179     public String JavaDoc toString();
180
181 }
182
Popular Tags