Manual serialization and versioning

Hi all
I have a class with n fields that is serialized in this way:
private void writeObject(ObjectOutputStream out) throws IOException {
for (int i = 0; i < n; i ++){
out.writeXXX(field_n);
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
for (int i = 0; i < n; i ++){
in.readXXX(field_n);
I have serialized versions of the class and I am reading them in my program.
Now I have to add new field in the class. I intend to implement the write method in this way:
private void writeObject(ObjectOutputStream out) throws IOException {
for (int i = 0; i < n; i ++){
out.writeXXX(field_n);
out.writeXXX(newfield);
But I have no idea how to implement the read method to work with the two versions.
Does anyone know how to deal with this?

I found a way to deal with the problem. Now my code looks like this:
private void writeObject(ObjectOutputStream out) throws IOException {
final ObjectOutputStream.PutField field = out.putFields();
field.put(FIELD_VERSION, version);
field.put(FIELD_DATA, toShow);
out.writeFields();
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
try {
final ObjectInputStream.GetField field = in.readFields();
int oldversion = field.get(FIELD_VERSION, 0);
if (oldversion > 0) {
toShow = (ArrayList) field.get(FIELD_TO_SHOW, toShow);
} else {
final ObjectStreamClass streamClass = field.getObjectStreamClass();
ObjectStreamField [] o = streamClass.getFields();
toShow = (ArrayList)field.get(o[1].getName(), new ArrayList());
Looks like the data stored in the old way (directly with outputStream.writeObject()) can be taken from the GetField. So I am using PutField and GetField to write/read the data, and when I see the data was not written in the new way (
int oldversion = field.get(FIELD_VERSION, 0);
if (oldversion > 0) {*old data*/}
) I am reading the old objects wrote trough the writeObject method using the names of the variables I had wrote. I am not sure what exactly is specified in the serialization spec., but this works now.
Hope this will be useful for someone
Best Regards
Zlatko

Similar Messages

  • Auto Save and Versions

    Where can I control Auto Save and Versions? I can't find it in System Settings.
    Can I control it by terminal commands?
    On http://www.apple.com/macosx/what-is/ Apple claims:
    Versions creates a new version of a document each time you open it and every hour while you’re working.
    While here http://www.apple.com/macosx/whats-new/auto-save.html Apple claims:
    Forget about manual saving and forge ahead with confidence. Auto Save in OS X Lion automatically saves your work, while you work, during pauses and every five minutes. And Lion saves changes in the background so you're never interrupted with progress bars.
    So I wonder every five minutes or every hour? Would be nice to make sure on each Mac itself whether it auto-saves every five minutes or every hour and to actually allow its user o set the frequency.

    It does both. It saves your work in the current version every 5 minutes. Every hour, it creates a new version of the document.
    I haven't searched for any version settings, yet.

  • Importing Masters and Versions from iPhoto

    Is it possible to import both Masters and the associated Adjusted Versions from iPhoto into Aperture 3?
    The manual tells how to import the masters into the Aperture library but does not seem to tell how to import the corresponding versions adjusted in iPhoto.

    In iPhoto all images are masters in a sense. When you adjusted an image in iPhoto a duplicate image was made and the adjustments were done to the duplicate giving you two separate files.
    When you import your iPhoto library into Aperture these two files (the original and the adjusted image) are two separate files as far as Aperture is concerned. Aperture will keep them together and apply keywords to each to help you sort it all out once you running the Aperture library but they will not have the same master version relationship that masters and versions created in Aperture have.
    So when you import your iPhoto library all images will come over, you don't need to do anything special to get the adjusted images.

  • Batch rename masters and versions

    Like a dummy, I imported a huge photo shoot without using the easy re-naming.
    Now, I want to rename every photo. I want to keep the numerical order, as it is critical for organizing the project photos. I want the Masters to be renamed (and I assume then that the versions just stay "version1" etc...). I have all my photos in stacks by master and version (not different masters).
    How can I batch rename, keeping the sequential order that is already there.
    (I have read the manual. I have searched on this forum. I still am a little unclear and, hence, the question.)
    Thanks in advance!

    If the images are referenced to an external location (outside Aperture's Library) then you can easily renaming them using Automator.
    Copy all the images you are going to rename to a temp location. Just in case something goes wrong.
    With Aperture closed open Automator, in the finder select all the images you need to rename and drag them to the right part of automator's screen. Now on the very left part select Finder, on the second column, near the bottom drag the rename finder items action to the right part, just under the window with all your images listed. Click on don't add so it will just rename the files (you made a copy previously). Select replace text and enter the old and new text. That way it will keep the numerical part of your files.
    Press play and wait for the action to finish.
    Check in the finder that the files have been renamed properly.
    Open Aperture and go to the project with those images. If the masters can't be found go to File/Manage Referenced files... and in there you can reconnect to the right location. Usually this step won't be needed unless you move the masters to a new location.

  • How do I manually drag and drop songs from music library to iPhone 4 using iTunes 11?

    How do I manually drag and drop songs from music library to iPhone using iTunes 11?

    If you manually manage music... on iTunes 11, go to the top left corner and there will be a pull down bar. Click "show menu bar". From there, go to view, then show sidebar. Magically, it looks like the previous versions of iTunes. Took me 3 hours of trial and error and searching through forums to figure out. Tried calling Apple to have them walk me through it and they said they wouldn't help me since I don't have Apple Care. Whatever. Hope this helps!!

  • I'm not seeing the Auto Save and Versions features

    I have a document open in Pages '09 and I'm running Lion, but I am not seeing the auto save or versions features that you supposedly get my clicking on the document name. Can someone help? Do I have to turn this feature on in preferences?

    I'm actually working on a Word document that Pages has converted and opened, but the document does have a title bar name. So..I have to do a manual save before auto save will start working?!?
    You don't have to do a manual save. Pages will auto save the converted Word document. If you quit Pages after editing the converted document without saving, Pages will reopen the converted Word document, give it a temporary window title of "Untitiled" and have saved your edits.
    I did think I see a preference setting for auto save that wasn't checked in my preferences.
    I don't think Pages every had auto save. Word does though, and this may be what you're remembering.
    Also, how does all this auto save and versions stuff work…
    Have a read of Apple's support document titled OS X Lion: About Auto Save and Versions. This explains both and how the two features are related but different.
    NB While Pages auto saves new, untitled documents it doesn't create a Version of these documents.

  • How to manually drag and drop songs from music library to iPod Shuffle using iTunes 11?

    In iTunes 10, it's simple to just drag and drop a few songs manually from the library/playlist to the Shuffle.  In iTunes 11, Shuffle has its own window.  How do you manually drag and drop songs from music library/playlist to iPod Shuffle using iTunes 11?

    If you manually manage music... on iTunes 11, go to the top left corner and there will be a pull down bar. Click "show menu bar". From there, go to view, then show sidebar. Magically, it looks like the previous versions of iTunes. Took me 3 hours of trial and error and searching through forums to figure out. Tried calling Apple to have them walk me through it and they said they wouldn't help me since I don't have Apple Care. Whatever. Hope this helps!!

  • Serialize and Deserialize

    Serialize and Deserialize with Oracle 9 and Oracle 10
    We have developed a client/server application. Client is a Java application and Server is written in C-Language; link between Java and C is RPC/JRPC.
    We have to serialize and then deserialize a stream in a clob field in Oracle DB. When we deserialize with Oracle 9 we have no problem; now, after a migration to Oracle 10G, the deserialize failed at client level.
    If we test in test environment (Oracle 9) with the same client and the same server we have no problem. The only difference between two enviroenment is only the version of Oracle (9 is OK - 10G is KO).
    We use the OCI api.
    The error message at client level is:
    java.io.InvalidClassException: rpc.wDichiarazione; local class incompatible: stream classdesc serialVersionUID = 2960125282182152041, local class serialVersionUID = 2960125281578161001
    Thanks of all
    Marco

    You've changed a class definition. It has nothing to do with the Oracle version. Recompile that class with
    private static long serialVersionUID = 2960125282182152041L;If you then get another exception, you need to evaluate the changes you've made to the class in the light of what it says about Versioning in the Serialization specification.

  • The message has been rescheduled  .(Manual restart for version)

    Hi
    What is the exact meaning of the following status in SXMB_MONI -
    Manual restart for version ( symbol forward arrow )
    The message has been rescheduled.
    i am getting this status when i have restarted a message from SXMB_MONI
    Any idea why it is not getting processed to success
    what may be the resons ?
    i can see the Q status as red dot (message has errors)
    thanks
    Prashanth

    thanks ...
    so is it a restart of the queues ? (and not the message)
    Is this a task that xi admins normaly do ?
    when i click on the queue it is specifying "not authorized to run the transaction SMQ2"
    So i guess i can request the admin for restart of the queue
    I assume messages wont get lost during queue restart
    thanks
    Prashanht

  • Error in creation of model and version

    Hi experts,
    While I m trying to create Model and Version SAP demo systems, it is showing me error " Live cache is not availble".
    Should I copy a planning version to new or should I contact basis team for that? It is also not allowing me to create new LC connection.
    I am attaching screen shots. Please help.

    Hi All,
    BASIS guy have configured Live Cache. We have started live Cache succesfully.
    Still facing problem in Version stating that an error occured in Live cache.
    Kindly help.
    Attaching screen shot below.

  • Summary report to show all the software components and version installed

    We are using 64bit Windows 2003 and Hyperion Planning and Essbase in 2 separate servers. I am not sure whether Windows can have a summary report to show all the software components and version installed and show it is 32bit or 64bit version installed?
    Thanks!

    Refer steps here to delete SC file.:
    http://support.apple.com/kb/TS2363
    Then proceed to repair your QuickTime. START / CONTROL PANEL / ADD n REMOVE PROGRAMS / highlight QUICKTIME and click CHANGE then REPAIR.

  • How to find Mobile device OS name and version using Flex?

    is there anyway to get device information like OS name and version using flex 4.5.1 or 4.6 SDK. i am developing a project in Flex which needs to identify the end user mobile platform like Android, iOS.. and its version like Android means 2.1,2.2,etc..
    Anyone can help me on this?

    I don't know that there is a proprietary driver. In fact, I'm sure there isn't because I never installed one. I figured there was some code file somewhere that dealt with keyboards. Yes, I have dealt with the developer, they say to tell Apple there is a problem. I have been putting it off and waiting to update since 10.6.3, so the problem is getting a little old. Do I even know there is a problem? I'm not sure what this means. I do know that when I update my operating system past 10.6.2 my keyboard no longer works, and I have to use a stock Apple keyboard to run a time machine reinstall. Why else would I be going through this?

  • Bought a new macbook and want to manually manage music onto my iphone 4s but when i click 'manually manage' and then 'apply' i get the message saying it will erase everything already on there. Need help please!

    Bought a new macbook and want to manually manage music onto my iphone 4s (as it is already full of music from old windows laptop) but when i click 'manually manage' and then 'apply' i get the message saying it will erase everything already on there. Need help please!

    Before you sync your iPhone make sure that all the music that was synced to your phonereviously has been copied to your iTunes on the new MacBook Pro. Then when you connect your phone you will be able to either sync all music or select only those playlists that you want on the phone.

  • MTS with batch management, serialization and Handling unit

    Hello All,
    I am testing a scenario for MTS with batch management, serialization and Handling unit for discrete manufacturing.
    Everything worked fine till I created the Handling unit for the finished product.
    The production order has a quantity of 3 EA.
    It has three serial numbers 1, 2 and 3. (serial numbers can be displayed from order->Header->serial numbers)
    I created one Handling unit for production order quantity of 3 EA.
    I tried to do a goods receipt for the production order using transaction COWBHUWE.
    I get the following error when I try to post the GR:
    Only 0 serial numbers entered instead of 3
    Message no. IO304
    Diagnosis
    There is a serial number obligation, so the number of serial numbers must equal the number of serial numbers in the material document.
    You can post the operation only if you entered the correct number of serial numbers previously.
    System Response
    Depending on the context in which the error arises, the system continues processing, or the required function cannot be performed.
    Procedure
    You have the following options, for example:
    Check that the serial numbers are entered fully.
    If necessary, display an error log.
    If necessary, contact your system administrator.
    What did I miss?
    How to fix this problem?
    Please help.
    Thanks in advance
    George

    I added the serialization procedure HUSL to the serial number profile and it fixed the problem.

  • Table For Purchase Order Version Number and Version Created Date

    Dear Sir,
    Whenever we make any change in Purchase Order , then a new Version Number  along with Created Date is assigned . In Me23n the Version Number and It's Created date is also displayed ( at PO Header Level) .
    We request you to kindly guide us as which Table is required to be reffered to get the Version Number and Version Created date  for the Purchase Order .
    With Thanks and Rgds
    Sonia

    Hi
    Check in EKKO - Purchase order header
    EKPO - Purchase order item
    CDHDR
    CHPOS
    Regards
    Ram
    Edited by: Parasuram M on Sep 16, 2009 11:59 AM

Maybe you are looking for

  • Kernel Panic (iMac) when using Camera Raw (8.2) on CS6

    Everytime I process photos on camera raw using my iMac, it hangs, white screens, then restarts on me. At first it I never had this issue until I installed a data recovery software called Disk Drill (I'm not sure if this is really the cause but panics

  • Exception condition "CNTL_ERROR" raised.  in WDA :  smartform to pdf

    Hii,  I am using a webdynpro - abap application. I am showing  a smartform as a pdf in one on the windows. When the link in the main window is clicked, a secondary window. Instead of the pdf, I get following exception.Kindly help me understand, where

  • PDF generation with FOP throws NPE

    Hi, Stack trace at oracle.xml.jaxp.JXTransformer.reportXSLException(JXTransformer.java:769) at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:342) I'm using standard Java 1.4 API calls to create a PDF document from a DOM with Apache FOP 0

  • How to use Web Activity Step in Workflow

    Hi, Please tell me how to use step "Web Activity" in workflow or give me some good links. Thanks in advance. Regards Arvind Singh

  • ABAP in BW

    There are a lot of examples in the WIKI .. please search for the same Dear All. i have no experiance with ABAP but i want to learn the ABAP which is used in BW in tranformation or routines, i have never use abap can any body tell me the links or eboo