• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

find method

 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

...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]...


The find method in my data class implements the above statement to something like the pseudo-code below:



The above code implies the following assumptions:
- to match a value in database, client has to pass a null value
- to get no matched values, client has to pass an "EMPTY" or some other String values that don't/will never exist in datafile. Client is not supposed to use the "" String since the code fieldValue.startsWith("") will always return true.


Is this a good implementation?Is it ok to compare criteria values from field values as Strings? Or should i compare them as bytes?

/tim
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

This looks reasonable.

You could simply convert an empty string entered by the user into a null value for search purposes, as it does not make sense for the user to be searching for an empty string.

Given the provided API indicates that all fields in a record are to be treated as Strings, I feel that it is OK to compare them as Strings.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic