use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project che by eclipse.
the class CommandDeserializer method toCommand.
private List<String> toCommand(ArrayNode arrayCommandNode, DeserializationContext ctxt) throws JsonMappingException {
List<String> commands = new ArrayList<>();
for (TreeNode treeNode : arrayCommandNode) {
if (treeNode instanceof TextNode) {
TextNode textNode = (TextNode) treeNode;
commands.add(textNode.asText());
} else {
throw ctxt.mappingException("Array 'command' contains not string element.");
}
}
return commands;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project jackson-databind by FasterXML.
the class TestTreeTraversingParser method testTextAsBinary.
public void testTextAsBinary() throws Exception {
TextNode n = new TextNode(" APs=\n");
JsonParser p = n.traverse();
assertNull(p.getCurrentToken());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
byte[] data = p.getBinaryValue();
assertNotNull(data);
assertArrayEquals(new byte[] { 0, -5 }, data);
assertNull(p.nextToken());
p.close();
assertTrue(p.isClosed());
// Also: let's verify we get an exception for garbage...
n = new TextNode("?!??");
p = n.traverse();
assertToken(JsonToken.VALUE_STRING, p.nextToken());
try {
p.getBinaryValue();
} catch (InvalidFormatException e) {
verifyException(e, "Illegal character");
}
p.close();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class InfoArchiveRestClient method getValidJsonRequestForExport.
private String getValidJsonRequestForExport(String exportConfigurationUri, List<SearchResult> searchResults) {
JsonNodeFactory jsonNodeFactory = new ObjectMapper().getNodeFactory();
ObjectNode root = jsonNodeFactory.objectNode();
ArrayNode includedRows = jsonNodeFactory.arrayNode();
for (SearchResult searchResult : searchResults) {
for (Row row : searchResult.getRows()) {
includedRows.add(row.getId());
}
}
TextNode exportConfiguration = jsonNodeFactory.textNode(exportConfigurationUri);
root.set("exportConfiguration", exportConfiguration);
root.set("includedRows", includedRows);
return root.toString();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project parquet-mr by apache.
the class AvroJson method visit.
private static <T> T visit(JsonNode node, JsonTreeVisitor<T> visitor) {
switch(node.getNodeType()) {
case OBJECT:
Preconditions.checkArgument(node instanceof ObjectNode, "Expected instance of ObjectNode: " + node);
// use LinkedHashMap to preserve field order
Map<String, T> fields = Maps.newLinkedHashMap();
Iterator<Map.Entry<String, JsonNode>> iter = node.fields();
while (iter.hasNext()) {
Map.Entry<String, JsonNode> entry = iter.next();
visitor.recordLevels.push(entry.getKey());
fields.put(entry.getKey(), visit(entry.getValue(), visitor));
visitor.recordLevels.pop();
}
return visitor.object((ObjectNode) node, fields);
case ARRAY:
Preconditions.checkArgument(node instanceof ArrayNode, "Expected instance of ArrayNode: " + node);
List<T> elements = Lists.newArrayListWithExpectedSize(node.size());
for (JsonNode element : node) {
elements.add(visit(element, visitor));
}
return visitor.array((ArrayNode) node, elements);
case BINARY:
Preconditions.checkArgument(node instanceof BinaryNode, "Expected instance of BinaryNode: " + node);
return visitor.binary((BinaryNode) node);
case STRING:
Preconditions.checkArgument(node instanceof TextNode, "Expected instance of TextNode: " + node);
return visitor.text((TextNode) node);
case NUMBER:
Preconditions.checkArgument(node instanceof NumericNode, "Expected instance of NumericNode: " + node);
return visitor.number((NumericNode) node);
case BOOLEAN:
Preconditions.checkArgument(node instanceof BooleanNode, "Expected instance of BooleanNode: " + node);
return visitor.bool((BooleanNode) node);
case MISSING:
Preconditions.checkArgument(node instanceof MissingNode, "Expected instance of MissingNode: " + node);
return visitor.missing((MissingNode) node);
case NULL:
Preconditions.checkArgument(node instanceof NullNode, "Expected instance of NullNode: " + node);
return visitor.nullNode((NullNode) node);
default:
throw new IllegalArgumentException("Unknown node type: " + node.getNodeType() + ": " + node);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project solr-document-store by DBCDK.
the class StatusBean method createDiagStatusNode.
private JsonNode createDiagStatusNode() {
try (Connection connection = dataSource.getConnection();
Statement stmt = connection.createStatement();
ResultSet resultSet = stmt.executeQuery("SELECT diag FROM queue_error")) {
ObjectNode node = O.createObjectNode();
HashMap<ArrayList<String>, AtomicInteger> diags = new HashMap<>();
int c = 0;
while (resultSet.next() && c++ <= DIAG_COLLAPSE_MAX_ROWS) {
addToDiags(diags, resultSet.getString(1));
}
if (c > DIAG_COLLAPSE_MAX_ROWS) {
node.put("", "Diags limited to " + DIAG_COLLAPSE_MAX_ROWS + " rows");
}
Map<ArrayList<String>, String> sortKey = diags.keySet().stream().collect(Collectors.toMap(a -> a, a -> diagAsString(a)));
diags.entrySet().stream().sorted((l, r) -> sortKey.get(l.getKey()).compareToIgnoreCase(sortKey.get(r.getKey()))).forEach(e -> {
node.put(sortKey.get(e.getKey()), e.getValue().get());
});
return node;
} catch (SQLException ex) {
log.error("Sql error counting queue entries: {}", ex.getMessage());
log.debug("Sql error counting queue entries: ", ex);
return new TextNode("SQL Exception");
}
}
Aggregations