当前位置: 首页>>代码示例>>Java>>正文


Java DoubleNode类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.node.DoubleNode的典型用法代码示例。如果您正苦于以下问题:Java DoubleNode类的具体用法?Java DoubleNode怎么用?Java DoubleNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DoubleNode类属于com.fasterxml.jackson.databind.node包,在下文中一共展示了DoubleNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的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 );
  }
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:25,代码来源:PrimitiveObjectToJsonNode.java

示例2: activate

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的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");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:UiExtensionManager.java

示例3: activate

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的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");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:DistributedNetworkConfigStore.java

示例4: deserializePrimitiveTest

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的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")));
}
 
开发者ID:algohub,项目名称:judge-engine,代码行数:22,代码来源:DeserializerTest.java

示例5: primitiveToJsonTest

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的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")));
}
 
开发者ID:algohub,项目名称:judge-engine,代码行数:18,代码来源:SerializerTest.java

示例6: toValueNode

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的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());
}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:21,代码来源:Json8.java

示例7: toValueNode

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的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());
	}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:20,代码来源:Json7.java

示例8: getAvroSchema

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的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));
    }
}
 
开发者ID:Talend,项目名称:daikon,代码行数:24,代码来源:JsonSchemaInferrer.java

示例9: evaluate

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的package包/类
@Override
public JsonNode evaluate(JsonNode node) {
	JsonNode valueNode = super.evaluate(node);
	if(valueNode!=null && valueNode.isNumber()) {
		
		return DoubleNode.valueOf(Math.ceil(valueNode.asDouble()));
	} else if (valueNode!=null && valueNode.isTextual()){
		try {
			Double doubleVal = Double.parseDouble(valueNode.asText());
			return DoubleNode.valueOf(Math.ceil(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");
	}
}
 
开发者ID:kcthota,项目名称:JSONQuery,代码行数:18,代码来源:CeilValueExpression.java

示例10: evaluate

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的package包/类
@Override
public JsonNode evaluate(JsonNode node) {
	JsonNode valueNode = super.evaluate(node);
	if(valueNode!=null && valueNode.isNumber()) {
		
		return DoubleNode.valueOf(Math.floor(valueNode.asDouble()));
	} else if (valueNode!=null && valueNode.isTextual()){
		try {
			Double doubleVal = Double.parseDouble(valueNode.asText());
			return DoubleNode.valueOf(Math.floor(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");
	}
}
 
开发者ID:kcthota,项目名称:JSONQuery,代码行数:18,代码来源:FloorValueExpression.java

示例11: geocode

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的package包/类
public Geocoder.LatLong geocode(String address) {
    try {
        Map<String, Object> vars = new HashMap<>();
        vars.put("address", address);
        ResponseEntity<JsonNode> jsonNodeResponseEntity = this.restTemplate.getForEntity(
                this.urlPath, JsonNode.class, vars);
        JsonNode body = jsonNodeResponseEntity.getBody();
        if (jsonNodeResponseEntity.getStatusCode().equals(HttpStatus.OK)
                && body.path("status").textValue().equalsIgnoreCase("OK")) {
            if (body.path("results").size() > 0) {
                String formattedAddress = body.path("results").get(0).get("formatted_address").textValue();
                DoubleNode lngNode = (DoubleNode) body.path("results").get(0).path("geometry").path("location").get("lng");
                DoubleNode latNode = (DoubleNode) body.path("results").get(0).path("geometry").path("location").get("lat");
                log.debug(String.format("formatted address: %s", formattedAddress));
                return new Geocoder.LatLong(latNode.doubleValue(), lngNode.doubleValue());
            }
        }
    } catch (Exception ex) {
        log.debug("exception when processing address '" + address + "'", ex);
    }
    return null;
}
 
开发者ID:joshlong,项目名称:sfdc-cloudfoundry,代码行数:23,代码来源:GoogleGeocoder.java

示例12: setProp

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的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);
    }
}
 
开发者ID:inepex,项目名称:ineform,代码行数:25,代码来源:JavaPropHandler.java

示例13: incrementProperty

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的package包/类
public void incrementProperty(Connection conn, String project, Object userId, String property, double value)
        throws SQLException {
    Map<String, FieldType> columns = createMissingColumns(project, userId, ImmutableList.of(new SimpleImmutableEntry<>(property, new DoubleNode(value))), new CommitConnection(conn));

    FieldType fieldType = columns.get(property);
    if (fieldType == null) {
        createColumn(project, userId, property, JsonHelper.numberNode(0));
    }

    if (!fieldType.isNumeric()) {
        throw new RakamException(String.format("The property the is %s and it can't be incremented.", fieldType.name()),
                BAD_REQUEST);
    }

    String tableRef = checkTableColumn(stripName(property, "table column"));
    Statement statement = conn.createStatement();
    ProjectCollection userTable = getUserTable(project, false);

    String table = checkProject(userTable.project, '"') + "." + checkCollection(userTable.collection);

    int execute = statement.executeUpdate("update " + table +
            " set " + tableRef + " = " + value + " + coalesce(" + tableRef + ", 0)");
    if (execute == 0) {
        create(project, userId, JsonHelper.jsonObject().put(property, value));
    }
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:27,代码来源:AbstractPostgresqlUserStorage.java

示例14: arrayNodesHaveSameValues

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的package包/类
public boolean arrayNodesHaveSameValues(JsonNode expected, JsonNode actual) {
    int i = 0;
    for (Iterator<JsonNode> nodes = expected.elements(); nodes.hasNext(); i++) {

        JsonNode node = nodes.next();

        if (node instanceof TextNode) {
            return textNodesHaveSameValue(node, actual.get(i));
        } else if (node instanceof IntNode) {
            return intNodesHaveSameValue(node, actual.get(i));
        } else if (node instanceof DoubleNode) {
            return doubleNodesHaveSameValue(node, actual.get(i));
        }
    }
    return true;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:17,代码来源:AbstractJsonNodeTest.java

示例15: setPrecision

import com.fasterxml.jackson.databind.node.DoubleNode; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
public void setPrecision(final JsonNode value) throws IOException {
    if (value.isObject()) {
        sd = new FieldSampler() {
            FieldSampler base = FieldSampler.newSampler(value.toString());

            @Override
            public JsonNode sample() {
                return new DoubleNode(Math.sqrt(1 / base.sample().asDouble()));
            }
        };
    } else {
        this.sd = constant(Math.sqrt(1 / value.asDouble()));
    }
    init();
}
 
开发者ID:tdunning,项目名称:log-synth,代码行数:17,代码来源:RandomWalkSampler.java


注:本文中的com.fasterxml.jackson.databind.node.DoubleNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。