Package repast.simphony.parameter.xml
Class ParameterSweepParser
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.xml.sax.ext.DefaultHandler2
repast.simphony.parameter.xml.ParameterSweepParser
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,DeclHandler
,EntityResolver2
,LexicalHandler
Parses a parameters xml file and creates ParameterTreeSweeper based on that.
Additional ParameterSetterCreators can be registered for dealing with
additional parameter types using the registerSetterCreator method.
- Version:
- $Revision$ $Date$
- Author:
- Nick Collier
-
Constructor Summary
ConstructorDescriptionParameterSweepParser
(URL paramsURL) Creates a ParameterSweepParser to parse the specified URL.ParameterSweepParser
(ParameterTreeSweeper sweeper, URL paramsURL) Creates a ParameterSweeper parser to use the specified sweeper and to parse the specified URL. -
Method Summary
Modifier and TypeMethodDescriptionvoid
endElement
(String uri, String localName, String qName) void
Method writes out string content to a batch xml file used for temporary data storage.protected boolean
protected boolean
protected boolean
protected boolean
parse()
Parse the url and return the created ParameterTreeSweeper.Method reads file URL and size (based on content) and returns a string representation of that content.void
registerConstantCreator
(String constantTypeID, ParameterSetterCreator creator) Register a setter creator to be used for constant setters during sweeper creation.void
registerStepperCreator
(String typeID, ParameterSetterCreator creator) Register a setter creator to be used during sweeper creation.void
startElement
(String uri, String localName, String qName, Attributes attributes) Methods inherited from class org.xml.sax.ext.DefaultHandler2
attributeDecl, comment, elementDecl, endCDATA, endDTD, endEntity, externalEntityDecl, getExternalSubset, internalEntityDecl, resolveEntity, resolveEntity, startCDATA, startDTD, startEntity
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
ParameterSweepParser
Creates a ParameterSweepParser to parse the specified URL.- Parameters:
paramsURL
-
-
ParameterSweepParser
-
ParameterSweepParser
Creates a ParameterSweeper parser to use the specified sweeper and to parse the specified URL.- Parameters:
sweeper
-paramsURL
-
-
-
Method Details
-
parse
public Pair<Parameters,ParameterTreeSweeper> parse() throws ParserConfigurationException, SAXException, IOExceptionParse the url and return the created ParameterTreeSweeper.- Returns:
- the created ParameterTreeSweeper.
- Throws:
ParserConfigurationException
SAXException
IOException
-
inputFile
Method writes out string content to a batch xml file used for temporary data storage.- Parameters:
input
- the input string to write out- Throws:
IOException
-
readFile
Method reads file URL and size (based on content) and returns a string representation of that content.- Parameters:
url
- the file urlsize
- the size of the file- Returns:
- a string representation of the parameters
- Throws:
IOException
-
registerStepperCreator
Register a setter creator to be used during sweeper creation. When a parameter element whose "type" attribute is equal to the specified typeID is encountered, the specified creator will be used to create the ParameterSetter. The attributes of that element will be passed to the creator so that it can create the setter.- Parameters:
typeID
-creator
-
-
registerConstantCreator
Register a setter creator to be used for constant setters during sweeper creation. When a parameter element whose "constant type" attribute is equal to the specified typeID is encountered, the specified creator will be used to create the ParameterSetter. The attributes of that element will be passed to the creator so that it can create the constant setter.- Parameters:
constantTypeID
- matches agains the constant_type attribute.creator
-
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
isDouble
-
isLong
-
isFloat
-
isInt
-