File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

find() in URLyBIRD - returning all records

 
Rafal Kawecki
Ranch Hand
Posts: 30
Eclipse IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi ranchers,

I need help with the find method because I am all confused now.

Correct me if I'm wrong but:
  • find() method in Data class should not know anything about the view (as as the whole Data class), espacially that the view is interested in searching by name/location only
  • find() is responsible for returning record numbers that match the specified criteria
  • Specification says: 'A null value in criteria[n] matches any field value' - in other words (in my opinion) if there is at least one null then all records should be returned
  • view will be able to look only for: location, name, name or location so it will create:

  • so as you can see the find method will always return ALL records beacuse there will always be at least one null (of course I know there is additional filtering required becasue view expects exact matches)
  • if someday I'll add searching by all fields than no changes to the find() will be required

  • Am I missing somethig?

    Thanks in advance

    Rafal
     
    Roel De Nijs
    Sheriff
    Posts: 9094
    73
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I decided to ignore null values in the criteria array. If all values in criteria array are null I return all valid records. That's how I interpreted things and how I implemented the find-method of the Data class
     
    Rafal Kawecki
    Ranch Hand
    Posts: 30
    Eclipse IDE Java Ubuntu
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Thanks for extremely fast response.
    Roel De Nijs wrote:I decided to ignore null values in the criteria array.

    I don't get it. Can you please elaborate more on that? An example would be useful ;).

    Thanks in advance.
     
    Roel De Nijs
    Sheriff
    Posts: 9094
    73
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It's not hard: only non-null values are used to search the records.

    For example: using String[] criteria = {"par", null, null, ..., null }; will return all non-deleted records which name starts with "par".
     
    Rafal Kawecki
    Ranch Hand
    Posts: 30
    Eclipse IDE Java Ubuntu
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Roel De Nijs wrote:using String[] criteria = {"par", null, null, ..., null }; will return all non-deleted records which name starts with "par".

    and String[] criteria = {"par", "loc", null, ..., null }; will return all non-deleted records which name starts with "par" OR location starts with "loc"?

    One more question: ignoring null values in the criteria array isn't breaking the requirements ?
    String[] criteria = {"par", "loc", null, ..., null }; shouldn't return all the records according to the specification ?

    Thanks
     
    Roel De Nijs
    Sheriff
    Posts: 9094
    73
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Rafal Kawecki wrote:and String[] criteria = {"par", "loc", null, ..., null }; will return all non-deleted records which name starts with "par" OR location starts with "loc"?


    Rafal Kawecki wrote:One more question: ignoring null values in the criteria array isn't breaking the requirements ?
    String[] criteria = {"par", "loc", null, ..., null }; shouldn't return all the records according to the specification ?
    I passed with that approach, so I assume it's not against the requirements But that's of course a decision you have to document in choices.txt (and maybe also a bit in javadoc). The javadoc of my find-method mentions that passing a String[] with all null-values will result in all non-deleted records being returned.
     
    Rafal Kawecki
    Ranch Hand
    Posts: 30
    Eclipse IDE Java Ubuntu
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks man !!!
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic