Original Post
Hi, I have a small problem with the serialization of my objects. I have a basicobject that contains some parameters like a name, position etc. All my objects in my project are extending from this one. Now for sending information over the network, I would like to send only the basicobject part and not the complete extended class.
public class BasicObject {
String title;
int posx;
int posy;
}
public class ExtendedObject extends basicObject {
Image image;
Arraylist values;
public ExtendedObject(Image image){
this.image = image;
}
}
I convert my objects to a bytearray and then send them over the network by using sockets. When i cast it back to an object it's from the type ExtendedObject and not BasicObject. Can I do something like
ExtendedObject obj = new ExtendedObject(image1); -> this i have to start with
BasicObject obj = (BasicObject)obj; -> this is what i would like to have, but it doesn't work, I always get an error that the class is not found, which is normal cause the other program doesn't know the class ExtendedObject.
Is it possible to get only the BasicObject information? Thanks! Kind regards