use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project JMRI by JMRI.
the class JsonClientTrafficController method receiveLoop.
@Override
public void receiveLoop() {
log.debug("receiveLoop starts");
ObjectReader reader = this.mapper.reader();
while (true) {
try {
JsonNode root = reader.readTree((InputStream) this.istream);
String type = root.path(TYPE).asText();
JsonNode data = root.path(DATA);
log.debug("Processing {} with {}", type, data);
if (type.equals(GOODBYE)) {
log.info("Connection closing from server.");
break;
} else if (type.equals(HELLO)) {
this.receiveHello(data);
} else if (type.equals(LOCALE)) {
this.receiveHello(data);
} else if (type.equals(PONG)) {
// silently ignore
} else if (!data.isMissingNode() || (root.isArray() && ((ArrayNode) root).size() > 0)) {
// process replies with a data node or non-empty arrays
JsonClientReply reply = new JsonClientReply(root);
Runnable r = new RcvNotifier(reply, mLastSender, this);
try {
SwingUtilities.invokeAndWait(r);
} catch (InterruptedException e) {
log.error("Exception notifying listeners of reply: {}", e.getMessage(), e);
} catch (InvocationTargetException e) {
log.error("Exception notifying listeners of reply: {}", e.getMessage(), e);
}
}
} catch (IOException e) {
this.rcvException = true;
reportReceiveLoopException(e);
break;
} catch (NoSuchElementException nse) {
// so break out of the loop
break;
}
}
ConnectionStatus.instance().setConnectionState(this.controller.getCurrentPortName(), ConnectionStatus.CONNECTION_DOWN);
log.error("Exit from rcv loop");
this.recovery();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project knime-core by knime.
the class AbstractPageManager method getJSONLayoutFromSubnode.
private JSONLayoutPage getJSONLayoutFromSubnode(final NodeIDSuffix pageID, final String layoutInfo) throws IOException {
ObjectMapper mapper = JSONLayoutPage.getConfiguredVerboseObjectMapper();
ObjectReader reader = mapper.readerForUpdating(new JSONLayoutPage());
JSONLayoutPage page = reader.readValue(layoutInfo);
if (page != null && page.getRows() != null) {
for (JSONLayoutRow row : page.getRows()) {
setNodeIDInContent(row, pageID);
}
}
return page;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project knime-core by knime.
the class SubnodeLayoutJSONEditorPage method getJsonDocument.
/**
* @return the jsonDocument
*/
public String getJsonDocument() {
ObjectMapper mapper = JSONLayoutPage.getConfiguredObjectMapper();
ObjectReader reader = mapper.readerForUpdating(new JSONLayoutPage());
try {
String json = isWindows() ? m_textArea.getText() : m_jsonDocument;
JSONLayoutPage page = reader.readValue(json);
String layoutString = mapper.writeValueAsString(page);
return layoutString;
} catch (IOException e) {
LOGGER.error("Failed to retrieve JSON string from layout:" + e.getMessage(), e);
}
return "";
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project knime-core by knime.
the class SubnodeLayoutJSONEditorPage method updateBasicLayout.
private void updateBasicLayout() {
ObjectMapper mapper = JSONLayoutPage.getConfiguredObjectMapper();
JSONLayoutPage page = new JSONLayoutPage();
ObjectReader reader = mapper.readerForUpdating(page);
try {
page = reader.readValue(m_jsonDocument);
} catch (Exception e) {
/* do nothing, input needs to be validated beforehand */
}
m_basicMap.clear();
m_basicPanelAvailable = true;
List<JSONLayoutRow> rows = page.getRows();
for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) {
JSONLayoutRow row = rows.get(rowIndex);
populateDocumentNodeIDs(row);
processBasicLayoutRow(row, rowIndex);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project drill by axbaretto.
the class TestParsePhysicalPlan method parseSimplePlan.
@Test
public void parseSimplePlan() throws Exception {
DrillConfig c = DrillConfig.create();
ScanResult scanResult = ClassPathScanner.fromPrescan(c);
LogicalPlanPersistence lpp = new LogicalPlanPersistence(c, scanResult);
PhysicalPlanReader reader = new PhysicalPlanReader(c, scanResult, lpp, CoordinationProtos.DrillbitEndpoint.getDefaultInstance(), null);
ObjectReader r = lpp.getMapper().reader(PhysicalPlan.class);
ObjectWriter writer = lpp.getMapper().writer();
PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/physical_test1.json"), Charsets.UTF_8));
String unparse = plan.unparse(writer);
// System.out.println(unparse);
}
Aggregations