Results 1 to 10 of 10
Thread: marking a field Serializable
- 05-17-2010, 04:26 PM #1
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
- 05-17-2010, 04:54 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
You're not marking it as Serializable.
You're saying attribute "xyz" is of a class that implements Serializable.
Which is pretty useless in most cases.
- 05-17-2010, 05:01 PM #3
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
so suppose for a declaration
private Serializable parentId;
what would a parentId be of type and what would the potential values of parentid be of?
if parentId is of a class that implements Serializable then taht could be any class.
can you tell me where exactly and in what context can it be used.
- 05-17-2010, 05:10 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
You don't use Serializable like that, unless you're doing something funky which someone other that me would have to explain.
You declare classes as Serializable, and define attributes as transient if you don't want them to be serialised.
Your "parentId" example would simply inform whatever system you have that parentId is Serializable. That's it.
- 05-17-2010, 05:16 PM #5
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
Exactly its the first time I have seen it -
if thast what it tells the compiler then what use is it if teh class itself is not considered Serializable and what is the datatype of parentid in this case? that is confusing me
- 05-17-2010, 05:43 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Does the class do anything with it?
Not knowing what the situation is I really can't tell you what it's doing.
Where did you see this code?
- 05-17-2010, 06:03 PM #7
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
no ther are just attributes defined as mentioned above - and then there are just constructers and setters and getters thats it . so a class dow not implement serializable but has these fields
- 05-18-2010, 09:07 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
The only thing I can think of, without knowing anything else at all about what it is you're looking at (so this could well be wrong), is that the class is some sort of serliazing mechanism, which holds a bunch of Serializable things. Why? I can't say because I don't have the code.
You do...
- 05-18-2010, 11:09 AM #9
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
You are more likely to see it in conjunction with inheritance for framework code. e.g A database key is most useful if it is Serializable (and Comparable) so you could have
Java Code:import java.io.Serializable; public interface Entity<I extends Serializable & Comparable<I>> extends Serializable, Comparable<Entity<I>> { I getId(); }
- 05-18-2010, 11:27 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Does that match the description given so far though?
They're saying they have a class (unless I'm misreading this badly) that looks like (well, with getters and setters etc):
That doesn't seem to be to be quite the same beast.Java Code:public class Something { Serializable someAttribute; Serializable anotherAttribute; }
Similar Threads
-
how from an Access Currency field I populate a hidden field
By lse123 in forum Java ServletReplies: 4Last Post: 01-17-2010, 11:13 PM -
Serializable problem in writeObject method
By nouvaki in forum New To JavaReplies: 3Last Post: 01-16-2010, 01:56 PM -
Casting to an List<Serializable>
By Whatty in forum Advanced JavaReplies: 5Last Post: 10-15-2009, 07:47 PM -
Forum Rules: Marking your Thread as Solved
By DonCash in forum Forum GuidesReplies: 0Last Post: 04-01-2008, 12:13 PM -
Implementing Serializable interface
By javaplus in forum Advanced JavaReplies: 4Last Post: 12-18-2007, 12:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks