The R Project SVN R

Rev

Rev 5458 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5458 Rev 8090
Line 1... Line 1...
1
/*==============================================================================
1
/*============================================================================
2
 
2
 
3
  Project: Simple JAVA Search Engine for Keyword Search
3
  Project: Simple JAVA Search Engine for Keyword Search
4
  
4
  
5
  JAVA Source file for the class IndexTable
5
  JAVA Source file for the class IndexTable
6
  
6
  
7
  COPYRIGHT (C), 1998, Thomas Baier
7
  COPYRIGHT (C), 1998-2000, Thomas Baier, R Core Development Team
8
 
8
 
9
 *  This program is free software; you can redistribute it and/or modify
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
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
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
12
 *  (at your option) any later version.
Line 19... Line 19...
19
 *  You should have received a copy of the GNU General Public License
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
20
 *  along with this program; if not, write to the Free Software
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 
22
 
23
  
23
  
24
  $Source: /scratch/CVS-ARCHIVE/R/doc/html/search/IndexTable.java,v $
-
 
25
  
24
  
26
  $Revision: 1.4 $
25
  $Revision: 1.5 $
27
 
26
 
28
 
-
 
29
  $Date: 1999/08/10 09:56:03 $
27
  $Date: 2000/02/10 17:03:55 $
30
  
28
  
31
  $Author: ripley $
29
  $Author: leisch $
32
 
-
 
33
==============================================================================*/
-
 
34
 
30
 
-
 
31
============================================================================*/
35
 
32
 
36
/* -------------------------------- Imports --------------------------------- */
-
 
37
 
33
 
38
import java.util.Vector;
34
import java.util.Vector;
39
import java.util.Enumeration;
35
import java.util.Enumeration;
40
 
36
 
41
 
37
 
42
 
-
 
43
/*==============================================================================
-
 
44
                          Interface of class IndexTable
-
 
45
==============================================================================*/
-
 
46
 
-
 
47
/*------------------------------------------------------------------------------
-
 
48
  CLASS:    IndexTable
-
 
49
  SUPER:    Vector
-
 
50
  CONF. TO: 
-
 
51
  PURPOSE:  
-
 
52
  NOTES:    
-
 
53
 
-
 
54
  HISTORY:  98-04-26: created
-
 
55
            98-05-15: new static members for search-mode
-
 
56
------------------------------------------------------------------------------*/
-
 
57
public class IndexTable extends Vector
38
public class IndexTable extends Vector
58
{
39
{
59
  /*============================================================================
-
 
60
                                Public methods
-
 
61
  ============================================================================*/
-
 
62
 
40
 
63
  /*----------------------------------------------------------------------------
-
 
64
    INTERFACE: 
-
 
65
    PURPOSE:   build a vector of found entries
-
 
66
  	      
-
 
67
    NOTES:     convenience function to extend Vector super class
-
 
68
  
-
 
69
    PARAMS:    String key: the search string
41
  public Vector search (String key, boolean searchDesc,
70
    THROWS:    
-
 
71
    RETURNS:   Vector: a vector of found entries or null if no matches found
-
 
72
  
-
 
73
    HISTORY:   98-04-26: created
-
 
74
               98-05-15: new parameter for search mode
-
 
75
  ----------------------------------------------------------------------------*/
-
 
76
  public Vector search (String key,int mode)
42
			boolean searchKeywords, boolean searchAliases)
77
  {
43
  {
78
    Vector returnValue = new Vector ();
44
    Vector returnValue = new Vector ();
79
    Enumeration cursor = elements ();
45
    Enumeration cursor = elements ();
80
 
46
    
81
    while (cursor.hasMoreElements ()) {
47
    while (cursor.hasMoreElements ()) {
82
      IndexEntry entry = (IndexEntry) cursor.nextElement ();
48
      IndexEntry entry = (IndexEntry) cursor.nextElement ();
83
      
49
      
84
      if (entry.matches (key,mode)) {
50
      if (entry.matches (key, searchDesc,
-
 
51
			 searchKeywords, searchAliases)){
85
	returnValue.addElement (entry);
52
	returnValue.addElement (entry);
86
      }
53
      }
87
    }
54
    }
88
    if (!returnValue.isEmpty ()) {
55
    if (!returnValue.isEmpty ()) {
89
      return returnValue;
56
      return returnValue;
90
    }
57
    }
91
    
58
    
92
    return null;
59
    return null;
93
  }
60
  }
94
 
-
 
95
 
-
 
96
  /*============================================================================
-
 
97
                              Protected methods
-
 
98
  ============================================================================*/
-
 
99
 
-
 
100
  /*============================================================================
-
 
101
                               Private methods
-
 
102
  ============================================================================*/
-
 
103
 
-
 
104
  /*============================================================================
-
 
105
                             Instance Variables
-
 
106
  ============================================================================*/
-
 
107
 
-
 
108
  /*============================================================================
-
 
109
                                Static Data
-
 
110
  ============================================================================*/
-
 
111
  public static final int cSearchDescription = 0x00000001;
-
 
112
}
61
}
113
 
62
 
114
 
63
 
115
/*==============================================================================
-
 
116
 
-
 
117
  HISTORY:
-
 
118
  
-
 
119
  $Log: IndexTable.java,v $
-
 
120
  Revision 1.4  1999/08/10 09:56:03  ripley
-
 
121
  change FSF address in copyrights
-
 
122
  add some copyrights in src/gnome and elsewhere
-
 
123
 
-
 
124
  Revision 1.3  1999/03/05 19:18:38  pd
-
 
125
  branch update
-
 
126
 
-
 
127
 
-
 
128
  Revision 1.2  1999/03/04 17:15:18  leisch
-
 
129
  various bugfixes
-
 
130
 
-
 
131
  Revision 1.1.4.1  1999/03/02 15:19:56  leisch
-
 
132
  search used only kewords, no titles
-
 
133
 
-
 
134
  Revision 1.2  1998/05/15 22:09:15  baier
-
 
135
  support searching in description
-
 
136
 
-
 
137
  Revision 1.1  1998/04/26 21:46:51  baier
-
 
138
  Initial revision
-
 
139
 
-
 
140
 
-
 
141
==============================================================================*/
-
 
142
 
-
 
143
 
-
 
144
// Local Variables:
64
// Local Variables:
145
// mode: Java
65
// mode: Java
146
// mode: font-lock
66
// mode: font-lock
147
// End:
67
// End: