Need Serializable help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Need Serializable help

  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Question Need Serializable help

    Say I have a class:
    Code:
    class Request implement java.io.Serializable {
      
      // attributes
      User reqUser = new User(...);
      Location reqLoc = new Location(...);
      Priority reqPr = new Priority(...);
      Domain reqDom = new Domain (...);  
    
    }
    And a collection class of Requests:
    Code:
    class RequestColl {
    
     Vector RequestList = new Vector(); // will hold Requests
    
    }
    Questions:
    1) Can i directly serialize RequestList and expect all the Requests it holds to be serialized?

    2) If I serialize each Request instance on its own, must the classes it has as its attributes implement Serializable as well? Etc
    Code:
    class Domain implements Serializable {...}
    Thanks a lot!

    [ArchAngel added CODE tags]

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    1) Can i directly serialize RequestList and expect all the Requests it holds to be serialized?

    Pretty much (but see part 2)

    2) If I serialize each Request instance on its own, must the classes it has as its attributes implement Serializable as well? Etc

    Whenever Java tries to serialize a Request object, whether in the process of serializing an entire List or a single instance, it will need for those classes used to be declared Serializable.

    Just try to serialize it and find out!
    ArchAngel.
    O:-)

  3. #3
    Join Date
    Oct 2003
    Posts
    2
    thanks for your help! Reason I asked was because i didn't seem to be able to serialize that collection class

    o yes, thanks for tidying up after me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center