// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. 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]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public long[] findByCriteria(String[] criteria);
SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
SCJP (1.4), SCWCD, SCJD
I have a name and location JTextfields
In my opinion, you are going beyond the requirement by doing the server side validation such as you show in point number 2. I would like others to comment on it though.
Originally posted by Philippe Maquet:
Arun,
Did you think of the JComboBox solution ?
Regards,
Phil.
SCJP (1.4), SCWCD, SCJD
I do have client side validation by using the JComboBox to choose from the drop-down list, this way the user is not allowed to enter nonsensical text.
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.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
2. I'd like to say "good point", but how do you abstract the field type (none of the fields are typed in the schema) ? If you don't hardcode your test, you are OK too IMO even if, as Bharat, I think you go beyond the requirements.
But these methods in my case are synchronized on the static instance of the RAF.
What do you mean with "abstract the field type" and "hardcode your test"?
I am just waiting to finish this stuff, and get it over with
And i dont have a SCWCD exam to take a break... (already got it)
JTextFields are OK, but JComboBoxes probably will give a better user experience and they solve any criteria validation issue. In your instructions as in mine, the criteria values must match exactly. It means that entering "New Yor" instead of "New York" as location should return no record. With a JcomboBox, the user may just type "N", check that he got "New York", press enter ... and get the results he expects. Better, he can see which are the possible locations without performing any search ...
"location", "null", "null", "null", "null", "null", "null"
"null", "name", "null", "null", "null", "null", "null"
"location", "name", "null", "null", "null", "null", "null"
"null", "null", "null", "null", "null", "null", "null"
Because I've intepreted the requirement "It must allow the user to search the data for all records" that we would have a search field at the GUI, in which the user could type one criteria and it would search through all fields. But I think now that this sentence means we have to search for:
"null", "null", "null", "null", "null", "null", "null"
in which case all the records would be returned.
Is that right?
SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
Originally posted by Philippe Maquet:
In your instructions as in mine, the criteria values must match exactly. It means that entering "New Yor" instead of "New York" as location should return no record.
SCJP (1.4), SCWCD, SCJD
Originally posted by Ulrich Heeger:
So my question, RAF uses another thread to access the db.-file or I'm fine with the implementation described above?
SCJP (1.4), SCWCD, SCJD
But the statement above is what caught me. I was thinking that if i enter "New" in my location field, it should fetch all the records where location starts with "New" - like "New York". Let me paste the interface .. and see if i am wrong.
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.
Now i am confused .. i see the advantages of using JComboBox. One for the name, one for the location. Then have to have a 'hook' which has to update the JComboBox in case of new inserts.
SCJP (1.4), SCWCD, SCJD
Did you add some "type" notion at MetaData level (something like myDateField.setType(MetaData.DATE)), in which case that field will get its data checked automatically (by Data, MetaData or even itself) because of the type you assigned to it ? Or did you hard-code the call to validateDate() for the fifth field because you know it's a date ? These were the questions, and the answers I expect are yes/no (I mean yes to the first one, and no to the second
oui, je suis un p'tit suisse
Because you and the others said that it is beyond the requirements, I think I will pass on it (Should we document this decision?)
But you're right, it's not very elegant to hardcode it. If we wouldn' be reduced to this f.... interface, then it would be much easier to create an own Class Record with all setters and getters for the fields.
But it doesn't make much sense IMO to invest in extending MetaData with a fixed database file format we cannot change.
I am using multiple data instances and a single static RAF. So i cannot just synchronize the public methods. See Bharats reasons for it above. My public methods (other than lock/unlock which are synched on the WeakHashMap) are synched on this RAF. If my methods are not synched on RAF, then i will face a problem, where one of the methods might change the RAFs' position when another method is reading some bytes.
I believe in your case you have multiple data instances, single RAF handle and a single instance of a Datahelper class. Your public methods are not synched in your Data class, but the two methods in your datahelper class are synchronized (readFixedString and writeFixedString or something like it). In this case i dont see the need to synchronize on the RAF handle. Only one instance of the data class will have access to the datahelper class which will do the actual reading and writing, there by your RAF handle will be controlled by only that instance. So you will not have any dirty reads or dirty writes or dead locks.
In short what you have done should work and you dont have to sync on the RAF handle like me, as long as you use only one instance of DataHelper class and its methods are synchronized.
"I'm not back." - Bill Harding, Twister
if the filechannel.read(buf) cannot read the supposed length of the record (indicating corrupted record? throw RecNotFound)
Originally posted by Ulrich Heeger:
Hi Arun,
I have one more question concerning your request:
Does it mean you catch IOException for throwing a RecNotFoundException?
Greetings
Ulrich
SCJP (1.4), SCWCD, SCJD
look! it's a bird! it's a plane! It's .... a teeny tiny ad
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|