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 IndexEntry
5
  JAVA Source file for the class IndexEntry
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 18... Line 18...
18
 *
18
 *
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
  $Source: /scratch/CVS-ARCHIVE/R/doc/html/search/IndexEntry.java,v $
-
 
24
  
-
 
25
  $Revision: 1.3 $
23
  $Revision: 1.4 $
26
 
24
 
27
  $Date: 1999/08/10 09:56:03 $
25
  $Date: 2000/02/10 17:03:55 $
28
  
26
  
29
  $Author: ripley $
27
  $Author: leisch $
30
 
-
 
31
==============================================================================*/
-
 
32
 
28
 
-
 
29
============================================================================*/
33
 
30
 
34
/* -------------------------------- Imports --------------------------------- */
-
 
35
 
31
 
36
import java.lang.Object;
32
import java.lang.Object;
37
import java.lang.String;
33
import java.lang.String;
38
import java.applet.AppletContext;
34
import java.applet.AppletContext;
39
import java.net.URL;
35
import java.net.URL;
40
import java.net.MalformedURLException;
36
import java.net.MalformedURLException;
41
 
37
 
42
 
38
 
43
 
39
 
44
/*==============================================================================
-
 
45
                          Interface of class IndexEntry
-
 
46
==============================================================================*/
-
 
47
 
-
 
48
/*------------------------------------------------------------------------------
-
 
49
  CLASS:    IndexEntry
-
 
50
  SUPER:    Object
-
 
51
  CONF. TO: 
-
 
52
  PURPOSE:  
-
 
53
  NOTES:    
-
 
54
 
-
 
55
  HISTORY:  98-04-26: created
-
 
56
------------------------------------------------------------------------------*/
-
 
57
public class IndexEntry extends Object
40
public class IndexEntry extends Object
58
{
41
{
59
  /*============================================================================
-
 
60
                                Public methods
-
 
61
  ============================================================================*/
-
 
62
 
-
 
63
  /*----------------------------------------------------------------------------
-
 
64
    INTERFACE: 
-
 
65
    PURPOSE:   constructor
-
 
66
  	      
-
 
67
    NOTES:    
-
 
68
  
-
 
69
    PARAMS:   
-
 
70
    THROWS:    
-
 
71
    RETURNS:   void
-
 
72
  
-
 
73
    HISTORY:   98-04-26: created
-
 
74
               98-05-08: adapted for new index file format
42
  public IndexEntry (String entry, String keywords, String aliases,
75
	       98-05-10: added trace
43
		     String desc, String url)
76
  ----------------------------------------------------------------------------*/
-
 
77
  public IndexEntry (String title,String keywords,String desc,String url)
-
 
78
  {
44
  {
79
    iTitle = title;
45
    iEntry = entry;
80
    iKey = keywords;
46
    iKey = keywords;
-
 
47
    iAliases = aliases;
81
    iDescription = desc;
48
    iDescription = desc;
82
    iURL = url;
49
    iURL = url;
83
 
50
    
84
    // trace here
51
    // trace here
85
    Tracer.write ("Created IndexEntry. Title = \"" +
52
    Tracer.write ("Created IndexEntry. Entry = \"" +
86
		  title + "\", Keywords = \"" + keywords + "\"\n");
53
		  entry + "\", Keywords = \"" + keywords + "\"\n");
87
    return;
54
    return;
88
  }
55
  }
89
 
56
 
90
 
-
 
91
  /*----------------------------------------------------------------------------
-
 
92
    INTERFACE: 
-
 
93
    PURPOSE:   check for a matching search string
-
 
94
  	      
-
 
95
    NOTES:     case-insensitive compare
-
 
96
  
57
  
97
    PARAMS:    
-
 
98
    THROWS:    
-
 
99
    RETURNS:   boolean: true if matches
-
 
100
  
-
 
101
    HISTORY:   98-04-26: created
-
 
102
               98-05-15: new parameter mode, check description, too
58
  public boolean matches (String aString, boolean searchDesc,
103
  ----------------------------------------------------------------------------*/
-
 
104
  public boolean matches (String aString,int mode)
59
			  boolean searchKeywords, boolean searchAliases)
105
  {
60
  {
106
    // case-insensitive substring!
61
    if (searchAliases &&
107
    if ((mode & IndexTable.cSearchDescription) == IndexTable.cSearchDescription) {
-
 
108
      if ((iKey.toUpperCase ().indexOf (aString.toUpperCase ()) > -1)
62
	(iAliases.toUpperCase ().indexOf (aString.toUpperCase ()) > -1))
109
	  || (iDescription.toUpperCase ().indexOf (aString.toUpperCase ()) > -1)) {
63
      {
110
	return true;
64
	return true;
111
      }
65
      }
-
 
66
    
112
    } else {
67
    if (searchDesc &&
113
      if (iKey.toUpperCase ().indexOf (aString.toUpperCase ()) > -1) {
68
	(iDescription.toUpperCase ().indexOf (aString.toUpperCase ()) > -1))
-
 
69
      {
114
	return true;
70
	return true;
115
      }
71
      }
-
 
72
 
-
 
73
    if (searchKeywords &&
-
 
74
	(iKey.toUpperCase ().indexOf (aString.toUpperCase ()) > -1))
-
 
75
      {
-
 
76
	return true;
-
 
77
      }
116
    }
78
    
117
    return false;
79
    return false;
118
  }
80
  }
119
 
81
 
120
 
82
 
121
  /*----------------------------------------------------------------------------
-
 
122
    INTERFACE: 
-
 
123
    PURPOSE:   return the description text
-
 
124
  	      
-
 
125
    NOTES:     
-
 
126
  
-
 
127
    PARAMS:    
-
 
128
    THROWS:    
-
 
129
    RETURNS:   String: the description
-
 
130
  
-
 
131
    HISTORY:   98-04-26: created
-
 
132
  ----------------------------------------------------------------------------*/
-
 
133
  public String getDescription ()
83
  public String getDescription ()
134
  {
84
  {
135
    return iDescription;
85
    return iDescription;
136
  }
86
  }
137
 
87
 
138
 
-
 
139
  /*----------------------------------------------------------------------------
-
 
140
    INTERFACE: 
-
 
141
    PURPOSE:   return the title string
-
 
142
  	      
-
 
143
    NOTES:     
-
 
144
  
-
 
145
    PARAMS:    
-
 
146
    THROWS:    
-
 
147
    RETURNS:   void
-
 
148
  
-
 
149
    HISTORY:   98-05-08: created
-
 
150
  ----------------------------------------------------------------------------*/
-
 
151
  public String getTitle ()
88
  public String getEntry ()
152
  {
89
  {
153
    return iTitle;
90
    return iEntry;
154
  }
91
  }
155
 
92
 
-
 
93
  public String getAliases ()
-
 
94
  {
-
 
95
    return iAliases;
-
 
96
  }
156
 
97
 
157
  /*----------------------------------------------------------------------------
-
 
158
    INTERFACE: 
-
 
159
    PURPOSE:   return the URL as a string
-
 
160
  	      
-
 
161
    NOTES:     
-
 
162
  
-
 
163
    PARAMS:    
-
 
164
    THROWS:    
-
 
165
    RETURNS:   String: the URL
-
 
166
  
-
 
167
    HISTORY:   98-04-26: created
-
 
168
  ----------------------------------------------------------------------------*/
-
 
169
  public String getURL ()
98
  public String getURL ()
170
  {
99
  {
171
    return iURL;
100
    return iURL;
172
  }
101
  }
173
 
102
 
174
 
103
 
175
  /*============================================================================
-
 
176
                              Protected methods
-
 
177
  ============================================================================*/
-
 
178
 
-
 
179
  /*============================================================================
-
 
180
                               Private methods
-
 
181
  ============================================================================*/
-
 
182
 
-
 
183
  /*============================================================================
-
 
184
                             Instance Variables
-
 
185
  ============================================================================*/
-
 
186
 
-
 
187
  private String iTitle;
104
  private String iEntry;
188
  private String iKey;
105
  private String iKey;
-
 
106
  private String iAliases;
189
  private String iDescription;
107
  private String iDescription;
190
  private String iURL;
108
  private String iURL;
191
 
109
 
192
 
110
 
193
  /*============================================================================
-
 
194
                                Static Data
-
 
195
  ============================================================================*/
-
 
196
}
111
}
197
 
112
 
198
 
-
 
199
/*==============================================================================
-
 
200
 
-
 
201
  HISTORY:
-
 
202
  
-
 
203
  $Log: IndexEntry.java,v $
-
 
204
  Revision 1.3  1999/08/10 09:56:03  ripley
-
 
205
  change FSF address in copyrights
-
 
206
  add some copyrights in src/gnome and elsewhere
-
 
207
 
-
 
208
  Revision 1.2  1999/03/04 17:15:18  leisch
-
 
209
  various bugfixes
-
 
210
 
-
 
211
  Revision 1.1.4.1  1999/03/02 15:19:55  leisch
-
 
212
  search used only kewords, no titles
-
 
213
 
-
 
214
  Revision 1.4  1998/05/15 22:07:56  baier
-
 
215
  also allow search in description
-
 
216
 
-
 
217
  Revision 1.3  1998/05/10 02:43:24  baier
-
 
218
  now a simple data-class
-
 
219
 
-
 
220
  Revision 1.2  1998/04/26 22:35:21  baier
-
 
221
  some comments
-
 
222
 
-
 
223
  Revision 1.1  1998/04/26 21:43:09  baier
-
 
224
  Initial revision
-
 
225
 
-
 
226
 
-
 
227
==============================================================================*/
-
 
228
 
-
 
229
 
-
 
230
// Local Variables:
113
// Local Variables:
231
// mode: Java
114
// mode: Java
232
// mode: font-lock
115
// mode: font-lock
233
// End:
116
// End: