wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes creating an Adapter for my interface?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "creating an Adapter for my interface??" Watch "creating an Adapter for my interface??" New topic
Author

creating an Adapter for my interface??

Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
I have the following problem here is my interface:

package suncertify.db;
import java.io.*;
import java.util.*;
import java.rmi.*;
public interface DataClient extends Remote
{
public FieldInfo [] getFieldInfo()throws RemoteException;
public DataInfo getRecord(int recNum)throws DatabaseException, RemoteException;
public DataInfo find(String toMatch)throws DatabaseException, RemoteException;
public void add(String [] newData)throws DatabaseException, RemoteException;
public void modify(DataInfo newData)throws DatabaseException, RemoteException;
public void delete(DataInfo toDelete)throws DatabaseException, RemoteException;
public void close() throws RemoteException;
public void lock(int record)throws IOException, RemoteException;
public void unlock(int record)throws RemoteException;
public DataInfo[] criteriaFind(String criteria) throws DatabaseException, RemoteException;
public String[] getComboValues(int fieldNum) throws DatabaseException, RemoteException;
public int getMatchCount(String matchCount) throws DatabaseException,RemoteException;
}
the problem is when I compile DataClientLocal
without abstract keyword then I get a ton of errors staing class must be declared abstract it does not define all the methods in my interface//
Any Ideas perhaps making an adapter class for my interface??
How to declare an adapter for my class
public abstract class DataClientLocal implements DataClient
{
.
.
.}I need to implement an adapter instaed of DataClient
m Thanks for any help Lisa

Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
Creating your own adapter class is done by declaring an empty body for all abstract methods declared - and then overriding one (or more) of those methods in your instantiation.
Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
Paul is this approach look ok for my project??
Thanks Lisa
luis veron
Ranch Hand

Joined: Mar 07, 2001
Posts: 35
hi lisa,
I think we don't need to declare the class as abstact as Paul suggest, we only need to implement those record as empty. For example;

public DataInfo getRecord(int recNum) throws DatabaseException {}

Am I right? You will noticed too that I removed the synchronized modifier (in this case for getRecord) to allow concurrent access to the db.
Does it make sense?
Thanks
[This message has been edited by luis veron (edited March 15, 2001).]
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
Just for the record, I didn't sugest it, she asked how to do it...
Andrew Spruce
Greenhorn

Joined: Feb 27, 2001
Posts: 21
Wouldn't it make sense to declare the class abstract anyway? given that it has no method implementations.
This would stop it from being used directly.

[This message has been edited by Andrew Spruce (edited March 27, 2001).]
[This message has been edited by Andrew Spruce (edited March 27, 2001).]
Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
Yes it would thanks
Lisa I have been giving thoughts to my design
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating an Adapter for my interface??
 
Similar Threads
OO Design issue with Data and RMI instance??
Trying to instantiate my middle tier class??see code
Question regarding data class and extending data
Error compiling DataClientLocal
Naming.Lookup and Rebind