本文整理汇总了Java中org.knime.core.node.workflow.FlowVariable类的典型用法代码示例。如果您正苦于以下问题:Java FlowVariable类的具体用法?Java FlowVariable怎么用?Java FlowVariable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlowVariable类属于org.knime.core.node.workflow包,在下文中一共展示了FlowVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateData
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Update the settings and input spec.
* @param settings the settings
* @param spec the input spec
* @param flowVars the available flow variables
*/
public void updateData(final JavaSnippetSettings settings,
final DataTableSpec spec,
final Map<String, FlowVariable> flowVars) {
m_inListenerArmed = false;
m_outListenerArmed = false;
m_inFieldsTable.updateData(settings.getJavaSnippetFields(),
spec, flowVars);
m_outFieldsTable.updateData(settings.getJavaSnippetFields(),
spec, flowVars);
// update snippet.
m_snippet.setJavaSnippetFields(new JavaSnippetFields(
m_inFieldsTable.getInColFields(),
m_inFieldsTable.getInVarFields(),
m_outFieldsTable.getOutColFields(),
m_outFieldsTable.getOutVarFields()));
m_inListenerArmed = true;
m_outListenerArmed = true;
}
示例2: getAllowedJavaTypes
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@SuppressWarnings("rawtypes")
@Override
public Class[] getAllowedJavaTypes(final int row) {
Object input = getValueAt(row, Column.COLUMN);
if (input instanceof DataColumnSpec) {
DataColumnSpec colSpec = (DataColumnSpec)input;
DataType elemType = colSpec.getType().isCollectionType()
? colSpec.getType().getCollectionElementType()
: colSpec.getType();
DataValueToJava dvToJava =
TypeProvider.getDefault().getDataValueToJava(elemType,
colSpec.getType().isCollectionType());
return dvToJava.canProvideJavaTypes();
} else if (input instanceof FlowVariable) {
FlowVariable flowVar = (FlowVariable)input;
TypeConverter typeConversion =
TypeProvider.getDefault().getTypeConverter(
flowVar.getType());
return typeConversion.canProvideJavaTypes();
} else {
return new Class[0];
}
}
示例3: addRow
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Adds a row for the given flow variable.
*
* @param var the flow variable definition
* @return true when the row was added successfully
*/
public boolean addRow(final FlowVariable var) {
int r = m_model.getRowCount();
m_model.addRow();
m_model.setValueAt(var, r, Column.COLUMN);
String varName = var.getName();
Set<String> taken = new HashSet<String>();
for (int i = 0; i < m_model.getRowCount(); i++) {
taken.add((String)m_model.getValueAt(i, Column.JAVA_FIELD));
}
String fieldName = FieldsTableUtil.createUniqueJavaIdentifier(
varName, taken, "v_");
m_model.setValueAt(fieldName, r, Column.JAVA_FIELD);
Class javaType = TypeProvider.getDefault()
.getTypeConverter(var.getType()).getPreferredJavaType();
m_model.setValueAt(javaType, r, Column.JAVA_TYPE);
return true;
}
示例4: createInputCellEditor
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/** Create cell editor for for the input columns / flow variables. */
private TableCellEditor createInputCellEditor() {
JComboBox comboBox = new JComboBox();
comboBox.setRenderer(new InputListCellRenderer());
if (null != m_spec) {
for (DataColumnSpec colSpec : m_spec) {
comboBox.addItem(colSpec);
}
}
if (null != m_flowVars) {
for (FlowVariable flowVar : m_flowVars.values()) {
comboBox.addItem(flowVar);
}
}
DefaultCellEditor editor = new DefaultCellEditor(comboBox);
editor.setClickCountToStart(2);
return editor;
}
示例5: getInVarFields
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Get the field definitions representing input flow variables.
*
* @return fields representing input flow variables
*/
public InVarList getInVarFields() {
InVarList inCols = new InVarList();
for (int r = 0; r < m_model.getRowCount(); r++) {
if (!m_model.validateValues(r)) {
// there are errors in this row
continue;
}
Object value = m_model.getValueAt(r, Column.COLUMN);
if (value instanceof FlowVariable) {
FlowVariable colSpec = (FlowVariable)value;
InVar inVar = new InVar();
inVar.setKnimeType(colSpec.getType());
inVar.setKnimeName(colSpec.getName());
inVar.setJavaName(
(String)m_model.getValueAt(r, Column.JAVA_FIELD));
inVar.setJavaType((Class)m_model.getValueAt(r,
Column.JAVA_TYPE));
inCols.add(inVar);
}
}
return inCols;
}
示例6: validateColDataType
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Validate knime type in the given row.
* @param row the row to check
* @return error message if error occurs
*/
private String validateColDataType(final int row) {
Object value = getValueAt(row, Column.DATA_TYPE);
if (null == value) {
return "Please select a value";
}
if (value instanceof Type) {
if (getFieldType(row).equals(FieldType.Column)) {
return "Please select a data type.";
}
} else if (value instanceof DataType) {
if (getFieldType(row).equals(FieldType.FlowVariable)) {
return "Please select a flow variable type.";
}
} else if (value instanceof String) {
return "Please select a valid type.";
}
// no errors found
return null;
}
示例7: addRow
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Adds a row using the values of the given output variable.
*
* @param outVar the output variable definition
* @return true when the row was added successfully
*/
public boolean addRow(final OutVar outVar) {
int r = m_model.getRowCount();
m_model.addRow();
m_model.setValueAt(outVar.getReplaceExisting(),
r, Column.REPLACE_EXISTING);
if (!m_flowVarsOnly) {
m_model.setValueAt(FieldType.FlowVariable, r,
Column.FIELD_TYPE);
}
String name = outVar.getKnimeName();
FlowVariable flowVar = m_flowVars.get(name);
Object value = null != flowVar ? flowVar : name;
m_model.setValueAt(value, r, Column.COLUMN);
m_model.setValueAt(outVar.getKnimeType(), r, Column.DATA_TYPE);
if (!m_flowVarsOnly) {
m_model.setValueAt(false, r, Column.IS_COLLECTION);
}
m_model.setValueAt(outVar.getJavaName(), r, Column.JAVA_FIELD);
m_model.setValueAt(outVar.getJavaType(), r, Column.JAVA_TYPE);
return true;
}
示例8: setFlowVariables
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Set the flow variables to display.
* @param flowVars the flow variables.
*/
public void setFlowVariables(final Collection<FlowVariable> flowVars) {
Collection<FlowVariable> sortedFlowVars = new TreeSet<FlowVariable>(new Comparator<FlowVariable>() {
@Override
public int compare(final FlowVariable o1, final FlowVariable o2) {
return o1.getName().compareTo(o2.getName());
}
});
sortedFlowVars.addAll(flowVars);
DefaultListModel fvListModel =
(DefaultListModel)getModel();
fvListModel.removeAllElements();
for (FlowVariable v : sortedFlowVars) {
fvListModel.addElement(v);
}
}
示例9: FlowVariableRepository
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Create a new repository.
* @param input the flow variables from the input stack.
*/
public FlowVariableRepository(final Map<String, FlowVariable> input) {
super();
m_input = input;
m_modified = new LinkedHashMap<String, FlowVariable>();
m_flowVarNames = new LinkedHashSet<String>();
m_flowVarNames.addAll(input.keySet());
}
示例10: getValueOfType
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* 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);
}
示例11: isOfType
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* 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);
}
示例12: put
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Add a new or updated flow variable.
* @param flowVar the flow variable associated with name
*/
public void put(final FlowVariable flowVar) {
m_modified.put(flowVar.getName(), flowVar);
// re-add element since natural ordering of flow variables is a stack
m_flowVarNames.remove(flowVar.getName());
m_flowVarNames.add(flowVar.getName());
}
示例13: validateJavaTypeColumn
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Validate java type in the given row.
* @param row the row to check
* @return error message if error occurs
*/
@SuppressWarnings("rawtypes")
private String validateJavaTypeColumn(final int row) {
Object value = this.getValueAt(row, Column.JAVA_TYPE);
if (null == value) {
return "Please select a value";
}
if (!(value instanceof Class)) {
return "Cannot find class " + value.toString();
}
Class javaType = (Class)value;
Object input = this.getValueAt(row, Column.COLUMN);
if (input instanceof DataColumnSpec) {
DataColumnSpec colSpec = (DataColumnSpec)input;
DataType elemType = colSpec.getType().isCollectionType()
? colSpec.getType().getCollectionElementType()
: colSpec.getType();
DataValueToJava dvToJava =
TypeProvider.getDefault().getDataValueToJava(elemType,
colSpec.getType().isCollectionType());
return dvToJava.canProvideJavaType(javaType) ? null
: "The java type \"" + javaType.getSimpleName()
+ "\" is not supported.";
} else if (input instanceof FlowVariable) {
FlowVariable flowVar = (FlowVariable)input;
TypeConverter typeConversion =
TypeProvider.getDefault().getTypeConverter(
flowVar.getType());
return typeConversion.canProvideJavaType(javaType) ? null
: "The java type \"" + javaType.getSimpleName()
+ "\" is not supported.";
} else {
return null;
}
}
示例14: getFieldType
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Returns the field type for the given column.
*
* @param row the row to check
* @return the field type of the given column
*/
private FieldType getFieldType(final int row) {
if (m_flowVarsOnly) {
return FieldType.FlowVariable;
} else {
return (FieldType)getValueAt(row, Column.FIELD_TYPE);
}
}
示例15: validateColFieldType
import org.knime.core.node.workflow.FlowVariable; //导入依赖的package包/类
/**
* Validate field type in the given row.
* @param row the row to check
* @return error message if error occurs
*/
private String validateColFieldType(final int row) {
Object value = getFieldType(row);
if (null == value) {
return "Please select a value.";
}
return value.equals(FieldType.Column)
|| value.equals(FieldType.FlowVariable) ? null
: "No valid field type: " + value.toString();
}