swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: serializing strings


From: Marcus G. Daniels
Subject: Re: serializing strings
Date: 17 Apr 2001 10:57:09 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "DK" == Daniel Kottow <address@hidden> writes:

DK> i would like to initialize some string objects from a file.  i
DK> think through the lisparchiver would be best, since i also want to
DK> edit the parameters by hand. unfortunately, i have not found any
DK> examples on this.maybe somebody can give me a hint on this? 

Ok, the first time you run the program below it will write out an instance
of itself to the file TestSaveString.scm.  The second time you run it,
the data will be loaded and printed.

import swarm.Globals;
import swarm.defobj.Archiver;

public class TestSaveString {
    // Non public instance variables will be skipped
    public String str1;
    public String str2;
    
    TestSaveString () {
        str1 = "string 1";
        str2 = "string 2";
    }

    static void main (String args[]) {
        Globals.env.initSwarm ("TestSaveString", "0.0", "address@hidden",
                               args);

        // Use Globals.env.hdf5AppArchiver for HDF5
        Archiver archiver = Globals.env.lispAppArchiver;

        // get the object back named "obj"
        TestSaveString obj = (TestSaveString) archiver.getObject ("obj");

        if (obj != null)
            {
                System.out.println ("string 1: " + obj.str1);
                System.out.println ("string 2: " + obj.str2);
            }

        // save an instance of this class under the name "obj"
        archiver.putShallow$object ("obj", new TestSaveString ());

        // always call sync after a set of puts
        archiver.sync ();
    }
}

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]