This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes UB 1.3.3 find & create Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "UB 1.3.3 find & create" Watch "UB 1.3.3 find & create" New topic
Author

UB 1.3.3 find & create

Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 230
Some questions again:



1. String[] data is (key does not go to db, just index):
a) key,name,city..
b) name, city..
c) other, what?




It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.


2. String[] criteria contains (all fields must be used?)
a)name,location...
b)name,location
c) other, what?

3. I need to provide to GUI functionality
a) search with all fields
b) search with name and/or location
c) other, what?


And finally design points (comments?):

Uses DBCache, file is read in the beginning
  • synchronized Singleton
  • all member variables private

  • DBCache contains data + schema
  • used helper class to populate & read data
  • don't start if magic cookie don't match

  • DBRecords contains (in DBCache) (LinkedHashMap<Integer, DBRecords>):
  • index(record number),record(actual record)
  • one DBRecord contains(LinkedHashMap<Integer, String>
  • index (way to match against schema), value of the field


  • creation & find uses schema to determine field lengths + amount of fields in db-file (that's why i'm asking all these questions)

    Properties are read from file. Own class extends java.util.Properties
  • magic cookie (set/get)
  • db-file location (set/get)


  • Thanks

    ps. used time 8,5h

    SCJP 5.0, SCJD URLyBird 1.3.3, OCMJEA 5 (SCEA) Factory Homes
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 4925
        
      10

    looking good. used approximately the same approach

    concerning your questions about find and create. i guess they take both an array which contains as many fields as the db model. i check the length of the array to the db-model. if it's not the same i throw IllegalArgumentException

    and your find method will have to return more records than you might show in your gui, because you don't have an option if you have to search on (name and location) or (name or location). so you have to return all records starting with specified name or with the specified location. and in your business layer you have to filter the returned array depending on which choice the user made.

    SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
    http://www.javaroe.be/
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: UB 1.3.3 find & create
     
    Similar Threads
    URLyBird findByCriteria
    find method in B&S
    Do we need to filter the search result data?
    Search
    a question about requirement, findByCriteria