Package org.goplanit.io.input
Class PlanItInputBuilder
- java.lang.Object
-
- org.goplanit.input.InputBuilderListener
-
- org.goplanit.io.input.PlanItInputBuilder
-
- All Implemented Interfaces:
EventListener
,PlanitComponentListener
,EventListener
public class PlanItInputBuilder extends InputBuilderListener
Class which reads inputs from XML input files- Author:
- gman6028
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_SEPARATOR
The default separator that is assumed when no separator is provided
-
Constructor Summary
Constructors Constructor Description PlanItInputBuilder(String projectPath)
Constructor which generates the input objects from files in a specified directory, using the default extension ".xml"PlanItInputBuilder(String projectPath, String xmlFileExtension)
Constructor which generates the input objects from files in a specified directory
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onPlanitComponentEvent(PlanitComponentEvent event)
Whenever a project component is created this method will be invokedprotected void
populateDemands(Demands demands, Zoning zoning, MacroscopicNetwork network)
Populates the Demands object from the input fileprotected void
populateInitialLinkSegmentCost(PopulateInitialLinkSegmentCostEvent initialCostEvent)
Populate the initial link segment cost from a CSV fileprotected void
populateMacroscopicNetwork(MacroscopicNetwork network)
Creates the macroscopic network object from the data in the input fileprotected void
populateRoutedServices(RoutedServices routedServicesToPopulate)
Populate the routed services based on the local XML file if it can be found.protected void
populateServiceNetwork(ServiceNetwork serviceNetworkToPopulate)
Populate the service network based on the local XML file if it can be found.protected void
populateZoning(Zoning zoning, MacroscopicNetwork network)
Creates the Zoning object and connectoids from the data in the input filestatic boolean
validateXmlInputFile(File xmlFileLocation, String schemaFileLocation)
Validates an input XML file against an XSD file-
Methods inherited from class org.goplanit.input.InputBuilderListener
getKnownSupportedEventTypes
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.event.EventListener
hasKnownSupportedEventTypes
-
-
-
-
Field Detail
-
DEFAULT_SEPARATOR
public static final String DEFAULT_SEPARATOR
The default separator that is assumed when no separator is provided- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PlanItInputBuilder
public PlanItInputBuilder(String projectPath) throws PlanItException
Constructor which generates the input objects from files in a specified directory, using the default extension ".xml"- Parameters:
projectPath
- the location of the input file directory- Throws:
PlanItException
- thrown if one of the input required input files cannot be found, or if there is an error reading one of them
-
PlanItInputBuilder
public PlanItInputBuilder(String projectPath, String xmlFileExtension) throws PlanItException
Constructor which generates the input objects from files in a specified directory- Parameters:
projectPath
- the location of the input file directoryxmlFileExtension
- the extension of the data files to be searched through- Throws:
PlanItException
- thrown if one of the input required input files cannot be found, or if there is an error reading one of them
-
-
Method Detail
-
populateMacroscopicNetwork
protected void populateMacroscopicNetwork(MacroscopicNetwork network) throws PlanItException
Creates the macroscopic network object from the data in the input file- Parameters:
network
- the infrastructure network object to be populated from the input data- Throws:
PlanItException
- thrown if there is an error reading the input file
-
populateZoning
protected void populateZoning(Zoning zoning, MacroscopicNetwork network) throws PlanItException
Creates the Zoning object and connectoids from the data in the input file- Parameters:
zoning
- the Zoning object to be populated from the input datanetwork
- PhysicalNetwork object previously defined- Throws:
PlanItException
- thrown if there is an error reading the input file
-
populateDemands
protected void populateDemands(Demands demands, Zoning zoning, MacroscopicNetwork network) throws PlanItException
Populates the Demands object from the input file- Parameters:
demands
- the Demands object to be populated from the input datazoning
- Zoning object previously definednetwork
- network object previously defined- Throws:
PlanItException
- thrown if there is an error reading the input file
-
populateRoutedServices
protected void populateRoutedServices(RoutedServices routedServicesToPopulate) throws PlanItException
Populate the routed services based on the local XML file if it can be found.- Parameters:
routedServicesToPopulate
- to instance to populate- Throws:
PlanItException
- thrown if error
-
populateServiceNetwork
protected void populateServiceNetwork(ServiceNetwork serviceNetworkToPopulate) throws PlanItException
Populate the service network based on the local XML file if it can be found.- Parameters:
serviceNetworkToPopulate
- to instance to populate- Throws:
PlanItException
- thrown if error
-
populateInitialLinkSegmentCost
protected void populateInitialLinkSegmentCost(PopulateInitialLinkSegmentCostEvent initialCostEvent) throws PlanItException
Populate the initial link segment cost from a CSV file- Parameters:
initialCostEvent
- to extract context from to populate its component that it carries- Throws:
PlanItException
- thrown if error
-
validateXmlInputFile
public static boolean validateXmlInputFile(File xmlFileLocation, String schemaFileLocation)
Validates an input XML file against an XSD file- Parameters:
xmlFileLocation
- input XML fileschemaFileLocation
- XSD file to validate XML file against- Returns:
- true if the file is valid, false otherwise
-
onPlanitComponentEvent
public void onPlanitComponentEvent(PlanitComponentEvent event) throws PlanItException
Whenever a project component is created this method will be invoked- Parameters:
event
- event containing the created (and empty) project component- Throws:
PlanItException
- thrown if error
-
-