當前位置: 首頁>>代碼示例>>Java>>正文


Java DoubleDataEntry類代碼示例

本文整理匯總了Java中org.iotp.infomgt.data.kv.DoubleDataEntry的典型用法代碼示例。如果您正苦於以下問題:Java DoubleDataEntry類的具體用法?Java DoubleDataEntry怎麽用?Java DoubleDataEntry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DoubleDataEntry類屬於org.iotp.infomgt.data.kv包,在下文中一共展示了DoubleDataEntry類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getKvEntries

import org.iotp.infomgt.data.kv.DoubleDataEntry; //導入依賴的package包/類
private List<KvEntry> getKvEntries(DocumentContext document, List<? extends KVMapping> mappings) {
    List<KvEntry> result = new ArrayList<>();
    if (mappings != null) {
        for (KVMapping mapping : mappings) {
            String key = eval(document, mapping.getKey());
            String strVal = eval(document, mapping.getValue());
            switch (mapping.getType().getDataType()) {
                case STRING:
                    result.add(new StringDataEntry(key, strVal));
                    break;
                case BOOLEAN:
                    result.add(new BooleanDataEntry(key, Boolean.valueOf(strVal)));
                    break;
                case DOUBLE:
                    result.add(new DoubleDataEntry(key, Double.valueOf(strVal)));
                    break;
                case LONG:
                    result.add(new LongDataEntry(key, Long.valueOf(strVal)));
                    break;
            }
        }
    }
    return result;
}
 
開發者ID:osswangxining,項目名稱:iot-edge-greengrass,代碼行數:25,代碼來源:MqttJsonConverter.java

示例2: parseValues

import org.iotp.infomgt.data.kv.DoubleDataEntry; //導入依賴的package包/類
public static List<KvEntry> parseValues(JsonObject valuesObject) {
  List<KvEntry> result = new ArrayList<>();
  for (Entry<String, JsonElement> valueEntry : valuesObject.entrySet()) {
    JsonElement element = valueEntry.getValue();
    if (element.isJsonPrimitive()) {
      JsonPrimitive value = element.getAsJsonPrimitive();
      if (value.isString()) {
        result.add(new StringDataEntry(valueEntry.getKey(), value.getAsString()));
      } else if (value.isBoolean()) {
        result.add(new BooleanDataEntry(valueEntry.getKey(), value.getAsBoolean()));
      } else if (value.isNumber()) {
        if (value.getAsString().contains(".")) {
          result.add(new DoubleDataEntry(valueEntry.getKey(), value.getAsDouble()));
        } else {
          result.add(new LongDataEntry(valueEntry.getKey(), value.getAsLong()));
        }
      } else {
        throw new JsonSyntaxException("Can't parse value: " + value);
      }
    } else {
      throw new JsonSyntaxException("Can't parse value: " + element);
    }
  }
  return result;
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:26,代碼來源:JsonConverter.java

示例3: getKvEntries

import org.iotp.infomgt.data.kv.DoubleDataEntry; //導入依賴的package包/類
public static List<KvEntry> getKvEntries(JsonNode data) {
  List<KvEntry> attributes = new ArrayList<>();
  for (Iterator<Map.Entry<String, JsonNode>> it = data.fields(); it.hasNext();) {
    Map.Entry<String, JsonNode> field = it.next();
    String key = field.getKey();
    JsonNode value = field.getValue();
    if (value.isBoolean()) {
      attributes.add(new BooleanDataEntry(key, value.asBoolean()));
    } else if (value.isLong()) {
      attributes.add(new LongDataEntry(key, value.asLong()));
    } else if (value.isDouble()) {
      attributes.add(new DoubleDataEntry(key, value.asDouble()));
    } else {
      attributes.add(new StringDataEntry(key, value.asText()));
    }
  }
  return attributes;
}
 
開發者ID:osswangxining,項目名稱:iot-edge-greengrass,代碼行數:19,代碼來源:JsonTools.java

示例4: getKvEntries

import org.iotp.infomgt.data.kv.DoubleDataEntry; //導入依賴的package包/類
private List<KvEntry> getKvEntries(List<? extends KVMapping> mappings) {
    List<KvEntry> result = new ArrayList<>();
    for (KVMapping mapping : mappings) {
        String strVal = mapping.getValue();
        for (Map.Entry<String, String> tagKV : tagValues.entrySet()) {
            strVal = strVal.replace(escape(tagKV.getKey()), tagKV.getValue());
        }
        switch (mapping.getType().getDataType()) {
            case STRING:
                result.add(new StringDataEntry(mapping.getKey(), strVal));
                break;
            case BOOLEAN:
                result.add(new BooleanDataEntry(mapping.getKey(), Boolean.valueOf(strVal)));
                break;
            case DOUBLE:
                result.add(new DoubleDataEntry(mapping.getKey(), Double.valueOf(strVal)));
                break;
            case LONG:
                result.add(new LongDataEntry(mapping.getKey(), Long.valueOf(strVal)));
                break;
        }
    }
    return result;
}
 
開發者ID:osswangxining,項目名稱:iot-edge-greengrass,代碼行數:25,代碼來源:OpcUaDevice.java

示例5: getKvEntry

import org.iotp.infomgt.data.kv.DoubleDataEntry; //導入依賴的package包/類
private BasicKvEntry getKvEntry(TransformerKVMapping mapping, String key, String strVal, DataValueTransformer transformer) {
    try {
        switch (mapping.getType().getDataType()) {
            case STRING:
                return new StringDataEntry(key, transformer.transformToString(strVal));
            case BOOLEAN:
                return new BooleanDataEntry(key, transformer.transformToBoolean(strVal));
            case DOUBLE:
                return new DoubleDataEntry(key, transformer.transformToDouble(strVal));
            case LONG:
                return new LongDataEntry(key, transformer.transformToLong(strVal));
        }
    } catch (Exception e) {
        log.error("Transformer [{}] can't be applied to field with key [{}] and value [{}]",
                transformer.getClass().getSimpleName(), key, strVal);
        throw e;
    }
    log.error("No mapping found for data type [{}]", mapping.getType().getDataType());
    throw new IllegalArgumentException("No mapping found for data type [" + mapping.getType().getDataType() + "]");
}
 
開發者ID:osswangxining,項目名稱:iot-edge-greengrass,代碼行數:21,代碼來源:BasicJsonConverter.java

示例6: getKvEntries

import org.iotp.infomgt.data.kv.DoubleDataEntry; //導入依賴的package包/類
private List<KvEntry> getKvEntries(DocumentContext document, List<? extends KVMapping> mappings) {
  List<KvEntry> result = new ArrayList<>();
  if (mappings != null) {
    for (KVMapping mapping : mappings) {
      String key = eval(document, mapping.getKey());
      String strVal = eval(document, mapping.getValue());
      switch (mapping.getType().getDataType()) {
      case STRING:
        result.add(new StringDataEntry(key, strVal));
        break;
      case BOOLEAN:
        result.add(new BooleanDataEntry(key, Boolean.valueOf(strVal)));
        break;
      case DOUBLE:
        result.add(new DoubleDataEntry(key, Double.valueOf(strVal)));
        break;
      case LONG:
        result.add(new LongDataEntry(key, Long.valueOf(strVal)));
        break;
      }
    }
  }
  return result;
}
 
開發者ID:osswangxining,項目名稱:iotgateway,代碼行數:25,代碼來源:MqttJsonConverter.java


注:本文中的org.iotp.infomgt.data.kv.DoubleDataEntry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。