private String[] declaredTypeQuantities;
private String[] declaredTypeUnits;
- private TObjectIntHashMap<String> variableMap = new TObjectIntHashMap<String>();
+ private static int NO_VARIABLE_KEY = -1;
+
+ private TObjectIntHashMap<String> variableMap = new TObjectIntHashMap<String>(10, 0.5f, NO_VARIABLE_KEY);
private Set<String> subscriptionSet = new HashSet<String>();
private TIntArrayList subscription = new TIntArrayList();
synchronized(syncObject) {
// Safety check
int vr = variableMap.get(name);
- if(vr == 0) return false;
+ if(vr == NO_VARIABLE_KEY) return false;
if(!subscriptionSet.add(name)) return false;
subscribedNames.add(name);
subscription.add(vr);
* @throws FMILException
*/
public void setRealValue(String name, double value) throws FMILException {
- setRealValue(variableMap.get(name), value);
+ int key = variableMap.get(name);
+ if(key == NO_VARIABLE_KEY)
+ throw new FMILException("No variable with name " + name);
+ setRealValue(key, value);
}
/**
* @throws FMILException
*/
public void setIntegerValue(String name, int value) throws FMILException {
- setIntegerValue(variableMap.get(name), value);
+ int key = variableMap.get(name);
+ if(key == NO_VARIABLE_KEY)
+ throw new FMILException("No variable with name " + name);
+ setIntegerValue(key, value);
}
/**
* @throws FMILException
*/
public void setBooleanValue(String name, boolean value) throws FMILException {
- setBooleanValue(variableMap.get(name), value);
+ int key = variableMap.get(name);
+ if(key == NO_VARIABLE_KEY)
+ throw new FMILException("No variable with name " + name);
+ setBooleanValue(key, value);
}
/**
* @throws FMILException
*/
public void setStringValue(String name, String value) throws FMILException {
- setStringValue(variableMap.get(name), value);
+ int key = variableMap.get(name);
+ if(key == NO_VARIABLE_KEY)
+ throw new FMILException("No variable with name " + name);
+ setStringValue(key, value);
}
/**
* @throws FMILException
*/
public double getRealValue(String name) throws FMILException {
- double result = getRealValue(variableMap.get(name));
+ int key = variableMap.get(name);
+ if(key == NO_VARIABLE_KEY)
+ throw new FMILException("No variable with name " + name);
+ double result = getRealValue(key);
if (DEBUG) System.err.println("getRealValue " + name + " = " + result);
return result;
}
* @throws FMILException
*/
public int getIntegerValue(String name) throws FMILException {
- int result = getIntegerValue(variableMap.get(name));
+ int key = variableMap.get(name);
+ if(key == NO_VARIABLE_KEY)
+ throw new FMILException("No variable with name " + name);
+ int result = getIntegerValue(key);
if (DEBUG) System.err.println("getIntegerValue " + name + " = " + result);
return result;
}
* @throws FMILException
*/
public boolean getBooleanValue(String name) throws FMILException {
- boolean result = getBooleanValue(variableMap.get(name));
+ int key = variableMap.get(name);
+ if(key == NO_VARIABLE_KEY)
+ throw new FMILException("No variable with name " + name);
+ boolean result = getBooleanValue(key);
if (DEBUG) System.err.println("getBooleanValue " + name + " = " + result);
return result;
}
* @throws FMILException
*/
public String getStringValue(String name) throws FMILException {
- String result = getStringValue(variableMap.get(name));
+ int key = variableMap.get(name);
+ if(key == NO_VARIABLE_KEY)
+ throw new FMILException("No variable with name " + name);
+ String result = getStringValue(key);
if (DEBUG) System.err.println("getIntegerValue " + name + " = " + result);
return result;
}