本文整理汇总了Java中org.iotp.infomgt.data.kv.LongDataEntry类的典型用法代码示例。如果您正苦于以下问题:Java LongDataEntry类的具体用法?Java LongDataEntry怎么用?Java LongDataEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LongDataEntry类属于org.iotp.infomgt.data.kv包,在下文中一共展示了LongDataEntry类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKvEntries
import org.iotp.infomgt.data.kv.LongDataEntry; //导入依赖的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;
}
示例2: parseValues
import org.iotp.infomgt.data.kv.LongDataEntry; //导入依赖的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;
}
示例3: getKvEntries
import org.iotp.infomgt.data.kv.LongDataEntry; //导入依赖的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;
}
示例4: getKvEntries
import org.iotp.infomgt.data.kv.LongDataEntry; //导入依赖的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;
}
示例5: getKvEntry
import org.iotp.infomgt.data.kv.LongDataEntry; //导入依赖的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() + "]");
}
示例6: getKvEntries
import org.iotp.infomgt.data.kv.LongDataEntry; //导入依赖的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;
}