本文整理汇总了Java中com.fasterxml.jackson.databind.node.LongNode类的典型用法代码示例。如果您正苦于以下问题:Java LongNode类的具体用法?Java LongNode怎么用?Java LongNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LongNode类属于com.fasterxml.jackson.databind.node包,在下文中一共展示了LongNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateMetricData
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
private ObjectNode updateMetricData(long nowMs, String hostName, ObjectNode testData) {
ObjectNode data;
data = testData.deepCopy(); // copy test data, modify it
ObjectNode attNode = (ObjectNode) data.path( "attributes" );
attNode.put( "hostName", hostName );
attNode.put( "currentTimeMillis", nowMs );
ArrayNode timeStamps = (ArrayNode) data.path( "data" ).path( "timeStamp" );
for (int i = 0; i < timeStamps.size(); i++) {
long offset = i * 30000; // timeStamps in reverse order LIFO. latest
// time is first
timeStamps.set( i, LongNode.valueOf( nowMs - offset ) );
}
return data;
}
示例2: get
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
public static JsonNode get( final PrimitiveObject obj ) throws IOException{
switch( obj.getPrimitiveType() ){
case BOOLEAN:
return BooleanNode.valueOf( obj.getBoolean() );
case BYTE:
return IntNode.valueOf( obj.getInt() );
case SHORT:
return IntNode.valueOf( obj.getInt() );
case INTEGER:
return IntNode.valueOf( obj.getInt() );
case LONG:
return new LongNode( obj.getLong() );
case FLOAT:
return new DoubleNode( obj.getDouble() );
case DOUBLE:
return new DoubleNode( obj.getDouble() );
case STRING:
return new TextNode( obj.getString() );
case BYTES:
return new BinaryNode( obj.getBytes() );
default:
return new TextNode( null );
}
}
示例3: activate
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
@Activate
public void activate() {
Serializer serializer = Serializer.using(KryoNamespaces.API,
ObjectNode.class, ArrayNode.class,
JsonNodeFactory.class, LinkedHashMap.class,
TextNode.class, BooleanNode.class,
LongNode.class, DoubleNode.class, ShortNode.class,
IntNode.class, NullNode.class);
prefsConsistentMap = storageService.<String, ObjectNode>consistentMapBuilder()
.withName(ONOS_USER_PREFERENCES)
.withSerializer(serializer)
.withRelaxedReadConsistency()
.build();
prefsConsistentMap.addListener(prefsListener);
prefs = prefsConsistentMap.asJavaMap();
register(core);
log.info("Started");
}
示例4: activate
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
@Activate
public void activate() {
KryoNamespace.Builder kryoBuilder = new KryoNamespace.Builder()
.register(KryoNamespaces.API)
.register(ConfigKey.class, ObjectNode.class, ArrayNode.class,
JsonNodeFactory.class, LinkedHashMap.class,
TextNode.class, BooleanNode.class,
LongNode.class, DoubleNode.class, ShortNode.class, IntNode.class,
NullNode.class);
configs = storageService.<ConfigKey, JsonNode>consistentMapBuilder()
.withSerializer(Serializer.using(kryoBuilder.build()))
.withName("onos-network-configs")
.withRelaxedReadConsistency()
.build();
configs.addListener(listener);
log.info("Started");
}
示例5: primitiveToJsonTest
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
@Test public void primitiveToJsonTest() {
assertEquals(BooleanNode.TRUE, Serializer.toJson(true, TypeNode.fromString("bool")));
assertEquals(BooleanNode.FALSE, Serializer.toJson(false, TypeNode.fromString("bool")));
assertEquals(TextNode.valueOf("a"),
Serializer.toJson('a', TypeNode.fromString("char")));
assertEquals(IntNode.valueOf(123), Serializer.toJson(123, TypeNode.fromString("int")));
assertEquals(LongNode.valueOf(123), Serializer.toJson(123L, TypeNode.fromString("long")));
assertEquals(DoubleNode.valueOf(123.0),
Serializer.toJson(123.0, TypeNode.fromString("double")));
assertEquals(TextNode.valueOf("123"),
Serializer.toJson("123", TypeNode.fromString("string")));
}
示例6: decodePointer
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
private Result decodePointer(int ctrlByte, int offset) {
int pointerSize = ((ctrlByte >>> 3) & 0x3) + 1;
int base = pointerSize == 4 ? (byte) 0 : (byte) (ctrlByte & 0x7);
int packed = this.decodeInteger(base, pointerSize);
long pointer = packed + this.pointerBase
+ this.pointerValueOffset[pointerSize];
if (Decoder.DEBUG) {
Log.debug("Pointer size", String.valueOf(pointerSize));
Log.debug("Packed pointer", String.valueOf(packed));
Log.debug("Pointer base", this.pointerBase);
Log.debug("Pointer value offset",
this.pointerValueOffset[pointerSize]);
Log.debug("Pointer to", String.valueOf(pointer));
}
return new Result(new LongNode(pointer), offset + pointerSize);
}
示例7: toValueNode
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
@Deprecated
public static ValueNode toValueNode(Object value) {
if (value == null)
return NullNode.instance;
if (value instanceof ValueNode)
return (ValueNode) value;
if (value instanceof Boolean)
return BooleanNode.valueOf((boolean) value);
else if (value instanceof Integer)
return IntNode.valueOf((int) value);
else if (value instanceof Long)
return LongNode.valueOf((long) value);
else if (value instanceof Double)
return DoubleNode.valueOf((double) value);
else if (value instanceof Float)
return FloatNode.valueOf((float) value);
return TextNode.valueOf(value.toString());
}
示例8: toValueNode
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
public static ValueNode toValueNode(Object value) {
if (value == null)
return NullNode.instance;
if (value instanceof ValueNode)
return (ValueNode) value;
if (value instanceof Boolean)
return BooleanNode.valueOf((boolean) value);
else if (value instanceof Integer)
return IntNode.valueOf((int) value);
else if (value instanceof Long)
return LongNode.valueOf((long) value);
else if (value instanceof Double)
return DoubleNode.valueOf((double) value);
else if (value instanceof Float)
return FloatNode.valueOf((float) value);
return TextNode.valueOf(value.toString());
}
示例9: getJobLaunchingData
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
private static JobLaunchingData getJobLaunchingData(final JsonNode payload, final JsonNode jobJsonNode) {
final String jobName = jobJsonNode.get("name").asText();
final JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
final JsonNode commercetools = payload.get("commercetools");
commercetools.fields().forEachRemaining(stringJsonNodeEntry -> {
jobParametersBuilder.addString("commercetools." + stringJsonNodeEntry.getKey(), stringJsonNodeEntry.getValue().asText());
});
jobJsonNode.fields().forEachRemaining(jobField -> {
//TODO prepare for other classes
if (jobField.getValue() instanceof TextNode) {
jobParametersBuilder.addString(jobField.getKey(), jobField.getValue().asText());
} else if (jobField.getValue() instanceof IntNode || jobField.getValue() instanceof LongNode) {
jobParametersBuilder.addLong(jobField.getKey(), jobField.getValue().asLong());
}
});
return new JobLaunchingData(jobName, jobParametersBuilder.toJobParameters());
}
示例10: getAvroSchema
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
/**
* Get an Avro schema using {@link AvroUtils#wrapAsNullable(Schema)} by node type.
*
* @param node Json node.
* @return an Avro schema using {@link AvroUtils#wrapAsNullable(Schema)} by node type.
*/
public Schema getAvroSchema(JsonNode node) {
if (node instanceof TextNode) {
return AvroUtils.wrapAsNullable(AvroUtils._string());
} else if (node instanceof IntNode) {
return AvroUtils.wrapAsNullable(AvroUtils._int());
} else if (node instanceof LongNode) {
return AvroUtils.wrapAsNullable(AvroUtils._long());
} else if (node instanceof DoubleNode) {
return AvroUtils.wrapAsNullable(AvroUtils._double());
} else if (node instanceof BooleanNode) {
return AvroUtils.wrapAsNullable(AvroUtils._boolean());
} else if (node instanceof NullNode) {
return AvroUtils.wrapAsNullable(AvroUtils._string());
} else {
return Schema.createRecord(getSubRecordRandomName(), null, null, false, getFields(node));
}
}
示例11: evaluate
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
@Override
public JsonNode evaluate(JsonNode node) {
JsonNode valueNode = super.evaluate(node);
if(valueNode!=null && valueNode.isNumber()) {
return LongNode.valueOf(Math.round(valueNode.asDouble()));
} else if (valueNode!=null && valueNode.isTextual()){
try {
Double doubleVal = Double.parseDouble(valueNode.asText());
return LongNode.valueOf(Math.round(doubleVal));
} catch(NumberFormatException e) {
throw new UnsupportedExprException("Value not parseable to a number");
}
} else {
throw new UnsupportedExprException("Value not a number or text to parse to a number");
}
}
示例12: setProp
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
@Override
public void setProp(HasProp hasProp, String group, String key, Object value) {
try {
ObjectNode groupJSON = getOrCreateJsonGroup(hasProp, group);
if (value == null) {
groupJSON.put(key, NullNode.getInstance());
} else if (value instanceof Long) {
groupJSON.put(key, LongNode.valueOf((Long) value));
} else if (value instanceof Double) {
groupJSON.put(key, DoubleNode.valueOf((Double) value));
} else if (value instanceof Integer) {
groupJSON.put(key, IntNode.valueOf((Integer) value));
} else if (value instanceof Float) {
groupJSON.put(key, new DoubleNode((double) value));
} else if (value instanceof String) {
groupJSON.put(key, TextNode.valueOf((String) value));
} else if (value instanceof Boolean) {
groupJSON.put(key, BooleanNode.valueOf((Boolean) value));
}
hasProp.setPropsJson(group, groupJSON.toString());
} catch (Exception e) {
logSetProp(hasProp, group, key, value);
}
}
示例13: unionLongInFloatRangeMax
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
@Test
public void unionLongInFloatRangeMax() throws JsonProcessingException, IOException {
Schema schemaA = SchemaBuilder.builder().floatType();
Schema schemaB = SchemaBuilder.builder().intType();
Schema schema = SchemaBuilder.unionOf().type(schemaA).and().type(schemaB).endUnion();
JsonNode datum = new LongNode((long) Float.MAX_VALUE);
UnionResolution unionResolution = new JasvornoConverter(model, UndeclaredFieldBehaviour.NO_MATCH)
.resolveUnion(datum, schema.getTypes());
assertThat(unionResolution.matchType, is(MatchType.FULL));
assertThat(unionResolution.schema, is(schemaA));
}
示例14: unionLongInFloatRangeMin
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
@Test
public void unionLongInFloatRangeMin() throws JsonProcessingException, IOException {
Schema schemaA = SchemaBuilder.builder().floatType();
Schema schemaB = SchemaBuilder.builder().intType();
Schema schema = SchemaBuilder.unionOf().type(schemaA).and().type(schemaB).endUnion();
JsonNode datum = new LongNode((long) -Float.MAX_VALUE);
UnionResolution unionResolution = new JasvornoConverter(model, UndeclaredFieldBehaviour.NO_MATCH)
.resolveUnion(datum, schema.getTypes());
assertThat(unionResolution.matchType, is(MatchType.FULL));
assertThat(unionResolution.schema, is(schemaA));
}
示例15: unionLongInsideFloatRange
import com.fasterxml.jackson.databind.node.LongNode; //导入依赖的package包/类
@Test
public void unionLongInsideFloatRange() throws JsonProcessingException, IOException {
Schema schemaA = SchemaBuilder.builder().floatType();
Schema schemaB = SchemaBuilder.builder().intType();
Schema schema = SchemaBuilder.unionOf().type(schemaA).and().type(schemaB).endUnion();
JsonNode datum = new LongNode((long) (0.5 * Float.MAX_VALUE));
UnionResolution unionResolution = new JasvornoConverter(model, UndeclaredFieldBehaviour.NO_MATCH)
.resolveUnion(datum, schema.getTypes());
assertThat(unionResolution.matchType, is(MatchType.FULL));
assertThat(unionResolution.schema, is(schemaA));
}