KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > data > search > SearchTupleSet


1 package prefuse.data.search;
2
3 import java.util.Iterator JavaDoc;
4
5 import prefuse.data.Tuple;
6 import prefuse.data.tuple.DefaultTupleSet;
7
8 /**
9  * <p>Abstract base class for TupleSet implementations that support text
10  * search. These sets provide search engine functionality -- Tuple data fields
11  * can be indexed and then searched over using text queries, the results of
12  * which populate the TupleSet. A range of search techniques are provided by
13  * subclasses of this class.</p>
14  *
15  * <p>
16  * <b>NOTE:</b> The {@link #addTuple(Tuple)} and
17  * {@link #removeTuple(Tuple)}, methods are not supported by this
18  * implementation or its derived classes. Calling these methods will result
19  * in thrown exceptions. Instead, membership is determined by the search
20  * matches found using the {@link #search(String) search} method, which
21  * searches over the terms indexed using the {@link #index(Iterator, String)}
22  * and {@link #index(Tuple, String)} methods.
23  * </p>
24  *
25  * @author <a HREF="http://jheer.org">jeffrey heer</a>
26  * @see prefuse.data.query.SearchQueryBinding
27  */

28 public abstract class SearchTupleSet extends DefaultTupleSet {
29     
30     /**
31      * Returns the current search query, if any.
32      * @return the currently active search query
33      */

34     public abstract String JavaDoc getQuery();
35     
36     /**
37      * Searches the indexed fields of this TupleSet for matching
38      * strings, adding the Tuple instances for each search match
39      * to the TupleSet. The details of how the query is matched to
40      * indexed fields is left to subclasses.
41      * @param query the query string to search for. Indexed fields
42      * with matching text will be added to the TupleSet.
43      */

44     public abstract void search(String JavaDoc query);
45     
46     /**
47      * Indexes the data values for the given field name for
48      * each Tuple in the provided Iterator. These values are used
49      * to construct an internal data structure allowing fast searches
50      * over these attributes. To index multiple fields, simply call
51      * this method multiple times with the desired field names.
52      * @param tuples an Iterator over Tuple instances to index
53      * @param field the name of the attribute to index
54      * @throws ClassCastException is a non-Tuple instance is
55      * encountered in the iteration.
56      */

57     public void index(Iterator JavaDoc tuples, String JavaDoc field) {
58         while ( tuples.hasNext() ) {
59             Tuple t = (Tuple)tuples.next();
60             index(t, field);
61         }
62     }
63     
64     /**
65      * Index an individual Tuple field, so that it can be searched for.
66      * @param t the Tuple
67      * @param field the data field to index
68      */

69     public abstract void index(Tuple t, String JavaDoc field);
70
71     /**
72      * Un-index an individual Tuple field, so that it can no longer be
73      * searched for.
74      * @param t the Tuple
75      * @param field the data field to unindex
76      * @see #isUnindexSupported()
77      */

78     public abstract void unindex(Tuple t, String JavaDoc field);
79     
80     /**
81      * Indicates if this TupleSearchSet supports the unindex operation.
82      * @return true if unindex is supported, false otherwise.
83      * @see #unindex(Tuple, String)
84      */

85     public abstract boolean isUnindexSupported();
86     
87     // ------------------------------------------------------------------------
88
// Unsupported Operations
89

90     /**
91      * This method is not supported by this implementation. Don't call it!
92      * Instead, use the {@link #search(String) search} or
93      * {@link #clear() clear} methods.
94      */

95     public Tuple addTuple(Tuple t) {
96         throw new UnsupportedOperationException JavaDoc();
97     }
98     /**
99      * This method is not supported by this implementation. Don't call it!
100      * Instead, use the {@link #search(String) search} or
101      * {@link #clear() clear} methods.
102      */

103     public boolean removeTuple(Tuple t) {
104         throw new UnsupportedOperationException JavaDoc();
105     }
106     
107 } // end of abstract class SearchTupleSet
108
Popular Tags