本文整理汇总了Java中com.fasterxml.jackson.databind.node.IntNode类的典型用法代码示例。如果您正苦于以下问题:Java IntNode类的具体用法?Java IntNode怎么用?Java IntNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntNode类属于com.fasterxml.jackson.databind.node包,在下文中一共展示了IntNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的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 );
}
}
示例2: activate
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的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");
}
示例3: activate
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的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");
}
示例4: deserialize
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的package包/类
@Test
public void deserialize() throws Exception {
StratumMessage m1 = readValue("{\"id\":123, \"method\":\"a.b\", \"params\":[1, \"x\", null]}");
assertEquals(123L, (long)m1.id);
assertEquals("a.b", m1.method);
assertEquals(Lists.newArrayList(new IntNode(1), new TextNode("x"), NullNode.getInstance()), m1.params);
StratumMessage m2 = readValue("{\"id\":123, \"result\":{\"x\": 123}}");
assertTrue(m2.isResult());
assertEquals(123L, (long)m2.id);
assertEquals(mapper.createObjectNode().put("x", 123), m2.result);
StratumMessage m3 = readValue("{\"id\":123, \"result\":[\"x\"]}");
assertEquals(123L, (long)m3.id);
//noinspection AssertEqualsBetweenInconvertibleTypes
assertEquals(mapper.createArrayNode().add("x"), m3.result);
}
示例5: resolve
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的package包/类
/**
* Obtain the value for 'name' from the given stack frame's node.
*/
private JsonNode resolve(Object name, Frame frame) {
// Special internal variable @index points to the array index for a
// given stack frame.
if (name instanceof String) {
String strName = (String)name;
if (strName.startsWith("@")) {
if (name.equals("@index")) {
if (frame.currentIndex != -1) {
// @index is 1-based
return new IntNode(frame.currentIndex + 1);
}
return Constants.MISSING_NODE;
}
JsonNode node = frame.getVar(strName);
return (node == null) ? Constants.MISSING_NODE : node;
}
// Fall through
}
return nodePath(frame.node(), name);
}
示例6: deserializePrimitiveTest
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的package包/类
@Test public void deserializePrimitiveTest() {
assertEquals(Boolean.TRUE,
Deserializer.fromJson(TypeNode.fromString("bool"), BooleanNode.TRUE));
assertEquals(Boolean.FALSE,
Deserializer.fromJson(TypeNode.fromString("bool"), BooleanNode.FALSE));
assertEquals('a',
Deserializer.fromJson(TypeNode.fromString("char"), TextNode.valueOf("a")));
assertEquals(Integer.valueOf(123),
Deserializer.fromJson(TypeNode.fromString("int"), IntNode.valueOf(123)));
assertEquals(Long.valueOf(123),
Deserializer.fromJson(TypeNode.fromString("long"), IntNode.valueOf(123)));
assertEquals(Double.valueOf(123.0),
Deserializer.fromJson(TypeNode.fromString("double"), DoubleNode.valueOf(123.0)));
assertEquals("algohub",
Deserializer.fromJson(TypeNode.fromString("string"), TextNode.valueOf("algohub")));
}
示例7: primitiveToJsonTest
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的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")));
}
示例8: deserialize
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的package包/类
@Override
public Location deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
JsonNode node = jp.getCodec().readTree(jp);
int id = (Integer) ((IntNode) node.get("locationId")).numberValue();
String countryCode = node.get("countryCode").asText();
String defaultLanguage = node.get("defaultLanguage").asText();
Locale locale = new Locale.Builder().setLanguage(defaultLanguage).setRegion(countryCode).build();
String name = node.get("locationName").asText();
JsonNode mapSection = node.get("mapSection");
Coordinates center = new Coordinates(mapSection.get("center").get("latitude").asDouble(), mapSection.get("center").get("longitude").asDouble());
Coordinates lowerRight = new Coordinates(mapSection.get("lowerRight").get("latitude").asDouble(), mapSection.get("lowerRight").get("longitude").asDouble());
Coordinates upperLeft = new Coordinates(mapSection.get("upperLeft").get("latitude").asDouble(), mapSection.get("upperLeft").get("longitude").asDouble());
TimeZone timezone = TimeZone.getTimeZone(node.get("timezone").asText());
return new Location(id, locale, name, center, lowerRight, upperLeft, timezone);
}
示例9: toValueNode
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的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());
}
示例10: toValueNode
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的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());
}
示例11: getJobLaunchingData
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的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());
}
示例12: getAvroSchema
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的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));
}
}
示例13: add
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的package包/类
@Test
public void add() throws JsonProcessingException {
// Entity
Branch branch = do_create_branch();
// Adds some data
String name = uid("T");
EntityDataStoreRecord record = store.add(branch, CATEGORY, name, Signature.of(TEST_USER), null, new IntNode(15));
// Checks
assertNotNull(record);
assertTrue(record.getId() > 0);
assertEquals(CATEGORY, record.getCategory());
assertNotNull(record.getSignature());
assertEquals(name, record.getName());
assertNull(record.getGroupName());
assertEquals(branch.getProjectEntityType(), record.getEntity().getProjectEntityType());
assertEquals(branch.getId(), record.getEntity().getId());
assertJsonEquals(
new IntNode(15),
record.getData()
);
}
示例14: replaceOrAdd
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的package包/类
@Test
public void replaceOrAdd() throws JsonProcessingException {
// Entity
Branch branch = do_create_branch();
// Adds some data
String name = uid("T");
EntityDataStoreRecord record = store.add(branch, CATEGORY, name, Signature.of(TEST_USER), null, new IntNode(15));
// Checks
assertTrue(record.getId() > 0);
assertEquals(CATEGORY, record.getCategory());
assertJsonEquals(
new IntNode(15),
record.getData()
);
// Updates the same name
EntityDataStoreRecord secondRecord = store.replaceOrAdd(branch, CATEGORY, name, Signature.of(TEST_USER), null, new IntNode(16));
// Checks
assertEquals(record.getId(), secondRecord.getId());
assertJsonEquals(
new IntNode(16),
secondRecord.getData()
);
}
示例15: replaveOrAddForNewRecord
import com.fasterxml.jackson.databind.node.IntNode; //导入依赖的package包/类
@Test
public void replaveOrAddForNewRecord() throws JsonProcessingException {
// Entity
Branch branch = do_create_branch();
// Adds some data
String name = uid("T");
EntityDataStoreRecord record = store.add(branch, CATEGORY, name, Signature.of(TEST_USER), null, new IntNode(15));
// Checks
assertTrue(record.getId() > 0);
assertEquals(CATEGORY, record.getCategory());
assertJsonEquals(
new IntNode(15),
record.getData()
);
// Updates with a different same name
EntityDataStoreRecord secondRecord = store.replaceOrAdd(branch, CATEGORY, name + "2", Signature.of(TEST_USER), null, new IntNode(16));
// Checks
assertNotEquals(record.getId(), secondRecord.getId());
assertJsonEquals(
new IntNode(16),
secondRecord.getData()
);
}