[jdom-interest] Beta5 candidate

Peter V. Gadjokov pvg at c-c-s.com
Wed Sep 27 01:17:20 PDT 2000


>Yep.  Make sure the utils class is package protected.  (Even at that
>it's unfortunate we'd need another class, even a support class, for
>people to see in the package.  Any way to do it elegantly without the
>extra class?)

I've put it in a org.jdom.util package but that's easy to change to org.jdom
and package protect it if that goes down better. It's not really a class,
just a couple of global functions. Their functionality can be explicitly cut
and pasted in the 3-5 places in which it is used. That's not 'elegant' in my
book but I'm not religious about it, I can make that change too, it will
just be a little more annoying to maintain in the future. 

Here's what it looks like - 

public class SerializationUtils
{
    public static void writeList(List list, ObjectOutputStream out)
        throws IOException
    [...] 
    public static List readList(ObjectInputStream in)
        throws IOException, ClassNotFoundException
    [...]	
    public static void writeNamespace(Namespace ns, ObjectOutputStream out)
        throws IOException
    [...] 
    public static Namespace readNamespace(ObjectInputStream in)
        throws IOException, ClassNotFoundException
    [...]
}

And it gets called in places like this - Element.writeObject - 

    private void writeObject(ObjectOutputStream out) throws IOException {
        
        out.writeInt(JDOM_ELEMENT_SVER);
        out.writeObject(name);
        SerializationUtils.writeList(attributes, out);
        SerializationUtils.writeList(content, out);
        SerializationUtils.writeNamespace(namespace, out);
    }

I just grepped my tree, there are three call pairs from two classes to
write/read list and two call pairs from two classes to write/read namespace.
Let me know which way you'd prefer to see this go, I'll wrap it up and spew
to the list tonight (or shortly after I hear from you)

-pvg



More information about the jdom-interest mailing list