Source:
<code>private InterpreterResult getResultFromStatementInfo(StatementInfo stmtInfo, boolean displayAppInfo) { if (stmtInfo.output.isError()) { return new InterpreterResult(InterpreterResult.Code.ERROR, stmtInfo.output.evalue); } else { String result = stmtInfo.output.data.plain_text; if (stmtInfo.output.data.application_livy_table_json != null) { <START> String table_result = ""; <END> for (Map header : stmtInfo.output.data.application_livy_table_json.headers) { table_result += (table_result == "" ? "" : "\t") + header.get("name"); } table_result += "\n"; for (List<Object> row : stmtInfo.output.data.application_livy_table_json.records) { String values = ""; for (Object value : row) { values += (values == "" ? "" : "\t") + value; } table_result += values + "\n"; } result = "%table " + table_result; } else if (stmtInfo.output.data.image_png != null) { return new InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.IMG, (String) stmtInfo.output.data.image_png); } else if (result != null) { result = result.trim(); if (result.startsWith("<link") || result.startsWith("<script") || result.startsWith("<style") || result.startsWith("<div")) { result = "%html " + result; } } if (displayAppInfo) { StringBuilder outputBuilder = new StringBuilder(); outputBuilder.append("%angular "); outputBuilder.append("<pre><code>"); outputBuilder.append(result); outputBuilder.append("</code></pre>"); outputBuilder.append("<hr/>"); outputBuilder.append("Spark Application Id:" + sessionInfo.appId + "<br/>"); outputBuilder.append("Spark WebUI: <a href=" + sessionInfo.webUIAddress + ">" + sessionInfo.webUIAddress + "</a>"); return new InterpreterResult(InterpreterResult.Code.SUCCESS, outputBuilder.toString()); } else { return new InterpreterResult(InterpreterResult.Code.SUCCESS, result); } } }</code><technical_language>StringBuilder</technical_language>

Target:
private InterpreterResult getResultFromStatementInfo(StatementInfo stmtInfo, boolean displayAppInfo) { if (stmtInfo.output.isError()) { return new InterpreterResult(InterpreterResult.Code.ERROR, stmtInfo.output.evalue); } else { String result = stmtInfo.output.data.plain_text; if (stmtInfo.output.data.application_livy_table_json != null) { StringBuilder outputBuilder = new StringBuilder(); boolean notFirstColumn = false; for (Map header : stmtInfo.output.data.application_livy_table_json.headers) { if (notFirstColumn) { outputBuilder.append("\t"); } outputBuilder.append(header.get("name")); notFirstColumn = true; } outputBuilder.append("\n"); for (List<Object> row : stmtInfo.output.data.application_livy_table_json.records) { outputBuilder.append(StringUtils.join(row, "\t")); outputBuilder.append("\n"); } return new InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.TABLE, outputBuilder.toString()); } else if (stmtInfo.output.data.image_png != null) { return new InterpreterResult(InterpreterResult.Code.SUCCESS, InterpreterResult.Type.IMG, (String) stmtInfo.output.data.image_png); } else if (result != null) { result = result.trim(); if (result.startsWith("<link") || result.startsWith("<script") || result.startsWith("<style") || result.startsWith("<div")) { result = "%html " + result; } } if (displayAppInfo) { StringBuilder outputBuilder = new StringBuilder(); outputBuilder.append("%angular "); outputBuilder.append("<pre><code>"); outputBuilder.append(result); outputBuilder.append("</code></pre>"); outputBuilder.append("<hr/>"); outputBuilder.append("Spark Application Id:" + sessionInfo.appId + "<br/>"); outputBuilder.append("Spark WebUI: <a href=" + sessionInfo.webUIAddress + ">" + sessionInfo.webUIAddress + "</a>"); return new InterpreterResult(InterpreterResult.Code.SUCCESS, outputBuilder.toString()); } else { return new InterpreterResult(InterpreterResult.Code.SUCCESS, result); } } }