Exemplo n.º 1
0
  public static void addStringValue(StringMap.Builder inData, String inField, String inValue) {
    StringEntry.Builder strEntryBuilder = StringEntry.newBuilder();
    strEntryBuilder.setData(inValue);
    strEntryBuilder.setField(inField);

    inData.addStringEntries(strEntryBuilder.build());
  }
Exemplo n.º 2
0
  /**
   * @param inKey
   * @return
   */
  public static DataKey createDataKey(ISTMEntryKey inKey) {
    DataKey.Builder dataKeyB = DataKey.newBuilder();
    dataKeyB.setType(inKey.getType());
    dataKeyB.setService(inKey.getService());

    for (String key : inKey.getKeys()) {
      String val = inKey.getValue(key);

      StringEntry.Builder entryB = StringEntry.newBuilder();
      entryB.setField(key);
      entryB.setData(val);

      dataKeyB.addStringEntries(entryB.build());
    }

    return dataKeyB.build();
  }
Exemplo n.º 3
0
  /**
   * @param inKey
   * @param inData
   * @param inBuilder
   */
  public static void parseValueToMap(String inKey, DataType<?> inData, DataMap.Builder inBuilder) {
    if (inData instanceof DataTypeString) {
      StringEntry.Builder strBuilder = StringEntry.newBuilder();
      strBuilder.setField(inKey);
      strBuilder.setData(((DataTypeString) inData).get());
      inBuilder.addStringEntries(strBuilder.build());
    } else if (inData instanceof DataTypeBigDecimal) {
      DataTypeBigDecimal bd = (DataTypeBigDecimal) inData;
      BigDecimalEntry.Builder bdBuilder = BigDecimalEntry.newBuilder();
      bdBuilder.setField(inKey);
      bdBuilder.setScale(bd.get().scale());
      bdBuilder.setIntBytes(ByteString.copyFrom(bd.get().unscaledValue().toByteArray()));
      inBuilder.addBDEntries(bdBuilder.build());
    }
    if (inData instanceof DataTypeLong) {
      LongEntry.Builder longBuilder = LongEntry.newBuilder();
      longBuilder.setField(inKey);
      longBuilder.setData(((DataTypeLong) inData).get());
      inBuilder.addLongEntries(longBuilder.build());
    }
    if (inData instanceof DataTypeBoolean) {
      BooleanEntry.Builder booleanBuilder = BooleanEntry.newBuilder();
      booleanBuilder.setField(inKey);
      booleanBuilder.setData(((DataTypeBoolean) inData).get());
      inBuilder.addBoolEntries(booleanBuilder.build());
    }
    if (inData instanceof DataTypeNull) {
      NullEntry.Builder nullBuilder = NullEntry.newBuilder();
      nullBuilder.setField(inKey);
      inBuilder.addNullEntries(nullBuilder.build());
    }
    if (inData instanceof DataTypeHashMap) {
      HashMapEntry.Builder dataMapBuilder = HashMapEntry.newBuilder();
      dataMapBuilder.setField(inKey);

      DataTypeHashMap hashMap = (DataTypeHashMap) inData;
      DataMap.Builder hashMapBuilder = DataMap.newBuilder();

      parseMapValues(hashMap.get(), hashMapBuilder);

      dataMapBuilder.setData(hashMapBuilder.build());

      inBuilder.addHashMapEntries(dataMapBuilder.build());
    }
    if (inData instanceof DataTypeArrayList) {
      HashMapEntry.Builder dataMapBuilder = HashMapEntry.newBuilder();
      dataMapBuilder.setField(inKey);
      dataMapBuilder.setList(true);

      DataTypeArrayList list = (DataTypeArrayList) inData;
      DataMap.Builder hashMapBuilder = DataMap.newBuilder();

      parseListValues((PersistentArrayList<DataType<?>>) list.get(), hashMapBuilder);

      dataMapBuilder.setData(hashMapBuilder.build());

      inBuilder.addHashMapEntries(dataMapBuilder.build());
    } else if (inData instanceof DataTypeStatus) {
      inBuilder.setStatus(((DataTypeStatus) inData).get().ordinal());
    } else if (inData instanceof DataTypeRef) {
      ISTMEntryKey entryKey = ((DataTypeRef) inData).get();
      parseReference(inKey, entryKey, inBuilder, false);
    } else if (inData instanceof DataTypeLazyRef) {
      ISTMEntryKey entryKey = ((DataTypeLazyRef) inData).get();
      parseReference(inKey, entryKey, inBuilder, true);
    }
  }