Refine search
private static String string(Consumer<IndentedLineBuffer> action) { IndentedLineBuffer x = new IndentedLineBuffer() ; action.accept(x); return x.asString() ; }
@Override public String toString() { IndentedLineBuffer out = new IndentedLineBuffer() ; SerializationContext sCxt = SSE.sCxt((SSE.getPrefixMapWrite())) ; boolean first = true ; for (Quad quad : quads) { if ( !first ) out.print(" ") ; else first = false ; // Adds (quad ...) // SSE.write(buff.getIndentedWriter(), t) ; out.print("(") ; WriterNode.outputPlain(out, quad, sCxt) ; out.print(")") ; } out.flush() ; return out.toString() ; } }
@Override public String toPrefixString() { IndentedLineBuffer x = new IndentedLineBuffer() ; x.append("(") ; x.append(getName().toLowerCase(Locale.ROOT)) ; x.incIndent(); if ( isDistinct ) x.append(" distinct") ; for ( Expr e : getExprList() ) { x.append(" "); WriterExpr.output(x, e, null) ; } x.decIndent(); x.append(")") ; return x.asString() ; }
/** JsonValue to a string with no newlines */ public static String toStringFlat(JsonValue jValue) { try ( IndentedLineBuffer b = new IndentedLineBuffer() ) { b.setFlatMode(true); JSON.write(b, jValue); return b.asString() ; } }
public static String strNodes(Node ... nodes) { IndentedLineBuffer sw = new IndentedLineBuffer() ; boolean first = true ; for ( Node n : nodes ) { if ( ! first ) sw.append(" ") ; first = false ; str(sw, n) ; } return sw.toString() ; }
public static String str(Node n) { IndentedLineBuffer sw = new IndentedLineBuffer() ; str(sw, n) ; return sw.toString() ; }
/** * Gets user friendly version information for all registered classes as a string * @param singleLine Whether to print to a single line * @return Version information */ public String toString(boolean singleLine) { try ( IndentedLineBuffer buffer = new IndentedLineBuffer(false) ) { Iterator<Class<?>> iter = classes.iterator(); while (iter.hasNext()) { Class<?> c = iter.next(); String component = Lib.classShortName(c) ; String version = field(FIELD_VERSION, c); String timestamp = field(FIELD_BUILD_DATE, c); buffer.append("%s Version %s (Built %s)", component, version, timestamp); if (iter.hasNext()) { if (!singleLine) { buffer.println(); } else { buffer.print(", "); } } } return buffer.asString(); } }
public static void output(ServletOutputStream outStream, Consumer<IndentedLineBuffer> content, boolean lineNumbers) throws IOException { startFixed(outStream) ; IndentedLineBuffer out = new IndentedLineBuffer(lineNumbers) ; content.accept(out) ; out.flush() ; String x = htmlQuote(out.asString()) ; byte b[] = x.getBytes("UTF-8") ; outStream.write(b) ; finishFixed(outStream) ; }
@Test public void write06() { try (IndentedLineBuffer b = new IndentedLineBuffer()) { b.setLinePrefix("@."); b.println("ABCD") ; b.print("XYZ") ; assertEquals("@.ABCD\n@.XYZ", b.asString()) ; } }
@Test public void write04() { try (IndentedLineBuffer b = new IndentedLineBuffer()) { b.setLineNumbers(true); b.setNumberWidth(5); b.println("ABCD") ; b.print("XYZ") ; assertEquals(" 1 ABCD\n 2 XYZ", b.asString()) ; } }
public static void explain(String message, BasicPattern bgp, Context context) { if ( explaining(InfoLevel.ALL, logExec, context) ) { try (IndentedLineBuffer iBuff = new IndentedLineBuffer()) { if ( MultiLinesForPatterns ) iBuff.incIndent() ; formatTriples(iBuff, bgp) ; iBuff.flush() ; String str = iBuff.toString() ; _explain(logExec, message, str, false) ; } } }
@Override public String toString() { IndentedLineBuffer out = new IndentedLineBuffer() ; SerializationContext sCxt = SSE.sCxt(SSE.getPrefixMapString()) ; boolean first = true ; for ( Triple t : triples ) { if ( !first ) out.print("\n") ; else first = false ; // Adds (triple ...) // SSE.write(buff.getIndentedWriter(), t) ; out.print("(") ; WriterNode.outputPlain(out, t, sCxt) ; out.print(")") ; } out.flush() ; return out.toString() ; } }
protected static String asSparqlExpr(boolean isDistinct, String separator, ExprList exprs, SerializationContext sCxt) { IndentedLineBuffer x = new IndentedLineBuffer() ; x.append("GROUP_CONCAT(") ; if ( isDistinct ) x.append("DISTINCT ") ; ExprUtils.fmtSPARQL(x, exprs, sCxt) ; if ( separator != null ) { x.append(" ; separator=") ; String y = StrUtils.escapeString(separator) ; x.append("'") ; x.append(y) ; x.append("'") ; } x.append(")") ; return x.asString() ; }
@Override public String toString() { IndentedLineBuffer out = new IndentedLineBuffer() ; SerializationContext sCxt = SSE.sCxt((SSE.defaultPrefixMapWrite)) ; boolean first = true ; for (Quad quad : quads) { if ( !first ) out.print(" ") ; else first = false ; // Adds (triple ...) // SSE.write(buff.getIndentedWriter(), t) ; out.print("(") ; WriterNode.outputPlain(out, quad, sCxt) ; out.print(")") ; } out.flush() ; return out.toString() ; } }
@Test public void write05() { try (IndentedLineBuffer b = new IndentedLineBuffer()) { b.setLineNumbers(true); b.println("ABCD") ; b.println("XYZ") ; assertEquals(" 1 ABCD\n 2 XYZ\n", b.asString()) ; } }
public static void explain(String message, Op op, Context context) { if ( explaining(InfoLevel.FINE, logExec, context) ) { try (IndentedLineBuffer iBuff = new IndentedLineBuffer()) { if ( MultiLinesForOps ) iBuff.incIndent() ; else iBuff.setFlatMode(true) ; op.output(iBuff) ; String x = iBuff.asString() ; _explain(logExec, message, x, true) ; } } }
@Test public void write01() { try (IndentedLineBuffer b = new IndentedLineBuffer()) { b.print("hell") ; b.print("o") ; assertEquals("hello", b.asString()) ; } }
@Test public void testFormatBGP_1() { IndentedLineBuffer b = new IndentedLineBuffer() ; BasicPattern bgp = SSE.parseBGP("(prefix ((zz: <"+aUri+">)) (bgp (zz:s zz:p zz:o)))") ; FmtUtils.formatPattern(b, bgp, getContext()) ; assertEquals("zz:s zz:p zz:o .", b.toString()) ; }