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 StringDEMAND_XSD_FILEReference to demand schema location TODO: move to properties fileprotected Demandsdemandsthe demands to populateprotected LayeredNetwork<?,?>referenceNetworkReference network to use when demand relate to network entitiesprotected ZoningreferenceZoningReference zoning to use when demands relate to zoning entitiesprotected PlanitDemandsReaderSettingssettingssettings for the readerprotected PlanitZoningReaderzoningReaderzoning 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 usedZoninggetReferenceZoning()each demands reader is expected to ensure that its demand relates to a zoning this reference zoning can be obtained (after reading is complete).PlanitDemandsReaderSettingsgetSettings()any settings to configure the reader can be configured by collecting these settingsprotected voidpopulateDemandConfiguration()Sets up all the configuration data from the XML demands fileprotected voidpopulateDemandContents()Parses the demand contents of the XMLDemandsread()Parse the XMLand populate the demands memory modelvoidreset()reset the reader to allow for marking unnecessary resources for garbage collectionprotected voidsetDemands(Demands demands)Set the demands to populatevoidsetReferenceNetwork(MacroscopicNetwork referenceNetwork)Set reference network to usevoidsetReferenceZoning(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 PlanItExceptionSets 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 PlanItExceptionParses 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:
readin interfaceConverterReader<Demands>- Returns:
- parsed network
-
getSettings
public PlanitDemandsReaderSettings getSettings()
any settings to configure the reader can be configured by collecting these settings- Specified by:
getSettingsin 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:
resetin interfaceConverterEntity- Overrides:
resetin 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:
getReferenceZoningin 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
-
-