コード例 #1
0
 @Override
 public Object apply(List<Object> args) {
   if (args.size() < 1) {
     return null;
   }
   Map<Object, Object> map = (Map<Object, Object>) args.get(0);
   if (map == null) {
     map = new HashMap<>();
   }
   String[] headers = {"KEY", "VALUE"};
   String[][] data = new String[map.size()][2];
   int i = 0;
   for (Map.Entry<Object, Object> kv : map.entrySet()) {
     data[i++] = new String[] {kv.getKey().toString(), kv.getValue().toString()};
   }
   return FlipTable.of(headers, data);
 }
コード例 #2
0
    @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);
    }