aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Do i have to create new exception for my interface 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 "Do i have to create new exception for my interface" Watch "Do i have to create new exception for my interface" New topic
Author

Do i have to create new exception for my interface

ritu ko
Greenhorn

Joined: Jul 30, 2003
Posts: 3
Hi all,
in my interface :
Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:
package suncertify.db;
public interface DBMain {
// Reads a record from the file. Returns an array where each
// element is a record value.
public String [] read(int recNo) throws RecordNotFoundException;
// Modifies the fields of a record. The new value for field n
// appears in data[n].
public void update(int recNo, String [] data)
throws RecordNotFoundException;
// Deletes a record, making the record number and associated disk
// storage available for reuse.
public void delete(int recNo) throws RecordNotFoundException;
// 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 int [] find(String [] criteria)
throws RecordNotFoundException;
// Creates a new record in the database (possibly reusing a
// deleted entry). Inserts the given data, and returns the record
// number of the new record.
public int create(String [] data) throws DuplicateKeyException;
// Locks a record so that it can only be updated or deleted by this client.
// If the specified record is already locked, the current thread gives up
// the CPU and consumes no CPU cycles until the record is unlocked.
public void lock(int recNo) throws RecordNotFoundException;
// Releases the lock on a record.
public void unlock(int recNo) throws RecordNotFoundException;
// Determines if a record is currenly locked. Returns true if the
// record is locked, false otherwise.
public boolean isLocked(int recNo)
throws RecordNotFoundException;
}
1. do i have to create new recordnotfoundexception.
2. if yes for que 1 . where ( is my taught right ) to create as a subclass of ioexception.
new to java development .
Hope someone can guide me on the right path.
thank u
Ritu.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11479
    
  94

Hi Ritu
Welcome to JavaRanch

1. do i have to create new recordnotfoundexception.

You probably have an instruction to the effect of "Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package."
So, yes you do have to create the RecordNotFound exception.

2. if yes for que 1 . where ( is my taught right ) to create as a subclass of ioexception.

I think that is reasonable.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
ritu ko
Greenhorn

Joined: Jul 30, 2003
Posts: 3
thanks andrew.
ritu
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Ritu:
2. if yes for que 1 . where ( is my taught right ) to create as a subclass of ioexception.
Andrew:
I think that is reasonable.

I wouldn't do that. "RecordNotFoundException" simply must tell the caller that the specified record does not exist. It's quite different from an IO issue IMO. So I would extend Exception instead.
Best,
Phil.
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
I completely agree. Please check this thread.
M


Java Regular Expressions
ritu ko
Greenhorn

Joined: Jul 30, 2003
Posts: 3
Thanks all for your help.
ritu.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Do i have to create new exception for my interface