コード例 #1
0
 public static void jsonWriteVarContext(ObjectWriter writer, List<IntStringPair> context)
     throws IOException, JsonException {
   DataPointDao dataPointDao = new DataPointDao();
   JsonArray pointList = new JsonArray();
   for (IntStringPair p : context) {
     DataPointVO dp = dataPointDao.getDataPoint(p.getKey());
     if (dp != null) {
       JsonObject point = new JsonObject();
       pointList.add(point);
       point.put("varName", new JsonString(p.getValue()));
       point.put("dataPointXid", new JsonString(dp.getXid()));
     }
   }
   writer.writeEntry("context", pointList);
 }
コード例 #2
0
  public static String contextToString(List<IntStringPair> context) {
    DataPointDao dataPointDao = new DataPointDao();
    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (IntStringPair ivp : context) {
      DataPointVO dp = dataPointDao.getDataPoint(ivp.getKey());
      if (first) first = false;
      else sb.append(", ");

      if (dp == null) sb.append("?=");
      else sb.append(dp.getName()).append("=");
      sb.append(ivp.getValue());
    }
    return sb.toString();
  }