@Override public Object apply(List<Object> args, Context context) throws ParseException { Map<String, StellarExecutor.VariableResult> variables = (Map<String, StellarExecutor.VariableResult>) context.getCapability(StellarExecutor.SHELL_VARIABLES).get(); if (args.size() == 0) { return null; } String variable = (String) args.get(0); if (variable == null) { return null; } StellarExecutor.VariableResult result = variables.get(variable); if (result != null && result.getExpression() != null) { return result.getExpression(); } return null; }
@Override public Object apply(List<Object> args, Context context) throws ParseException { Map<String, StellarExecutor.VariableResult> variables = (Map<String, StellarExecutor.VariableResult>) context.getCapability(StellarExecutor.SHELL_VARIABLES).get(); LinkedHashMap<String, String> ret = new LinkedHashMap<>(); for (Object arg : args) { if (arg == null) { continue; } String variable = (String) arg; StellarExecutor.VariableResult result = variables.get(variable); if (result != null && result.getExpression() != null) { ret.put(variable, result.getExpression()); } } return ret; }
@Override public Object apply(List<Object> args, Context context) throws ParseException { Map<String, StellarExecutor.VariableResult> variables = (Map<String, StellarExecutor.VariableResult>) context.getCapability(StellarExecutor.SHELL_VARIABLES).get(); String[] headers = {"VARIABLE", "VALUE", "EXPRESSION"}; String[][] data = new String[variables.size()][3]; int wordWrap = -1; if (args.size() > 0) { wordWrap = ConversionUtils.convert(args.get(0), Integer.class); } int i = 0; for (Map.Entry<String, StellarExecutor.VariableResult> kv : variables.entrySet()) { StellarExecutor.VariableResult result = kv.getValue(); data[i++] = new String[] { toWrappedString(kv.getKey().toString(), wordWrap), toWrappedString(result.getResult(), wordWrap), toWrappedString(result.getExpression(), wordWrap) }; } return FlipTable.of(headers, data); }