Java Code Examples for org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode#isTextual()

The following examples show how to use org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode#isTextual() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonRowSchemaConverter.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static TypeInformation<?> convertStringFormat(String location, JsonNode node) {
	if (!node.isTextual()) {
		throw new IllegalArgumentException("Invalid '" + FORMAT + "' property in node: " + location);
	}

	switch (node.asText()) {
		case FORMAT_DATE:
			return Types.SQL_DATE;
		case FORMAT_TIME:
			return Types.SQL_TIME;
		case FORMAT_DATE_TIME:
			return Types.SQL_TIMESTAMP;
		default:
			return Types.STRING; // unlikely that we will support other formats in the future
	}
}
 
Example 2
Source File: JsonRowSchemaConverter.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static TypeInformation<?> convertStringEncoding(String location, JsonNode node) {
	if (!node.isTextual()) {
		throw new IllegalArgumentException("Invalid '" + CONTENT_ENCODING + "' property in node: " + location);
	}

	// "If the instance value is a string, this property defines that the string SHOULD
	// be interpreted as binary data and decoded using the encoding named by this property."

	switch (node.asText()) {
		case CONTENT_ENCODING_BASE64:
			return Types.PRIMITIVE_ARRAY(Types.BYTE);
		default:
			// we fail hard here:
			// this gives us the chance to support more encodings in the future without problems
			// of backwards compatibility
			throw new IllegalArgumentException("Invalid encoding '" + node.asText() + "' in node: " + location);
	}
}
 
Example 3
Source File: JsonRowSchemaConverter.java    From flink with Apache License 2.0 6 votes vote down vote up
private static TypeInformation<?> convertStringFormat(String location, JsonNode node) {
	if (!node.isTextual()) {
		throw new IllegalArgumentException("Invalid '" + FORMAT + "' property in node: " + location);
	}

	switch (node.asText()) {
		case FORMAT_DATE:
			return Types.SQL_DATE;
		case FORMAT_TIME:
			return Types.SQL_TIME;
		case FORMAT_DATE_TIME:
			return Types.SQL_TIMESTAMP;
		default:
			return Types.STRING; // unlikely that we will support other formats in the future
	}
}
 
Example 4
Source File: JsonRowSchemaConverter.java    From flink with Apache License 2.0 6 votes vote down vote up
private static TypeInformation<?> convertStringEncoding(String location, JsonNode node) {
	if (!node.isTextual()) {
		throw new IllegalArgumentException("Invalid '" + CONTENT_ENCODING + "' property in node: " + location);
	}

	// "If the instance value is a string, this property defines that the string SHOULD
	// be interpreted as binary data and decoded using the encoding named by this property."

	switch (node.asText()) {
		case CONTENT_ENCODING_BASE64:
			return Types.PRIMITIVE_ARRAY(Types.BYTE);
		default:
			// we fail hard here:
			// this gives us the chance to support more encodings in the future without problems
			// of backwards compatibility
			throw new IllegalArgumentException("Invalid encoding '" + node.asText() + "' in node: " + location);
	}
}
 
Example 5
Source File: JsonRowSchemaConverter.java    From flink with Apache License 2.0 6 votes vote down vote up
private static TypeInformation<?> convertStringFormat(String location, JsonNode node) {
	if (!node.isTextual()) {
		throw new IllegalArgumentException("Invalid '" + FORMAT + "' property in node: " + location);
	}

	switch (node.asText()) {
		case FORMAT_DATE:
			return Types.SQL_DATE;
		case FORMAT_TIME:
			return Types.SQL_TIME;
		case FORMAT_DATE_TIME:
			return Types.SQL_TIMESTAMP;
		default:
			return Types.STRING; // unlikely that we will support other formats in the future
	}
}
 
Example 6
Source File: JsonRowSchemaConverter.java    From flink with Apache License 2.0 6 votes vote down vote up
private static TypeInformation<?> convertStringEncoding(String location, JsonNode node) {
	if (!node.isTextual()) {
		throw new IllegalArgumentException("Invalid '" + CONTENT_ENCODING + "' property in node: " + location);
	}

	// "If the instance value is a string, this property defines that the string SHOULD
	// be interpreted as binary data and decoded using the encoding named by this property."

	switch (node.asText()) {
		case CONTENT_ENCODING_BASE64:
			return Types.PRIMITIVE_ARRAY(Types.BYTE);
		default:
			// we fail hard here:
			// this gives us the chance to support more encodings in the future without problems
			// of backwards compatibility
			throw new IllegalArgumentException("Invalid encoding '" + node.asText() + "' in node: " + location);
	}
}
 
Example 7
Source File: Selectors.java    From stateful-functions with Apache License 2.0 5 votes vote down vote up
public static String textAt(JsonNode node, JsonPointer pointer) {
  node = dereference(node, pointer);
  if (!node.isTextual()) {
    throw new WrongTypeException(pointer, "not a string");
  }
  return node.asText();
}
 
Example 8
Source File: Selectors.java    From flink-statefun with Apache License 2.0 5 votes vote down vote up
public static String textAt(JsonNode node, JsonPointer pointer) {
  node = dereference(node, pointer);
  if (!node.isTextual()) {
    throw new WrongTypeException(pointer, "not a string");
  }
  return node.asText();
}
 
Example 9
Source File: Selectors.java    From flink-statefun with Apache License 2.0 5 votes vote down vote up
public static Optional<String> optionalTextAt(JsonNode node, JsonPointer pointer) {
  node = node.at(pointer);
  if (node.isMissingNode()) {
    return Optional.empty();
  }
  if (!node.isTextual()) {
    throw new WrongTypeException(pointer, "not a string");
  }
  return Optional.of(node.asText());
}