Package weka.core.xml
Class XMLOptions
java.lang.Object
weka.core.xml.XMLOptions
- All Implemented Interfaces:
RevisionHandler
A class for transforming options listed in XML to a regular WEKA command line
string.
- Version:
- $Revision: 10203 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
the name attribute.static final String
the type attribute.static final String
the value attribute.static final String
the DTD for the XML file.static final String
the root node.static final String
tag for a single option.static final String
tag for a list of options.static final String
a value of the type attribute.static final String
a value of the type attribute.static final String
a value of the type attribute.static final String
a value of the type attribute.static final String
a value of the type attribute.static final String
a value of the type attribute. -
Constructor Summary
ConstructorDescriptionCreates 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
Modifier and TypeMethodDescriptionreturns the parsed DOM document.Returns the revision string.boolean
returns whether a validating parser is used.returns the handler of the XML document.static void
for testing only.void
setValidating
(boolean validating) sets whether to use a validating parser or not.String[]
toArray()
returns the current DOM document as string array.returns the given DOM document as command line.toString()
returns the object in a string representation (as indented XML output).
-
Field Details
-
TAG_OPTION
tag for a single option.- See Also:
-
TAG_OPTIONS
tag for a list of options.- See Also:
-
ATT_NAME
the name attribute.- See Also:
-
ATT_TYPE
the type attribute.- See Also:
-
ATT_VALUE
the value attribute.- See Also:
-
VAL_TYPE_FLAG
a value of the type attribute.- See Also:
-
VAL_TYPE_SINGLE
a value of the type attribute.- See Also:
-
VAL_TYPE_HYPHENS
a value of the type attribute.- See Also:
-
VAL_TYPE_QUOTES
a value of the type attribute.- See Also:
-
VAL_TYPE_CLASSIFIER
a value of the type attribute.- See Also:
-
VAL_TYPE_OPTIONHANDLER
a value of the type attribute.- See Also:
-
ROOT_NODE
the root node.- See Also:
-
DOCTYPE
the DTD for the XML file.- See Also:
-
-
Constructor Details
-
XMLOptions
Creates a new instance of XMLOptions.- Throws:
Exception
- if the construction of the DocumentBuilder fails- See Also:
-
XMLOptions
Creates a new instance of XMLOptions.- Parameters:
xml
- the xml to parse (if "<?xml" is not found then it is considered a file)- Throws:
Exception
- if the construction of the DocumentBuilder fails- See Also:
-
XMLOptions
Creates a new instance of XMLOptions.- Parameters:
file
- the XML file to parse- Throws:
Exception
- if the construction of the DocumentBuilder fails- See Also:
-
XMLOptions
Creates a new instance of XMLOptions.- Parameters:
stream
- the XML stream to parse- Throws:
Exception
- if the construction of the DocumentBuilder fails- See Also:
-
XMLOptions
Creates a new instance of XMLOptions.- Parameters:
reader
- the XML reader to parse- Throws:
Exception
- if the construction of the DocumentBuilder fails- See Also:
-
-
Method Details
-
getValidating
public boolean getValidating()returns whether a validating parser is used.- Returns:
- whether a validating parser is used
-
setValidating
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
returns the parsed DOM document.- Returns:
- the parsed DOM document
-
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:
-
toCommandLine
returns the given DOM document as command line.- Returns:
- the document as command line
- Throws:
Exception
- if anything goes wrong initializing the parsing
-
toArray
returns the current DOM document as string array.- Returns:
- the document as string array
- Throws:
Exception
- if anything goes wrong initializing the parsing
-
toString
returns the object in a string representation (as indented XML output). -
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-
main
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
-