Class XMLResourceAdapter
java.lang.Object
net.simplace.sim.io.FWSimIOAdapter
net.simplace.sim.io.resources.FWSimInputAdapter
net.simplace.sim.io.resources.FWSimResourceAdapter<org.jdom2.Element>
net.simplace.sim.io.resources.adapter.XMLResourceAdapter
- All Implemented Interfaces:
FWSimFieldContainer
Resource adapter for XML files (
XMLInterface). The file is registered in the file pool of the interface and
its root element is read into a FWSimResourceCache. A file is only read again if its unique id changed.- Author:
- Andreas Enders
-
Nested Class Summary
Nested classes/interfaces inherited from class FWSimIOAdapter
FWSimIOAdapter.FREQUENCE -
Field Summary
Fields inherited from class FWSimResourceAdapter
iLinesToReadFields inherited from class FWSimInputAdapter
iJexlScript, iShouldCacheToDBFields inherited from class FWSimIOAdapter
iArrayMode, iFieldcount, iFrequence, iHeaderVariables, iInterface, iJexlRule, iKeyMap, iName, iOrderNumber, iProcessTime, iResourceElement, iSession, iSourceKey -
Constructor Summary
ConstructorsConstructorDescriptionXMLResourceAdapter(String aFileName, String aContent, String aComponentName, int aOrderNumber, FWSimSession aFwSimSession, FWSimIOAdapter.FREQUENCE aFrequence, Map<String, String> aKeyMap, String aXPath) Creates the adapter from the graph panel: creates the XML interface and derives the header variables from the file (seereadHeaderList(XMLInterface, Map, FWSimSession)).XMLResourceAdapter(FWSimResourceAdapter<?> aAdapter, XMLInterface aInterface) Copy constructor used when the interface is replaced; the key variables are taken over.XMLResourceAdapter(org.jdom2.Element aResourceElement, FWSimSession aSession, int aOrderNumber) Creates the adapter from aresourceelement of the solution. -
Method Summary
Modifier and TypeMethodDescriptiongetData(FWSimVarMap aVarMap) Registers the file of the current simulation in the file pool and reads it, seegetData(FWSimVarMap, FileData).getData(FWSimVarMap aVarMap, FileData aFileData) Reads an XML file into a new cache, unless it is the same file (unique id) as last time.Methods inherited from class FWSimResourceAdapter
createAdapterFromObservable, createResourceAdapter, getLinesToRead, setLinesToRead, toXML, updateAdapterMethods inherited from class FWSimInputAdapter
getContentType, getInputVariables, getJexlScript, getOutputVariables, getVarMap, isTransformer, setFrequenceAndRule, shouldCacheToDB, toHTMLTablestringMethods inherited from class FWSimIOAdapter
addProcessTime, addVariable, checkCondition, createFormFields, createVariables, finalize, getCreateFormXML, getEditFormXML, getFieldMap, getFrequence, getHeaderVariables, getHeaderXML, getInterface, getJexlRule, getKeyMap, getName, getOrderNumber, getVariable, isArrayMode, isConditionCheck, removeVariable, setInterface, setOrderNumber, toString, writeHeaderList
-
Constructor Details
-
XMLResourceAdapter
public XMLResourceAdapter(org.jdom2.Element aResourceElement, FWSimSession aSession, int aOrderNumber) Creates the adapter from aresourceelement of the solution.- Parameters:
aResourceElement- theresourceelementaSession- the sessionaOrderNumber- order number of the adapter
-
XMLResourceAdapter
public XMLResourceAdapter(String aFileName, String aContent, String aComponentName, int aOrderNumber, FWSimSession aFwSimSession, FWSimIOAdapter.FREQUENCE aFrequence, Map<String, String> aKeyMap, String aXPath) throws ExceptionCreates the adapter from the graph panel: creates the XML interface and derives the header variables from the file (seereadHeaderList(XMLInterface, Map, FWSimSession)).- Parameters:
aFileName- XML fileaContent- XML content instead of a file, may benullaComponentName- name of the adapter and the interfaceaOrderNumber- order number of the adapteraFwSimSession- the sessionaFrequence- frequency the data is read withaKeyMap- key variables; if empty, the user is asked to select themaXPath- XPath expression, not used- Throws:
Exception- if the file cannot be read
-
XMLResourceAdapter
Copy constructor used when the interface is replaced; the key variables are taken over.- Parameters:
aAdapter- the adapter to copyaInterface- the new interface
-
-
Method Details
-
getData
Registers the file of the current simulation in the file pool and reads it, seegetData(FWSimVarMap, FileData).- Specified by:
getDatain classFWSimInputAdapter- Parameters:
aVarMap- variable map of the simulation (e.g. for the key values of the rule)- Returns:
- the cache containing the data read
- Throws:
MissingSimResourceException- if the data cannot be read- See Also:
-
getData
public FWSimResourceCache getData(FWSimVarMap aVarMap, FileData aFileData) throws MissingSimResourceException Reads an XML file into a new cache, unless it is the same file (unique id) as last time.- Parameters:
aVarMap- variable map of the simulationaFileData- the file- Returns:
- the new cache, or
nullif the file was already read - Throws:
MissingSimResourceException- if the file cannot be read or parsed
-