use of org.knime.base.node.jsnippet.expression.FlowVariableException in project knime-core by knime.
the class FlowVariableRepository method getValueOfType.
/**
* Get value of a flow variable. The type of the returned object is equal
* to the given className.
* @param name the name of the flow variable
* @param className the type of the returned object
* @return the value of the flow variable
*/
@SuppressWarnings("rawtypes")
public Object getValueOfType(final String name, final Class className) {
FlowVariable flowVar = getFlowVariable(name);
if (null == flowVar) {
throw new FlowVariableException("The flow variable with name \"" + name + "\" does not exist.");
}
TypeConverter converter = TypeProvider.getDefault().getTypeConverter(flowVar.getType());
return converter.getValue(flowVar, className);
}
use of org.knime.base.node.jsnippet.expression.FlowVariableException in project knime-core by knime.
the class FlowVariableRepository method isOfType.
/**
* Returns true when getValueOfType(String, Class) does not throw
* an TypeException when called with the given flow variable and the given
* class name.
* @param name the name of the flow variable
* @param className the type
* @return true when flow variable is of type.
*/
@SuppressWarnings("rawtypes")
public boolean isOfType(final String name, final Class className) {
FlowVariable flowVar = getFlowVariable(name);
if (null == flowVar) {
throw new FlowVariableException("The flow variable with name \"" + name + "\" does not exist.");
}
TypeConverter converter = TypeProvider.getDefault().getTypeConverter(flowVar.getType());
return converter.canProvideJavaType(className);
}
Aggregations