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

public class ParameterSweepParser extends DefaultHandler2
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 Details

    • ParameterSweepParser

      public ParameterSweepParser(URL paramsURL)
      Creates a ParameterSweepParser to parse the specified URL.
      Parameters:
      paramsURL -
    • ParameterSweepParser

      public ParameterSweepParser(InputStream in)
    • ParameterSweepParser

      public ParameterSweepParser(ParameterTreeSweeper sweeper, URL paramsURL)
      Creates a ParameterSweeper parser to use the specified sweeper and to parse the specified URL.
      Parameters:
      sweeper -
      paramsURL -
  • Method Details

    • parse

      Parse the url and return the created ParameterTreeSweeper.
      Returns:
      the created ParameterTreeSweeper.
      Throws:
      ParserConfigurationException
      SAXException
      IOException
    • inputFile

      public void inputFile(String input) throws IOException
      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

      public String readFile(URL url, int size) throws IOException
      Method reads file URL and size (based on content) and returns a string representation of that content.
      Parameters:
      url - the file url
      size - the size of the file
      Returns:
      a string representation of the parameters
      Throws:
      IOException
    • registerStepperCreator

      public void registerStepperCreator(String typeID, ParameterSetterCreator creator)
      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

      public void registerConstantCreator(String constantTypeID, ParameterSetterCreator creator)
      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 interface ContentHandler
      Overrides:
      startElement in class DefaultHandler
      Throws:
      SAXException
    • endElement

      public void endElement(String uri, String localName, String qName) throws SAXException
      Specified by:
      endElement in interface ContentHandler
      Overrides:
      endElement in class DefaultHandler
      Throws:
      SAXException
    • isDouble

      protected boolean isDouble(String val)
    • isLong

      protected boolean isLong(String val)
    • isFloat

      protected boolean isFloat(String val)
    • isInt

      protected boolean isInt(Double value)