Class FWSimCache
java.lang.Object
net.simplace.sim.io.FWSimCache
- All Implemented Interfaces:
FWSimFieldContainer
- Direct Known Subclasses:
FWSimResourceCache, FWSimResultCache, FWSimulationControlCache
Base class of the in-memory data caches. For fast access each data line is stored as
Object[] (one
value per header variable) under its key. See the two subclasses FWSimResourceCache (data read from
resources) and FWSimResultCache (output data kept in memory).- Author:
- Andreas Enders
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleantrueif a header variable is an arraythe data lines by key, in insertion orderprotected intnumber of header variables (values per line)protected FWSimIOAdapter.FREQUENCEfrequency of the adapter the cache belongs toprotected LinkedHashMap<String, FWSimVariable<?>> header variables (columns) by full name, in column orderprotected Stringname of the cache (the name of its adapter)protected intorder number of the adapter the cache belongs tocolumn index by field name -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFWSimCache(int aFieldcount, String aName, HashMap<Object, Object[]> aCache, boolean aArrayMode, LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables, FWSimIOAdapter.FREQUENCE aFrequence, int aOrderNumber, HashMap<String, Integer> aVariableIndex) Creates a cache from existing parts (used for copies); nothing is copied.FWSimCache(LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables, FWSimIOAdapter.FREQUENCE aFrequence, String aName, int aOrderNumber) Creates an empty cache for the given header variables and determines the column indices and the array mode. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddVariable(FWSimVariable<?> aVariable) Adds a header variable as new last column.voidcheckCondition(Boolean aCheckResult, String aMessage) Passes the check to the checker of the session.HashMap<String, FWSimVariable<?>> Returns a new map with the header variables.getCache()Returnsres.intReturns the header variables (the live map).Returns the frequency of the adapter.Returns an empty list; caches have no input variables.getName()intReturns the order number of the adapter.Returns the header variables.getVariable(String aID) Returns a header variable, ornullif unknown.getVariableIndex(String aFieldName) HashMap<String, FWSimVariable<?>> booleanbooleanAsks the checker of the session.voidremoveVariable(String aID) Removes a header variable.voidsetCacheMap(HashMap<Object, Object[]> aNewFieldMap) Replaces all data lines.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface FWSimFieldContainer
getCreateFormXML, getEditFormXML, getVarMap, toXML
-
Field Details
-
iFieldcount
protected int iFieldcountnumber of header variables (values per line) -
iName
name of the cache (the name of its adapter) -
iCache
-
iArrayMode
protected boolean iArrayModetrueif a header variable is an array -
iHeaderVariables
header variables (columns) by full name, in column order -
iVariablesIndexes
-
iFrequence
frequency of the adapter the cache belongs to -
iOrderNumber
protected int iOrderNumberorder number of the adapter the cache belongs to
-
-
Constructor Details
-
FWSimCache
public FWSimCache(LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables, FWSimIOAdapter.FREQUENCE aFrequence, String aName, int aOrderNumber) Creates an empty cache for the given header variables and determines the column indices and the array mode.- Parameters:
aHeaderVariables- the header variables (used directly, not copied)aFrequence- frequency of the adapteraName- name of the cacheaOrderNumber- order number of the adapter
-
FWSimCache
protected FWSimCache(int aFieldcount, String aName, HashMap<Object, Object[]> aCache, boolean aArrayMode, LinkedHashMap<String, FWSimVariable<?>> aHeaderVariables, FWSimIOAdapter.FREQUENCE aFrequence, int aOrderNumber, HashMap<String, Integer> aVariableIndex) Creates a cache from existing parts (used for copies); nothing is copied.- Parameters:
aFieldcount- number of header variablesaName- name of the cacheaCache- the data linesaArrayMode- if a header variable is an arrayaHeaderVariables- the header variablesaFrequence- frequency of the adapteraOrderNumber- order number of the adapteraVariableIndex- column index by field name
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceFWSimFieldContainer- Returns:
- the name of the cache
-
getFieldcount
public int getFieldcount()- Returns:
- the number of header variables (values per line)
-
isArrayMode
public boolean isArrayMode()- Returns:
trueif a header variable is an array
-
createVariables
Returns a new map with the header variables.- Specified by:
createVariablesin interfaceFWSimFieldContainer- Returns:
- the variables, keyed by name
- See Also:
-
getCache
-
addVariable
Adds a header variable as new last column. Use with care: the existing data lines are not adapted.- Specified by:
addVariablein interfaceFWSimFieldContainer- Parameters:
aVariable- the variable to add- See Also:
-
getVariable
Returns a header variable, ornullif unknown.- Specified by:
getVariablein interfaceFWSimFieldContainer- Parameters:
aID- id of the variable- Returns:
- the variable
- See Also:
-
getVariables
- Returns:
- the header variables (the live map)
-
removeVariable
Removes a header variable. Use with care: the data lines and column indices are not adapted.- Specified by:
removeVariablein interfaceFWSimFieldContainer- Parameters:
aID- id of the variable- See Also:
-
getOutputVariables
Returns the header variables.- Specified by:
getOutputVariablesin interfaceFWSimFieldContainer- Returns:
- the output variables of the field map
- See Also:
-
getOrderNumber
public int getOrderNumber()Returns the order number of the adapter.- Specified by:
getOrderNumberin interfaceFWSimFieldContainer- Returns:
- position of this container in the order of execution
- See Also:
-
getInputVariables
Returns an empty list; caches have no input variables.- Specified by:
getInputVariablesin interfaceFWSimFieldContainer- Returns:
- the input variables of the field map
- See Also:
-
getFieldMap
Returns the header variables (the live map).- Specified by:
getFieldMapin interfaceFWSimFieldContainer- Returns:
- the whole field map as created in
FWSimFieldContainer.createVariables() - See Also:
-
setCacheMap
-
getContentType
Returnsres.- Specified by:
getContentTypein interfaceFWSimFieldContainer- Returns:
- the content type of the variables of this container (e.g.
sys,mgm) - See Also:
-
getFrequence
Returns the frequency of the adapter.- Specified by:
getFrequencein interfaceFWSimFieldContainer- Returns:
- the frequency in which this container is called, or
nullif not applicable - See Also:
-
getVariableIndex
-
checkCondition
Passes the check to the checker of the session.- Specified by:
checkConditionin interfaceFWSimFieldContainer- Parameters:
aCheckResult- result of the check;falsemeans the condition is violatedaMessage- message describing the condition- See Also:
-
isConditionCheck
public boolean isConditionCheck()Asks the checker of the session.- Specified by:
isConditionCheckin interfaceFWSimFieldContainer- Returns:
trueif conditions are checked with the current check level of the session- See Also:
-