File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "UB 1.3.3 find & create" Watch "UB 1.3.3 find & create" New topic

UB 1.3.3 find & create

Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 232
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?)
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

    Joined: Jul 19, 2004
    Posts: 8393

    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
    OCAJP 7
    I agree. Here's the link:
    subject: UB 1.3.3 find & create
    It's not a secret anymore!