Package weka.core.xml

Class XMLOptions

  • All Implemented Interfaces:
    RevisionHandler

    public class XMLOptions
    extends Object
    implements RevisionHandler
    A class for transforming options listed in XML to a regular WEKA command line string.

    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • XMLOptions

        public XMLOptions​(String xml)
                   throws Exception
        Creates a new instance of XMLOptions.
        Parameters:
        xml - the xml to parse (if "
        Throws:
        Exception - if the construction of the DocumentBuilder fails
        See Also:
        setValidating(boolean)
      • XMLOptions

        public XMLOptions​(File file)
                   throws Exception
        Creates a new instance of XMLOptions.
        Parameters:
        file - the XML file to parse
        Throws:
        Exception - if the construction of the DocumentBuilder fails
        See Also:
        setValidating(boolean)
      • XMLOptions

        public XMLOptions​(InputStream stream)
                   throws Exception
        Creates a new instance of XMLOptions.
        Parameters:
        stream - the XML stream to parse
        Throws:
        Exception - if the construction of the DocumentBuilder fails
        See Also:
        setValidating(boolean)
      • XMLOptions

        public XMLOptions​(Reader reader)
                   throws Exception
        Creates a new instance of XMLOptions.
        Parameters:
        reader - the XML reader to parse
        Throws:
        Exception - if the construction of the DocumentBuilder fails
        See Also:
        setValidating(boolean)
    • Method Detail

      • getValidating

        public boolean getValidating()
        returns whether a validating parser is used.
        Returns:
        whether a validating parser is used
      • setValidating

        public void setValidating​(boolean validating)
                           throws Exception
        sets whether to use a validating parser or not.
        Note: this does clear the current DOM document!
        Parameters:
        validating - whether to use a validating parser
        Throws:
        Exception - if the instantiating of the DocumentBuilder fails
      • getDocument

        public Document getDocument()
        returns the parsed DOM document.
        Returns:
        the parsed DOM document
      • getXMLDocument

        public XMLDocument getXMLDocument()
        returns the handler of the XML document. the internal DOM document can be accessed via the getDocument() method.
        Returns:
        the object handling the XML document
        See Also:
        getDocument()
      • toCommandLine

        public String toCommandLine()
                             throws Exception
        returns the given DOM document as command line.
        Returns:
        the document as command line
        Throws:
        Exception - if anything goes wrong initializing the parsing
      • toArray

        public String[] toArray()
                         throws Exception
        returns the current DOM document as string array.
        Returns:
        the document as string array
        Throws:
        Exception - if anything goes wrong initializing the parsing
      • toString

        public String toString()
        returns the object in a string representation (as indented XML output).
        Overrides:
        toString in class Object
        Returns:
        the object in a string representation
      • main

        public static void main​(String[] args)
                         throws Exception
        for testing only. prints the given XML file, the resulting commandline and the string array.
        Parameters:
        args - the commandline options.
        Throws:
        Exception - if something goes wrong