I'm new to java - what does protected transient mean? I'm having trouble finding documentation on it.public class TheBean extends Container{ private transient OfficeConnection mConnection;...
11/3/2005 4:30:50 PM
Err, did you mean private or what?Protected access in Java means the field or method is accessible to the class, its subclasses, and all the other classes in the same package. The transient keyword indicates that the field isn't part of the data saved when the class is serialized.
11/3/2005 8:03:09 PM
http://java.sun.com/docs/books/tutorial/essential/io/providing.htmlhttp://mindprod.com/jgloss/transient.html
11/4/2005 12:02:18 AM
11/4/2005 5:02:15 PM
Sorry, you're wrong. Protected access is also accessible to all classes in the same package. I'll leave the proof as an exercise to the reader.
11/4/2005 6:31:36 PM
okay i've wondered about this for a long time: what is Serializable and when do we want a class to implement this interface?
11/4/2005 7:32:48 PM
Serialize is another way to say 'marshall'. Basically you write out the Class instance member data into a form that can be persisted and/or transmitted. Obviously since this persistance is heirarchical (if you have other class members) they need to be Serializable as well.
11/4/2005 7:44:33 PM
sorry i don't follow. i dont know what marshall means either...
11/4/2005 8:02:15 PM
okay...one very primitive example of serialization would be to 'marshall' a class out into XMLSay you have a Java class called Dog
public class Dog{ private String _breed = "Golden Retriever"; private String _color = "Blonde"; private int _height = 22; private int _weight = 105; private String _name = ""; private transient boolean initialized = false; public Dog(String name) { //All our dogs look the same _name = name; initialized = true; }}Dog bogey = new Dog("Bogey");
<Dog> <Breed value="Golden Retriever" type="String" /> <Name value="Bogey" type="String" /> <Color value="Blonde" type="String" /> <Height value=22 type="int" /> <Weight value=105 type="int" /></Dog>
11/4/2005 8:33:43 PM
thanks. makes more sense now.
11/4/2005 9:01:56 PM
11/4/2005 11:10:16 PM
11/5/2005 10:34:20 AM
^^^^thanks scud. That example helped alot.
11/6/2005 3:54:57 PM
As someone who knows nothing about CS, this thread's title made me chuckle.
11/6/2005 4:42:03 PM
think of serializing as like "freeze drying" a java object.you usually don't need to worry about transient member variables, since you usually aren't making classes that implement Serializable (although you might occationally extend a class that implements it... like Swing classes for example).
11/6/2005 8:34:24 PM