當前位置: 首頁>>代碼示例>>Java>>正文


Java TextNode.valueOf方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.node.TextNode.valueOf方法的典型用法代碼示例。如果您正苦於以下問題:Java TextNode.valueOf方法的具體用法?Java TextNode.valueOf怎麽用?Java TextNode.valueOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.node.TextNode的用法示例。


在下文中一共展示了TextNode.valueOf方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: applyGeneratesDate

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
@Test
public void applyGeneratesDate() {

    JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());

    ObjectNode objectNode = new ObjectMapper().createObjectNode();
    objectNode.put("type", "string");

    TextNode formatNode = TextNode.valueOf("date-time");
    objectNode.set("format", formatNode);

    JType mockDateType = mock(JType.class);
    FormatRule mockFormatRule = mock(FormatRule.class);
    when(mockFormatRule.apply(eq("fooBar"), eq(formatNode), Mockito.isA(JType.class), isNull(Schema.class))).thenReturn(mockDateType);
    when(ruleFactory.getFormatRule()).thenReturn(mockFormatRule);

    JType result = rule.apply("fooBar", objectNode, jpackage, null);

    assertThat(result, equalTo(mockDateType));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:TypeRuleTest.java

示例2: toValueNode

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的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.TextNode; //導入方法依賴的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: applyGeneratesDate

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
@Test
public void applyGeneratesDate() {

    JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());

    ObjectNode objectNode = new ObjectMapper().createObjectNode();
    objectNode.put("type", "string");

    TextNode formatNode = TextNode.valueOf("date-time");
    objectNode.put("format", formatNode);

    JType mockDateType = mock(JType.class);
    FormatRule mockFormatRule = mock(FormatRule.class);
    when(mockFormatRule.apply(eq("fooBar"), eq(formatNode), Mockito.isA(JType.class), isNull(Schema.class))).thenReturn(mockDateType);
    when(ruleFactory.getFormatRule()).thenReturn(mockFormatRule);

    JType result = rule.apply("fooBar", objectNode, jpackage, null);

    assertThat(result, equalTo(mockDateType));
}
 
開發者ID:fge,項目名稱:jsonschema2pojo,代碼行數:21,代碼來源:TypeRuleTest.java

示例5: applyGeneratesTypeFromFormatValue

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
@Test
public void applyGeneratesTypeFromFormatValue() {
    TextNode formatNode = TextNode.valueOf(formatValue);

    JType result = rule.apply("fooBar", formatNode, new JCodeModel().ref(String.class), null);

    assertThat(result.fullName(), equalTo(expectedType.getName()));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:FormatRuleJodaTest.java

示例6: primitiveToJson

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的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

示例7: evaluate

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
public JsonNode evaluate(JsonNode node) {
	JsonNode valueNode = super.evaluate(node);
	
	if(valueNode==null || !valueNode.isTextual()) {
		throw new UnsupportedExprException("Property value is not a string");
	}

	return TextNode.valueOf(valueNode.textValue().toLowerCase());
}
 
開發者ID:kcthota,項目名稱:JSONQuery,代碼行數:10,代碼來源:ToLowerValueExpression.java

示例8: evaluate

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
public JsonNode evaluate(JsonNode node) {
	JsonNode valueNode = super.evaluate(node);

	if (valueNode == null || !valueNode.isTextual()) {
		throw new UnsupportedExprException("Property value is not a string");
	}

	String value = valueNode.textValue();

	if (endIndex == null || (endIndex != null && endIndex > value.length())) {
		endIndex = value.length();
	}

	return TextNode.valueOf(value.substring(startIndex, endIndex));
}
 
開發者ID:kcthota,項目名稱:JSONQuery,代碼行數:16,代碼來源:SubstringValueExpression.java

示例9: evaluate

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
public JsonNode evaluate(JsonNode node) {
	JsonNode valueNode = super.evaluate(node);
	
	if(valueNode==null || !valueNode.isTextual()) {
		throw new UnsupportedExprException("Property value is not a string");
	}

	return TextNode.valueOf(valueNode.textValue().toUpperCase());
}
 
開發者ID:kcthota,項目名稱:JSONQuery,代碼行數:10,代碼來源:ToUpperValueExpression.java

示例10: evaluate

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
public JsonNode evaluate(JsonNode node) {
	JsonNode valueNode = super.evaluate(node);
	
	if(valueNode==null || !valueNode.isTextual()) {
		throw new UnsupportedExprException("Property value is not a string");
	}

	return TextNode.valueOf(valueNode.textValue().trim());
}
 
開發者ID:kcthota,項目名稱:JSONQuery,代碼行數:10,代碼來源:TrimValueExpression.java

示例11: evaluate

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
public JsonNode evaluate(JsonNode node) {
	JsonNode valueNode = super.evaluate(node);
	
	if(valueNode==null || !valueNode.isTextual()) {
		throw new UnsupportedExprException("Property value is not a string");
	}

	return TextNode.valueOf(valueNode.textValue().replace(target, replacement));
}
 
開發者ID:kcthota,項目名稱:JSONQuery,代碼行數:10,代碼來源:ReplaceValueExpression.java

示例12: evaluate

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
public JsonNode evaluate(JsonNode node) {
	JsonNode valueNode = super.evaluate(node);
	
	if(valueNode==null || !valueNode.isTextual()) {
		throw new UnsupportedExprException("Property value is not a string");
	}

	return TextNode.valueOf(valueNode.textValue() + appendText);
}
 
開發者ID:kcthota,項目名稱:JSONQuery,代碼行數:10,代碼來源:AppendToValueExpression.java

示例13: merge

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
private JsonNode merge(JsonNode source, JsonNode replacement) throws IOException {
	JsonNode replacementNodeEncoded = replacement.get(fieldName);
	if (replacementNodeEncoded != null) {
		HashMap<String, JsonNode> result = new HashMap<String, JsonNode>();
		result.putAll(groupArrayElementsByKey(tryDecode(source.get(fieldName), mapper.createArrayNode(), fieldName), key));
		result.putAll(groupArrayElementsByKey(tryDecode(replacement.get(fieldName), mapper.createArrayNode(), fieldName), key));
		return TextNode.valueOf(mapper.writeValueAsString(result.values()));
	} else {
		return source.get(fieldName);
	}
}
 
開發者ID:stagemonitor,項目名稱:stagemonitor,代碼行數:12,代碼來源:JsonMerger.java

示例14: toJsonNode

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的package包/類
@Override
public JsonNode toJsonNode() {
    return TextNode.valueOf(value);
}
 
開發者ID:sidemash,項目名稱:redson,代碼行數:5,代碼來源:JsonString.java

示例15: generateValue

import com.fasterxml.jackson.databind.node.TextNode; //導入方法依賴的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.TextNode.valueOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。