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


Java BooleanNode.valueOf方法代码示例

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


在下文中一共展示了BooleanNode.valueOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import com.fasterxml.jackson.databind.node.BooleanNode; //导入方法依赖的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: toValueNode

import com.fasterxml.jackson.databind.node.BooleanNode; //导入方法依赖的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

示例3: toValueNode

import com.fasterxml.jackson.databind.node.BooleanNode; //导入方法依赖的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

示例4: get

import com.fasterxml.jackson.databind.node.BooleanNode; //导入方法依赖的package包/类
public static JsonNode get( final Object obj ) throws IOException{

    if( obj instanceof PrimitiveObject ){
      return PrimitiveObjectToJsonNode.get( (PrimitiveObject)obj );
    }
    else if( obj instanceof String ){
      return new TextNode( (String)obj );
    }
    else if( obj instanceof Boolean ){
      return BooleanNode.valueOf( (Boolean)obj );
    }
    else if( obj instanceof Short ){
      return IntNode.valueOf( ( (Short)obj ).intValue() );
    }
    else if( obj instanceof Integer ){
      return IntNode.valueOf( (Integer)obj );
    }
    else if( obj instanceof Long ){
      return new LongNode( (Long)obj );
    }
    else if( obj instanceof Float ){
      return new DoubleNode( ( (Float)obj ).doubleValue() );
    }
    else if( obj instanceof Double ){
      return new DoubleNode( (Double)obj );
    }
    else if( obj instanceof byte[] ){
      return new BinaryNode( (byte[])obj );
    }
    else if( obj == null ){
      return NullNode.getInstance();
    }
    else{
      return new TextNode( obj.toString() );
    }
  }
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:37,代码来源:ObjectToJsonNode.java

示例5: primitiveToJson

import com.fasterxml.jackson.databind.node.BooleanNode; //导入方法依赖的package包/类
/**
 * Serialize primtive values to JSON .
 */
static <T> JsonNode primitiveToJson(final T value, final TypeNode type) {
  final JsonNode result;
  // for BinaryTreeNode
  if (value == null) {
    return NullNode.instance;
  }

  switch (type.getValue()) {
    case BOOL:
      result = BooleanNode.valueOf((Boolean) value);
      break;
    case CHAR:
      result = TextNode.valueOf(value.toString());
      break;
    case STRING:
      result = TextNode.valueOf((String) value);
      break;
    case DOUBLE:
      result = DoubleNode.valueOf((Double) value);
      break;
    case INT:
      result = IntNode.valueOf((Integer) value);
      break;
    case LONG:
      result = LongNode.valueOf((Long) value);
      break;
    default:
      throw new IllegalArgumentException("Unrecognized primitive type: " + type);
  }
  return result;
}
 
开发者ID:algohub,项目名称:judge-engine,代码行数:35,代码来源:Serializer.java

示例6: generateValue

import com.fasterxml.jackson.databind.node.BooleanNode; //导入方法依赖的package包/类
private JsonNode generateValue(LinkedList<String> path, ObjectNode schema, int index) {

		String stringPath = Utils.join(".", path.toArray(new String[path.size()]));
		List<Object> list = paths.get(stringPath);
		if (list != null)
			return Json7.toNode(list.get(random.nextInt(list.size())));

		JsonNode values = Json7.get(schema, "_values");
		if (values != null) {
			if (values.isArray()) {
				if (index < values.size())
					return values.get(index);
				return values.get(random.nextInt(values.size()));
			} else
				return values;
		}

		JsonNode enumType = Json7.get(schema, "_enumType");
		if (enumType != null) {
			if (types.containsKey(enumType.asText())) {
				List<String> typeValues = types.get(enumType.asText());
				String value = typeValues.get(random.nextInt(typeValues.size()));
				return Json7.toNode(value);
			}
		}

		JsonNode examples = Json7.get(schema, "_examples");
		if (examples != null) {
			if (examples.isArray()) {
				if (index < examples.size())
					return examples.get(index);
				return examples.get(random.nextInt(examples.size()));
			} else
				return examples;
		}

		String type = schema.get("_type").asText();

		if ("text".equals(type))
			return TextNode.valueOf(
					"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.");
		else if ("string".equals(type))
			return TextNode.valueOf("RD5654GH78");
		else if ("boolean".equals(type))
			return BooleanNode.valueOf(random.nextBoolean());
		else if ("integer".equals(type))
			return IntNode.valueOf(random.nextInt());
		else if ("long".equals(type))
			return LongNode.valueOf(random.nextLong());
		else if ("float".equals(type))
			return FloatNode.valueOf(random.nextFloat());
		else if ("double".equals(type))
			return DoubleNode.valueOf(random.nextDouble());
		else if ("date".equals(type))
			return TextNode.valueOf("2015-09-09");
		else if ("time".equals(type))
			return TextNode.valueOf("15:30:00");
		else if ("timestamp".equals(type))
			return TextNode.valueOf("2015-01-09T15:37:00.123Z");
		else if ("enum".equals(type))
			return TextNode.valueOf("blue");
		else if ("geopoint".equals(type))
			return Json7.object("lat", 48 + random.nextDouble(), "lon", 2 + random.nextDouble());
		else if ("object".equals(type))
			return generateObject(path, schema, index);

		return NullNode.getInstance();
	}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:69,代码来源:JsonGenerator.java


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