Package weka.core.xml
Class XMLOptions
- java.lang.Object
-
- weka.core.xml.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)
-
-
Field Summary
Fields Modifier and Type Field Description static StringATT_NAMEthe name attribute.static StringATT_TYPEthe type attribute.static StringATT_VALUEthe value attribute.static StringDOCTYPEthe DTD for the XML file.static StringROOT_NODEthe root node.static StringTAG_OPTIONtag for a single option.static StringTAG_OPTIONStag for a list of options.static StringVAL_TYPE_CLASSIFIERa value of the type attribute.static StringVAL_TYPE_FLAGa value of the type attribute.static StringVAL_TYPE_HYPHENSa value of the type attribute.static StringVAL_TYPE_OPTIONHANDLERa value of the type attribute.static StringVAL_TYPE_QUOTESa value of the type attribute.static StringVAL_TYPE_SINGLEa value of the type attribute.
-
Constructor Summary
Constructors Constructor Description XMLOptions()Creates a new instance of XMLOptions.XMLOptions(File file)Creates a new instance of XMLOptions.XMLOptions(InputStream stream)Creates a new instance of XMLOptions.XMLOptions(Reader reader)Creates a new instance of XMLOptions.XMLOptions(String xml)Creates a new instance of XMLOptions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DocumentgetDocument()returns the parsed DOM document.StringgetRevision()Returns the revision string.booleangetValidating()returns whether a validating parser is used.XMLDocumentgetXMLDocument()returns the handler of the XML document.static voidmain(String[] args)for testing only.voidsetValidating(boolean validating)sets whether to use a validating parser or not.String[]toArray()returns the current DOM document as string array.StringtoCommandLine()returns the given DOM document as command line.StringtoString()returns the object in a string representation (as indented XML output).
-
-
-
Field Detail
-
TAG_OPTION
public static final String TAG_OPTION
tag for a single option.- See Also:
- Constant Field Values
-
TAG_OPTIONS
public static final String TAG_OPTIONS
tag for a list of options.- See Also:
- Constant Field Values
-
ATT_NAME
public static final String ATT_NAME
the name attribute.- See Also:
- Constant Field Values
-
ATT_TYPE
public static final String ATT_TYPE
the type attribute.- See Also:
- Constant Field Values
-
ATT_VALUE
public static final String ATT_VALUE
the value attribute.- See Also:
- Constant Field Values
-
VAL_TYPE_FLAG
public static final String VAL_TYPE_FLAG
a value of the type attribute.- See Also:
- Constant Field Values
-
VAL_TYPE_SINGLE
public static final String VAL_TYPE_SINGLE
a value of the type attribute.- See Also:
- Constant Field Values
-
VAL_TYPE_HYPHENS
public static final String VAL_TYPE_HYPHENS
a value of the type attribute.- See Also:
- Constant Field Values
-
VAL_TYPE_QUOTES
public static final String VAL_TYPE_QUOTES
a value of the type attribute.- See Also:
- Constant Field Values
-
VAL_TYPE_CLASSIFIER
public static final String VAL_TYPE_CLASSIFIER
a value of the type attribute.- See Also:
- Constant Field Values
-
VAL_TYPE_OPTIONHANDLER
public static final String VAL_TYPE_OPTIONHANDLER
a value of the type attribute.- See Also:
- Constant Field Values
-
ROOT_NODE
public static final String ROOT_NODE
the root node.- See Also:
- Constant Field Values
-
DOCTYPE
public static final String DOCTYPE
the DTD for the XML file.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XMLOptions
public XMLOptions() throws ExceptionCreates a new instance of XMLOptions.- Throws:
Exception- if the construction of the DocumentBuilder fails- See Also:
setValidating(boolean)
-
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 Exceptionsets 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 thegetDocument()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).
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
-
-