Commit 17b61ffe authored by Nico Mack's avatar Nico Mack

Minor API fixes

parent 764c0e36
......@@ -445,7 +445,12 @@ public class PythonExecutor extends Executor {
SpatialVariable spatial = (SpatialVariable) variable;
variable = this.depythonizeStructuredVariable(spatial, result);
} else {
variable.setValueFromObject(result.__tojava__(Double.class));
if (variable.getValue() != null) {
variable.setValueFromObject(result.__tojava__(variable.getContentClass().getClass()));
}
//
}
return variable;
}
......
......@@ -87,7 +87,7 @@ public class NumericalVariable extends Variable<Double> {
public NumericalVariable(String name, String unit, Double value) {
super(EquationSystemBundle.NUMERIC_TYPE, name, unit);
this.value = value;
this.value = (value != null) ? value : Double.valueOf(0);
format = new DecimalFormat();
format.setDecimalSeparatorAlwaysShown(false);
......
......@@ -55,7 +55,7 @@ public class TextVariable extends Variable<String> {
*/
public TextVariable(String name, String value) {
super(EquationSystemBundle.TEXT_TYPE, name, EquationSystemBundle.EMPTY_STRING);
this.value = value;
this.value = (value != null) ? value : EquationSystemBundle.EMPTY_STRING;
}
/**
......
......@@ -122,7 +122,7 @@ public abstract class Variable<V> implements Cloneable {
@SuppressWarnings("unchecked")
public V getContentClass() {
return (V) value.getClass();
return (V) ((value != null) ? value.getClass() : null);
}
/**
......
......@@ -56,6 +56,12 @@ public class HtmlTemplate implements VariableBased {
// ***************************************************************************
// ---------------------------------------------------------------------------
public String getTemplate() {
return this.template;
}
// ---------------------------------------------------------------------------
public boolean dependsOn(String identifier) {
return this.identifiers.contains(identifier);
}
......
......@@ -56,6 +56,20 @@ public class VariableHtmlBox extends HtmlBox implements VariableBased, InputChan
}
}
// ---------------------------------------------------------------------------
/**
* @param builder
*/
// ---------------------------------------------------------------------------
public VariableHtmlBox(VariableHtmlBox original) {
super(original);
htmlTemplate = new HtmlTemplate(original.htmlTemplate.getTemplate());
if (!htmlTemplate.dependsOnVariables()) {
this.setInformation(original.htmlTemplate.getTemplate());
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitive(s)
......@@ -96,6 +110,13 @@ public class VariableHtmlBox extends HtmlBox implements VariableBased, InputChan
return htmlTemplate.getDeclaredVariables();
}
// ---------------------------------------------------------------------------
@Override
public VariableHtmlBox clone() {
return new VariableHtmlBox(this);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment