Exemplo n.º 1
0
 public OpMap(String args) {
   try {
     String opt[] = args.split("::");
     if (opt.length >= 2) {
       col = Integer.parseInt(opt[0]);
       map = new HashMap<>();
       JSONObject jo = new JSONObject(Bytes.urldecode(opt[1]));
       for (String key : jo.keySet()) {
         map.put(key, ValueFactory.create(jo.optString(key)));
       }
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
Exemplo n.º 2
0
 @Override
 public Bundle bundleize(Bundle next, String line) {
   List<String> row = tokens.tokenize(line);
   if (row == null) {
     return null;
   }
   int pos = 0;
   for (String col : row) {
     if (pos >= columns.length) {
       break;
     }
     ValueObject val = ValueFactory.create(col);
     if (tokenFilter != null) {
       val = tokenFilter.filter(val);
     }
     next.setValue(next.getFormat().getField(columns[pos++]), val);
   }
   return next;
 }
Exemplo n.º 3
0
  @Override
  public ValueObject filterValue(ValueObject value) {
    if (value == null) {
      return value;
    }
    try {
      ValueNumber num;
      if (!inDouble) {
        num = ValueUtil.asNumberOrParseLong(value, in);
      } else {
        num = ValueUtil.asNumberOrParseDouble(value);
      }

      if (outAsLong) {
        return num.asLong();
      } else {
        return ValueFactory.create(Long.toString(num.asLong().getLong(), out));
      }
    } catch (Exception ex) {
      log.warn("", ex);
      return value;
    }
  }