use of org.diirt.vtype.VString in project yamcs-studio by yamcs.
the class ConcatStringsFunction method calculate.
@Override
public Object calculate(List<Object> args) {
// Handle nulls
if (NullUtils.containsNull(args)) {
return null;
}
// Concatenate strings
StringBuilder sb = new StringBuilder();
for (Object object : args) {
VString str = (VString) object;
sb.append(str.getValue());
}
// Return new value
return ValueFactory.newVString(sb.toString(), highestSeverityOf(args, false), latestValidTimeOrNowOf(args));
}
use of org.diirt.vtype.VString in project yamcs-studio by yamcs.
the class ColumnFromVNumberArrayFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
VString name = (VString) args.get(0);
VNumberArray data = (VNumberArray) args.get(1);
if (name == null || data == null) {
return null;
}
return VTableFactory.column(name.getValue(), data);
}
use of org.diirt.vtype.VString in project yamcs-studio by yamcs.
the class ColumnOfVTableFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
VTable table = (VTable) args.get(0);
VString columnName = (VString) args.get(1);
if (columnName == null || table == null) {
return null;
}
int index = -1;
for (int i = 0; i < table.getColumnCount(); i++) {
if (Objects.equals(columnName.getValue(), table.getColumnName(i))) {
index = i;
}
}
if (index == -1) {
throw new RuntimeException("Table does not contain column '" + columnName.getValue() + "'");
}
Class<?> type = table.getColumnType(index);
if (String.class.isAssignableFrom(type)) {
@SuppressWarnings("unchecked") List<String> data = (List<String>) table.getColumnData(index);
return ValueFactory.newVStringArray(data, ValueFactory.alarmNone(), ValueFactory.timeNow());
}
if (Double.TYPE.isAssignableFrom(type)) {
ListDouble data = (ListDouble) table.getColumnData(index);
return ValueFactory.newVDoubleArray(data, ValueFactory.alarmNone(), ValueFactory.timeNow(), ValueFactory.displayNone());
}
if (Integer.TYPE.isAssignableFrom(type)) {
ListInt data = (ListInt) table.getColumnData(index);
return ValueFactory.newVIntArray(data, ValueFactory.alarmNone(), ValueFactory.timeNow(), ValueFactory.displayNone());
}
throw new RuntimeException("Unsupported type " + type.getSimpleName());
}
use of org.diirt.vtype.VString in project yamcs-studio by yamcs.
the class TableRangeFilterFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
VTable table = (VTable) args.get(0);
VString columnName = (VString) args.get(1);
VType min = (VType) args.get(2);
VType max = (VType) args.get(3);
if (columnName == null || columnName.getValue() == null || table == null || min == null || max == null) {
return null;
}
VTable result = VTableFactory.tableRangeFilter(table, columnName.getValue(), min, max);
return result;
}
use of org.diirt.vtype.VString in project yamcs-studio by yamcs.
the class TableStringMatchFilterFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
VTable table = (VTable) args.get(0);
VString columnName = (VString) args.get(1);
VString substring = (VString) args.get(2);
if (columnName == null || columnName.getValue() == null || table == null || substring == null) {
return null;
}
VTable result = VTableFactory.tableStringMatchFilter(table, columnName.getValue(), substring.getValue());
return result;
}
Aggregations