Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

serializing an ArrayList

 
Ricardo Soares
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, here is my problem:

i have the following classes:







each time i create an instance of Event it receives a date and is then added to the arraylists events

I have another class that does the serialization to and from xml

when i deserialize the xml it restores all the elements of the events arraylist but each event has its date ( day month and year ) with values 0

is there anything i need to do in order to make my serialization save the variables from the date class ?

thanks in advance
 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did not post the relevant part of your Date class.
Hopefully the data members are not transient!
 
Ricardo Soares
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no they are not transient

 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That seems to be ok. How do you fill that List?
 
Ricardo Soares
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



class helper is a class with methods to create, edit, remove, etc
 
Ishan Pandya
Ranch Hand
Posts: 226
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not Sure but if your are building a manual "Date" class which implements Serializable and has Constructor of your choice then please do change its name from Date to MyDate or anything you like..and make the respective changes every where in your code.
I think it would be because if you use "java.util.*" as an import statement it may take the inbuilt Date class.
Do the change and post what happens after that..
 
Paul Clapham
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ricardo Soares wrote:I have another class that does the serialization to and from xml

when i deserialize the xml it restores all the elements of the events arraylist but each event has its date ( day month and year ) with values 0

is there anything i need to do in order to make my serialization save the variables from the date class ?


Well, yes there is. But since we don't know how your deserializing works, it's hard to say much about exactly what you would have to do. I can say that just declaring classes as Serializable doesn't have any effect on how you get your data out of an XML document -- at least, probably not. How about showing us how you deserialize from XML?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic