Class PlanitDemandsReader
- java.lang.Object
-
- org.goplanit.converter.BaseReaderImpl<Demands>
-
- org.goplanit.io.converter.demands.PlanitDemandsReader
-
- All Implemented Interfaces:
ConverterEntity
,ConverterReader<Demands>
,DemandsReader
public class PlanitDemandsReader extends BaseReaderImpl<Demands> implements DemandsReader
Reader to parse PLANit demands from native XML format- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEMAND_XSD_FILE
Reference to demand schema location TODO: move to properties fileprotected Demands
demands
the demands to populateprotected LayeredNetwork<?,?>
referenceNetwork
Reference network to use when demand relate to network entitiesprotected Zoning
referenceZoning
Reference zoning to use when demands relate to zoning entitiesprotected PlanitDemandsReaderSettings
settings
settings for the readerprotected PlanitZoningReader
zoningReader
zoning reader provides alternative way to obtain reference zoning and reference network in case not available upon construction.-
Fields inherited from class org.goplanit.converter.BaseReaderImpl
sourceIdTracker
-
-
Constructor Summary
Constructors Constructor Description PlanitDemandsReader(PlanitDemandsReaderSettings demandsSettings, PlanitZoningReader zoningReader)
Constructor where parsing will be based upon the settings and zoning reader provides zoning (and network)PlanitDemandsReader(PlanitDemandsReaderSettings demandsSettings, LayeredNetwork<?,?> network, Zoning zoning, Demands demandsToPopulate)
Constructor where parsing will be based upon the settings and already present compatible network and zoningPlanitDemandsReader(org.goplanit.xml.generated.XMLElementMacroscopicDemand xmlMacroscopicDemands, LayeredNetwork<?,?> network, Zoning zoning, Demands demandsToPopulate)
Constructor where file has already been parsed and we only need to convert from raw XML objects to PLANit memory model
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LayeredNetwork<?,?>
getReferenceNetwork()
Collect reference network usedZoning
getReferenceZoning()
each demands reader is expected to ensure that its demand relates to a zoning this reference zoning can be obtained (after reading is complete).PlanitDemandsReaderSettings
getSettings()
any settings to configure the reader can be configured by collecting these settingsprotected void
populateDemandConfiguration()
Sets up all the configuration data from the XML demands fileprotected void
populateDemandContents()
Parses the demand contents of the XMLDemands
read()
Parse the XMLand populate the demands memory modelvoid
reset()
reset the reader to allow for marking unnecessary resources for garbage collectionprotected void
setDemands(Demands demands)
Set the demands to populatevoid
setReferenceNetwork(MacroscopicNetwork referenceNetwork)
Set reference network to usevoid
setReferenceZoning(Zoning referenceZoning)
Set reference zoning to use-
Methods inherited from class org.goplanit.converter.BaseReaderImpl
getBySourceId, getSourceIdContainer, initialiseSourceIdMap, initialiseSourceIdMap, registerBySourceId, registerBySourceId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.converter.demands.DemandsReader
getTypeDescription
-
-
-
-
Field Detail
-
settings
protected final PlanitDemandsReaderSettings settings
settings for the reader
-
demands
protected Demands demands
the demands to populate
-
referenceNetwork
protected LayeredNetwork<?,?> referenceNetwork
Reference network to use when demand relate to network entities
-
referenceZoning
protected Zoning referenceZoning
Reference zoning to use when demands relate to zoning entities
-
zoningReader
protected final PlanitZoningReader zoningReader
zoning reader provides alternative way to obtain reference zoning and reference network in case not available upon construction. When using a reader, reference zoning and network are expected to remain null.
-
DEMAND_XSD_FILE
public static final String DEMAND_XSD_FILE
Reference to demand schema location TODO: move to properties file- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PlanitDemandsReader
public PlanitDemandsReader(org.goplanit.xml.generated.XMLElementMacroscopicDemand xmlMacroscopicDemands, LayeredNetwork<?,?> network, Zoning zoning, Demands demandsToPopulate)
Constructor where file has already been parsed and we only need to convert from raw XML objects to PLANit memory model- Parameters:
xmlMacroscopicDemands
- to extract fromnetwork
- reference network for the demands to readzoning
- reference zoning for the demands to readdemandsToPopulate
- to populate
-
PlanitDemandsReader
public PlanitDemandsReader(PlanitDemandsReaderSettings demandsSettings, LayeredNetwork<?,?> network, Zoning zoning, Demands demandsToPopulate)
Constructor where parsing will be based upon the settings and already present compatible network and zoning- Parameters:
demandsSettings
- to usenetwork
- reference network for the demands to readzoning
- reference zoning for the demands to readdemandsToPopulate
- to populate
-
PlanitDemandsReader
public PlanitDemandsReader(PlanitDemandsReaderSettings demandsSettings, PlanitZoningReader zoningReader)
Constructor where parsing will be based upon the settings and zoning reader provides zoning (and network)- Parameters:
demandsSettings
- to usezoningReader
- to construct zoning (and network) from
-
-
Method Detail
-
setDemands
protected void setDemands(Demands demands)
Set the demands to populate- Parameters:
demands
- to populate
-
populateDemandConfiguration
protected void populateDemandConfiguration() throws PlanItException
Sets up all the configuration data from the XML demands file- Throws:
PlanItException
- thrown if there is a duplicate XML Id found for any component
-
populateDemandContents
protected void populateDemandContents() throws PlanItException
Parses the demand contents of the XML- Throws:
PlanItException
- thrown if error
-
read
public Demands read()
Parse the XMLand populate the demands memory model- Specified by:
read
in interfaceConverterReader<Demands>
- Returns:
- parsed network
-
getSettings
public PlanitDemandsReaderSettings getSettings()
any settings to configure the reader can be configured by collecting these settings- Specified by:
getSettings
in interfaceConverterReader<Demands>
- Returns:
- the settings to configrue the reader
-
reset
public void reset()
reset the reader to allow for marking unnecessary resources for garbage collection- Specified by:
reset
in interfaceConverterEntity
- Overrides:
reset
in classBaseReaderImpl<Demands>
-
getReferenceZoning
public Zoning getReferenceZoning()
each demands reader is expected to ensure that its demand relates to a zoning this reference zoning can be obtained (after reading is complete). the converter uses this to avoid the user having to manually transfer this zoning to the writer which also requires this same zoning consistency This is what this method enables- Specified by:
getReferenceZoning
in interfaceDemandsReader
- Returns:
- referenceZoning to supply demands writer with (after invoking
ConverterReader.read()
-
getReferenceNetwork
public LayeredNetwork<?,?> getReferenceNetwork()
Collect reference network used- Returns:
- reference network
-
setReferenceNetwork
public void setReferenceNetwork(MacroscopicNetwork referenceNetwork)
Set reference network to use- Parameters:
referenceNetwork
- to use
-
setReferenceZoning
public void setReferenceZoning(Zoning referenceZoning)
Set reference zoning to use- Parameters:
referenceZoning
- to use
-
-