aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S : Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S : Exception" Watch "B&S : Exception" New topic
Author

B&S : Exception

henry ang
Greenhorn

Joined: Dec 19, 2006
Posts: 12
Hi..

I am quite puzzle as to why the given requirement require us to throw RecordNotFoundException in the method lockRecord(long recNo)

I have a hashmap(lockedRecords) which stored the recNo and its matching cookie value.

In the event that a recNo is found in the hashmap, it would mean someone is already using it, and the client wanting to lock the record would need to wait until it is unlocked by the prev client.

In the event that no recNo is found in the lockedRecords, it would mean that the recNo is safe to use for the calling client, and my program would update the hashmap, return the cookie number and notify all.

However, i can't see the occasion where i need to throw a RecordNotFoundException


-------------------------<br />SCSA,SCNA,SCJP,SCEA
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
Just because the method signature in the interface mentions the exception doesn't mean the implementation class must actually throw it.
It just means the implementation class CAN throw it.


42
Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89
However, i can't see the occasion where i need to throw a RecordNotFoundException


what if the recoNo does not exist in the database file?
henry ang
Greenhorn

Joined: Dec 19, 2006
Posts: 12
Thanks Mike..

You are right.. this is the condition which i have missed
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: B&S : Exception