当前位置: 首页>>代码示例>>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;未经允许,请勿转载。