Re: XMLEncoder/XMLDecoder Beta 2

From: Kevin Menard (nirvdru..egativetwenty.net)
Date: Thu Dec 16 2004 - 08:30:19 EST

  • Next message: Kevin Menard: "Re: XMLEncoder/XMLDecoder Beta 2"

    On Dec 15, 2004, at 4:19 PM, John Martyniak wrote:

    > Kevin,
    >
    > This is really progressing along nicely.
    >
    > I have a question about the map file though. Is the plan to make that
    > customizable? Meaning that I might make several maps for a given type
    > of
    > object, to either go to a different end result, or one may have more
    > information than the other.

    Sorry, I guess I still don't follow what you mean. The map file is by
    definition customizable. What I have done is provided a default
    encoding in the absence of a map file. As far as different mapping
    files are concerned, just feed whichever one you want to encoder. So,
    modifying my previous example:

             final ByteArrayOutputStream out = new ByteArrayOutputStream();
             final XMLEncoder encoder = new XMLEncoder(new PrintWriter(out,
    true));

             for (final Iterator it = bookmarks.iterator(); it.hasNext();)
             {
                    final Bookmark b = (Bookmark) it.next();
                    encoder.encode("Bookmark", bookmark,
    "mapping_file_name");
                    encoder.getPrintWriter(); // If this is not here,
    out.toString() will return "".
                    System.out.println(out.toString());
             }

    Note that I have not yet provided a convenience method for encoding
    collections with mapping files.

    Then when you decode, simply provide the mapping file name you want.
    This is a bit different from WOXMLCoder, which essentially bound the
    mapping file with a particular instance of the encoder. In my
    implementation, you can use different mapping files with the same
    encoder instance.

    Is this what you were asking? Were you looking for something else?

    -- 
    Kevin
    



    This archive was generated by hypermail 2.0.0 : Thu Dec 16 2004 - 08:31:27 EST