Class VersionedExternalizable

  • All Implemented Interfaces:
    Externalizable, Serializable
    Direct Known Subclasses:
    GradebookDefinition

    @Deprecated
    public abstract class VersionedExternalizable
    extends Object
    implements Externalizable
    Deprecated.
    This is part of the import/export for gradebook1 which will be removed at some point
    Generic helper class for serializing Java objects to and from simply-formatted XML for archival and reconstitution across data definition versions.

    XStream is used to handle the marshalling and unmarshalling work. The main addition is an "externalizableVersion" attribute on the POJO's top-level element. That attribute can then be checked for incompatibilities before reconstitution, and used to convert old data into its new form. (Currently, if there's a version mismatch and nothing is done about it, this class throws a ConversionException.)

    Translation to and from XML can be handled either with the static "toXML" and "fromXML" methods, or through the Externalizable interface. The chief benefit of the static methods is that they (theoretically) give subclasses the ability to translate across versions using XSLT, and possibly even return an object of a different class than the original.

    TODO For the functionality being checked in (site-to-site migration), this class is not strictly necessary. It's here on a speculative basis for upcoming import/archive/merge development.

    See Also:
    Serialized Form
    • Field Detail

      • VERSION_ATTRIBUTE

        public static String VERSION_ATTRIBUTE
        Deprecated.
    • Constructor Detail

      • VersionedExternalizable

        public VersionedExternalizable()
        Deprecated.
    • Method Detail

      • getExternalizableVersion

        public abstract String getExternalizableVersion()
        Deprecated.
        Returns:
        non-null archivable version identifier for the object definition
      • getXStream

        protected static com.thoughtworks.xstream.XStream getXStream()
        Deprecated.
      • toXml

        public static String toXml​(Object obj)
        Deprecated.
        Parameters:
        obj - the Java object (usually a subclass of VersionedExternalizable) to describe as XML
        Returns:
        XML describing the object
      • fromXml

        public static Object fromXml​(String xmlString)
        Deprecated.
        Parameters:
        xmlString - XML string (presumably created by this class) describing a Java object
        Returns:
        the Java object it describes