I am in the process of converting a COBOL system to Java using web
services, but I am realy new to Java. We currently use COBOL copybooks
that contain record layouts so we don't need to redefine database
fields and things like that. I'm not seeing anything similar in Java.
In C++, we used structures, but they don't seem to exist in Java. I
attempted to set up a class for the record layout that simply contained
methods to set field values and get field values. I figured I could
use the class to populate the fields, return the class to the calling
method, and use the "get" functions to retrieve the data. However,
when I attempt to use the methods within the class, they are not
available to me. I assume they are protected somehow, which is
probably a good thing.
My question is, does anyone have any ideas of how I can accomplish what
I am trying to do? I considered returning a delimited string of all of
the fields, but if we later add fields to the layout, we would have to
change EVERY program that tokenized the delimited string. Clearly not
a good thing.
Any ideas would be very much appreciated.
Thanks,
Dan
Jeffrey Schwab - 27 Dec 2005 16:01 GMT
> I am in the process of converting a COBOL system to Java using web
> services, but I am realy new to Java. We currently use COBOL copybooks
[quoted text clipped - 8 lines]
> available to me. I assume they are protected somehow, which is
> probably a good thing.
Are the accessor methods ([gs]et*) declared "public?" It would be
helpful if you could post the definition of one of your custom classes here.
dmckeon@ameritas.com - 28 Dec 2005 13:45 GMT
Everything is declared public. Here is the class I have been testing
with. I have it defined as a Dynamic Web Project and I am trying to
use the methods in a different Dynamic Web Project. Could that be the
problem? Practically speaking, I can't have every project that uses
this class be defined under the same Dynamic Web Project. Maybe I'm
just missing the obvious since I'm new to this. Thanks for the help!
public class ImageRecord {
String appId;
String imgPath;
//constructor
public ImageRecord() {
init();
}
public void init(){
this.appId = "";
this.imgPath = "";
}
public void setappId(String appid) {
this.appId = appid;
}
public void setimgPath(String path) {
this.imgPath = path;
}
public String getappId() {
return this.appId;
}
public String getimgPath() {
return this.imgPath;
}
}