• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

criteriaFind review

 
Raffe Paffe
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my criteriaFind. Its big and i am not happy with it but it does work. Any comments would be great.

And the other methods...:

Thanks for any help!
[ March 19, 2003: Message edited by: Mark Spritzler ]
 
Miguel Roque
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Raffe.
I've implemented my criteriaFind in the following way.
1) I pick up the criteria string and pass it to a parse method that uses a string tokenizer to convert the criteria in a DataInfo.
2) Read all the records from the database and compare them with the created DataInfo received from the parse method. This is a special case equals.
3) If the records are equals, I add them to a ArrayList.
It's a simple implementation that takes +/- 30 lines of code.
Miguel
 
Raffe Paffe
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miguel, that sounds great!
1) I pick up the criteria string and pass it to a parse method that uses a string tokenizer to convert the criteria in a DataInfo.

How do you do that???
 
Miguel Roque
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raffe.
I'm in a hurry now, but your tokenizer can be built to understand =' and like this each two tokens are the field name and the value.
Build then a DataInfo with this and return that DataInfo. You have to compare a existent DataInfo with the fields of the Database and insert the tokens in the same position in the new criteria.
I've put a post on this I think it was in february.
I have to go now.
Miguel
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raffe, I edited your post so that the code doesn't make the UBB software look wierd.
It happens when a line of code is really long and it distorts the posts.
Well, now it looks fine.
Most of the time we close threads that have too much code to give away for an implementation of the SCJD assignment. But I am going to let this stay for a day or two so you can get an answer, but then I will need to delete the thread after that time.
Mark
 
Raffe Paffe
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark, sorry about the code. I wanted some comments for the way I do it. Its ok to remove the code.
 
Rajesh So
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do the following way: Comments are graciously invited.
1) The input is "database index number = value String" delimited by ",".
2) The process is:
2.1) Use one StringTokenizer for delimiter ","
2.2) Use StringTokenizers (for number of key-value pairs) for delimiter "=".

2.3) Search
3) The output is a List.
I am yet to implement for "ANY".
Rajesh
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sound close Rajesh.
what does "database index number " mean?
Are you changing the directions for what the criteria string is supposed to look like. They give you explicit instructions on how the criteria string should be, and a number is not it.
They want the field name = value string seperated by commas.
Good Luck
Mark
 
Kal iance
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anybody used list for the origin and destination (airports) ? and allow multiple selections on the airports so the query string would look like "Carrier='SpeedyAir$SOMETHING',Origin='SFO$XYZ$ABC'"
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rajesh Rajesh:
I am yet to implement for "ANY".
My suggestion for "ANY" would be to implement it at the front end.
  • It doesn't add anything whatsoever to the criteriaFind API; if you want to allow any value for a field, simply don't include it in your criteria!
  • "ANY" is an English word, and in other languages you'd have to handle it at the front end anyway. Of course we don't do i18n in this application, but it's another hint that this is fundamentally a front-end concern.
  • It's at least as simple to implement at the client end as at the server.
  • - Peter
    [ April 01, 2003: Message edited by: Peter den Haan ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic