예제 #1
0
 public boolean updateBundleWithListAppend(Bundle bundle) {
   for (FieldValue fv : list) {
     ValueObject oldValue = bundle.getValue(fv.field);
     ValueArray newValue;
     if (oldValue == null) {
       newValue = ValueFactory.createArray(1);
     } else if (oldValue instanceof ValueArray) {
       newValue = (ValueArray) oldValue;
     } else {
       newValue = ValueFactory.createArray(2);
       newValue.add(oldValue);
     }
     newValue.add(fv.value);
     bundle.setValue(fv.field, newValue);
   }
   return !list.isEmpty();
 }
예제 #2
0
 public boolean updateBundleWithMapAppend(Bundle bundle) {
   for (FieldValue fv : list) {
     ValueObject oldValue = bundle.getValue(fv.field);
     ValueMap newValue;
     if (oldValue == null) {
       newValue = ValueFactory.createMap();
     } else if (oldValue instanceof ValueMap) {
       newValue = (ValueMap) oldValue;
     } else {
       newValue = ValueFactory.createMap();
       newValue.put(oldValue.asString().asNative(), oldValue);
     }
     newValue.put(fv.value.asString().asNative(), fv.value);
     bundle.setValue(fv.field, newValue);
   }
   return !list.isEmpty();
 }
예제 #3
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();
   }
 }
예제 #4
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;
 }
예제 #5
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;
    }
  }