• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finder specification

 
Alex M�ller
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

URLyBrd
maybe my english isn't so good but i've got really problems in understanding the following description of the find method.

Field n in the database file is described by criteria[n]. A null value in criteria[n] matches any field value. A non-null value in criteria[n] matches any field value that begins with criteria[n].
public int[] find(String[] criteria) throws ....

For example assume that there's such a table
table:
name surname address

1. Does the description mean that criteria is always the same size of tablecolumns?
2. If so, does that mean, that criteria={"m�ller","alex", null}; results in all records?
3. What do i do with an empty string? I want to use regexpression and an empty string matches any string. But this makes no sence, isn't it?

Thx for help
Alex M�ller
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex,

1. Does the description mean that criteria is always the same size of tablecolumns?

Although one could argue that it would be legal that criteria could be smaller than the number of columns, I think it is a safer choice to make them always the same size.

2. If so, does that mean, that criteria={"m�ller","alex", null}; results in all records?

Again, this is a choice one can make: AND-type or OR-type searching. I choose for AND-type searching, because it seemed to have more practical use. In that case the criteria would select all records where the first field starts with "m�ller" and the second starts with "alex". The criteria (null,null,null) would always select all records.

3. What do i do with an empty string? I want to use regexpression and an empty string matches any string. But this makes no sence, isn't it?

According to the interface definition, an empty string indeed matches any string (because any string starts with an empty string). So an empty string does the same as a null string.

Frans.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic