File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Extra Method at Data.java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Extra Method at Data.java" Watch "Extra Method at Data.java" New topic
Author

Extra Method at Data.java

Song Jing Lim
Ranch Hand

Joined: Feb 11, 2003
Posts: 56
So far as I know, beside implement methods define at DBMain.java, we can create few method at Data.java.

But can I use that method by other class?

Let say I got a DataAdaptor as below:

Public Class DataAdaptor{
DBMain data = null;
pubic DataAdaptor(String dbpath){
data = new Data(dbpath);
}
}

Can I just define data as Data type instead DBMain? E.g.
Public Class DataAdaptor{
Data data = null;
pubic DataAdaptor(String dbpath){
data = new Data(dbpath);
}
}

So I can use those extra method define at Data.java which didn't define at DBMain interface e.g.
data.newmethod()

Any help on this?


Rgds,<br />Song Jing
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi

Nobody forbid you to implement other interface, or to add new methods on you Data class (or at least like this is in my specs).

Regards M.


SCJP, SCJD, SCWCD, OCPJBCD
Song Jing Lim
Ranch Hand

Joined: Feb 11, 2003
Posts: 56
Thanks for reply...

But is that any limitation that I can only add private method to Data.java? if I add extra public method (e.g. getNumberOfRec()) for Data.pub, then I only can instantate Data object as below:

Data db = new Data(dbpath);

instead of

DBMain db = new Data(dbpath);

Is that necessary to instantate db object as DBMain?

The public method I plan to implement include retrieve record version (using timestamp) by adaptor class:

So if

Class Adaptor(){

DBMain db = new Data(dbpath);

public int updateRec(Subcontractor obj){
String objVersion = obj.getVersion();
int recNo = obj.getRecNo();
String recVersionInDb = db.getRecVersion(recNo);
if(objVersion.equalIgnoreCase(recVersionInDb)){
....
}
}

I not able call db.getRecVersion(recNo) if db is DBMain object. I can only call that method if:
Data db = new Data(dbPath);

Back to my original question:
Any one pass SCJD by instantate db in adaptor class:
Data db = new Data(dbPath);

Or every one just do like:
DBMain db = new Data(dbPath);

Please help... :roll:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extra Method at Data.java
 
Similar Threads
DBMain
Certain Points to ponder
NX:Contractor About RemoteException
B&S 2.3.2 - Data class as a singleton
B&S: Making name and location data available to UI client