This week's book giveaway is in the Open Source forum.
We're giving away four copies of Programmers Guide to Apache Thrift and have Randy Abernethy on-line!
See this thread for details.
Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

creating an Adapter for my interface??  RSS feed

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul is this approach look ok for my project??
Thanks Lisa
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for the record, I didn't sugest it, she asked how to do it...
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it would thanks
Lisa I have been giving thoughts to my design
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!