Package weka.core.xml

Class KOML

  • All Implemented Interfaces:
    RevisionHandler

    public class KOML
    extends java.lang.Object
    implements RevisionHandler
    This class is a helper class for XML serialization using KOML . KOML does not need to be present, since the class-calls are done generically via Reflection.
    Version:
    $Revision 1.0$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String FILE_EXTENSION
      the extension for KOML files (including '.')
    • Constructor Summary

      Constructors 
      Constructor Description
      KOML()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getRevision()
      Returns the revision string.
      static boolean isPresent()
      returns whether KOML is present or not, i.e.
      static java.lang.Object read​(java.io.File file)
      reads the XML-serialized object from the given file
      static java.lang.Object read​(java.io.InputStream stream)
      reads the XML-serialized object from a stream
      static java.lang.Object read​(java.lang.String filename)
      reads the XML-serialized object from the given file
      static boolean write​(java.io.File file, java.lang.Object o)
      write the XML-serialized object to the given file
      static boolean write​(java.io.OutputStream stream, java.lang.Object o)
      writes the XML-serialized object to a stream
      static boolean write​(java.lang.String filename, java.lang.Object o)
      writes the XML-serialized object to the given file
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • FILE_EXTENSION

        public static final java.lang.String FILE_EXTENSION
        the extension for KOML files (including '.')
        See Also:
        Constant Field Values
    • Constructor Detail

      • KOML

        public KOML()
    • Method Detail

      • isPresent

        public static boolean isPresent()
        returns whether KOML is present or not, i.e. whether the classes are in the classpath or not
        Returns:
        whether KOML is available
      • read

        public static java.lang.Object read​(java.lang.String filename)
                                     throws java.lang.Exception
        reads the XML-serialized object from the given file
        Parameters:
        filename - the file to deserialize the object from
        Returns:
        the deserialized object
        Throws:
        java.lang.Exception - if something goes wrong while reading from the file
      • read

        public static java.lang.Object read​(java.io.File file)
                                     throws java.lang.Exception
        reads the XML-serialized object from the given file
        Parameters:
        file - the file to deserialize the object from
        Returns:
        the deserialized object
        Throws:
        java.lang.Exception - if something goes wrong while reading from the file
      • read

        public static java.lang.Object read​(java.io.InputStream stream)
                                     throws java.lang.Exception
        reads the XML-serialized object from a stream
        Parameters:
        stream - the stream to deserialize the object from
        Returns:
        the deserialized object
        Throws:
        java.lang.Exception - if something goes wrong while reading from the stream
      • write

        public static boolean write​(java.lang.String filename,
                                    java.lang.Object o)
                             throws java.lang.Exception
        writes the XML-serialized object to the given file
        Parameters:
        filename - the file to serialize the object to
        o - the object to write to the file
        Returns:
        whether writing was successful or not
        Throws:
        java.lang.Exception - if something goes wrong while writing to the file
      • write

        public static boolean write​(java.io.File file,
                                    java.lang.Object o)
                             throws java.lang.Exception
        write the XML-serialized object to the given file
        Parameters:
        file - the file to serialize the object to
        o - the object to write to the file
        Returns:
        whether writing was successful or not
        Throws:
        java.lang.Exception - if something goes wrong while writing to the file
      • write

        public static boolean write​(java.io.OutputStream stream,
                                    java.lang.Object o)
                             throws java.lang.Exception
        writes the XML-serialized object to a stream
        Parameters:
        stream - the stream to serialize the object to
        o - the object to write to the stream
        Returns:
        whether writing was successful or not
        Throws:
        java.lang.Exception - if something goes wrong while writing to the stream
      • getRevision

        public java.lang.String getRevision()
        Returns the revision string.
        Specified by:
        getRevision in interface RevisionHandler
        Returns:
        the revision