| 1230 |
leisch |
1 |
/*==============================================================================
|
|
|
2 |
|
|
|
3 |
Project: Simple JAVA Search Engine for Keyword Search
|
|
|
4 |
|
|
|
5 |
JAVA Source file for the class IndexTable
|
|
|
6 |
|
|
|
7 |
COPYRIGHT (C), 1998, Thomas Baier
|
| 3765 |
leisch |
8 |
|
|
|
9 |
* This program is free software; you can redistribute it and/or modify
|
|
|
10 |
* it under the terms of the GNU General Public License as published by
|
|
|
11 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
12 |
* (at your option) any later version.
|
|
|
13 |
*
|
|
|
14 |
* This program is distributed in the hope that it will be useful,
|
|
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
17 |
* GNU General Public License for more details.
|
|
|
18 |
*
|
|
|
19 |
* You should have received a copy of the GNU General Public License
|
|
|
20 |
* along with this program; if not, write to the Free Software
|
|
|
21 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
| 1230 |
leisch |
22 |
|
| 3765 |
leisch |
23 |
|
| 1230 |
leisch |
24 |
$Source: /scratch/CVS-ARCHIVE/R/doc/html/search/IndexTable.java,v $
|
|
|
25 |
|
| 3765 |
leisch |
26 |
$Revision: 1.2 $
|
| 1230 |
leisch |
27 |
|
| 3765 |
leisch |
28 |
$Date: 1999/03/04 17:15:18 $
|
| 1230 |
leisch |
29 |
|
|
|
30 |
$Author: leisch $
|
|
|
31 |
|
|
|
32 |
==============================================================================*/
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
/* -------------------------------- Imports --------------------------------- */
|
|
|
36 |
|
|
|
37 |
import java.util.Vector;
|
|
|
38 |
import java.util.Enumeration;
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
/*==============================================================================
|
|
|
43 |
Interface of class IndexTable
|
|
|
44 |
==============================================================================*/
|
|
|
45 |
|
|
|
46 |
/*------------------------------------------------------------------------------
|
|
|
47 |
CLASS: IndexTable
|
|
|
48 |
SUPER: Vector
|
|
|
49 |
CONF. TO:
|
|
|
50 |
PURPOSE:
|
|
|
51 |
NOTES:
|
|
|
52 |
|
|
|
53 |
HISTORY: 98-04-26: created
|
| 3765 |
leisch |
54 |
98-05-15: new static members for search-mode
|
| 1230 |
leisch |
55 |
------------------------------------------------------------------------------*/
|
|
|
56 |
public class IndexTable extends Vector
|
|
|
57 |
{
|
|
|
58 |
/*============================================================================
|
|
|
59 |
Public methods
|
|
|
60 |
============================================================================*/
|
|
|
61 |
|
|
|
62 |
/*----------------------------------------------------------------------------
|
|
|
63 |
INTERFACE:
|
|
|
64 |
PURPOSE: build a vector of found entries
|
|
|
65 |
|
|
|
66 |
NOTES: convenience function to extend Vector super class
|
|
|
67 |
|
|
|
68 |
PARAMS: String key: the search string
|
|
|
69 |
THROWS:
|
|
|
70 |
RETURNS: Vector: a vector of found entries or null if no matches found
|
|
|
71 |
|
|
|
72 |
HISTORY: 98-04-26: created
|
| 3765 |
leisch |
73 |
98-05-15: new parameter for search mode
|
| 1230 |
leisch |
74 |
----------------------------------------------------------------------------*/
|
| 3765 |
leisch |
75 |
public Vector search (String key,int mode)
|
| 1230 |
leisch |
76 |
{
|
|
|
77 |
Vector returnValue = new Vector ();
|
|
|
78 |
Enumeration cursor = elements ();
|
|
|
79 |
|
|
|
80 |
while (cursor.hasMoreElements ()) {
|
|
|
81 |
IndexEntry entry = (IndexEntry) cursor.nextElement ();
|
|
|
82 |
|
| 3765 |
leisch |
83 |
if (entry.matches (key,mode)) {
|
| 1230 |
leisch |
84 |
returnValue.addElement (entry);
|
|
|
85 |
}
|
|
|
86 |
}
|
|
|
87 |
if (!returnValue.isEmpty ()) {
|
|
|
88 |
return returnValue;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
return null;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
/*============================================================================
|
|
|
96 |
Protected methods
|
|
|
97 |
============================================================================*/
|
|
|
98 |
|
|
|
99 |
/*============================================================================
|
|
|
100 |
Private methods
|
|
|
101 |
============================================================================*/
|
|
|
102 |
|
|
|
103 |
/*============================================================================
|
|
|
104 |
Instance Variables
|
|
|
105 |
============================================================================*/
|
|
|
106 |
|
|
|
107 |
/*============================================================================
|
|
|
108 |
Static Data
|
|
|
109 |
============================================================================*/
|
| 3765 |
leisch |
110 |
public static final int cSearchDescription = 0x00000001;
|
| 1230 |
leisch |
111 |
}
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
/*==============================================================================
|
|
|
115 |
|
|
|
116 |
HISTORY:
|
|
|
117 |
|
|
|
118 |
$Log: IndexTable.java,v $
|
| 3765 |
leisch |
119 |
Revision 1.2 1999/03/04 17:15:18 leisch
|
|
|
120 |
various bugfixes
|
| 1230 |
leisch |
121 |
|
| 3765 |
leisch |
122 |
Revision 1.1.4.1 1999/03/02 15:19:56 leisch
|
|
|
123 |
search used only kewords, no titles
|
|
|
124 |
|
|
|
125 |
Revision 1.2 1998/05/15 22:09:15 baier
|
|
|
126 |
support searching in description
|
|
|
127 |
|
| 1230 |
leisch |
128 |
Revision 1.1 1998/04/26 21:46:51 baier
|
|
|
129 |
Initial revision
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
==============================================================================*/
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
// Local Variables:
|
|
|
136 |
// mode: Java
|
|
|
137 |
// mode: font-lock
|
|
|
138 |
// End:
|