List of usage examples for org.apache.commons.lang3.text StrBuilder StrBuilder
public StrBuilder()
From source file:de.vandermeer.asciithemes.TA_Border_Chars.java
@Override default StrBuilder getBorder(int mode, StrBuilder builder) { StrBuilder ret = (builder == null) ? new StrBuilder() : builder; switch (mode) { case MODE_LEFT: return ret.append(this.getLeftChar()); case MODE_RIGHT: return ret.append(this.getRightChar()); default:/*from w w w .j a va2s . co m*/ return ret; } }
From source file:de.vandermeer.asciithemes.TA_Border_Strings.java
@Override default StrBuilder getBorder(int mode, StrBuilder builder) { StrBuilder ret = (builder == null) ? new StrBuilder() : builder; switch (mode) { case MODE_LEFT: return ret.append(this.getLeftString()); case MODE_RIGHT: return ret.append(this.getRightString()); default:// w w w . ja v a 2 s . c om return ret; } }
From source file:de.vandermeer.asciithemes.TA_Frame.java
/** * Returns a string containing the input collection with the requested frame. * @param coll input collection/*from w w w .j a va 2s . co m*/ * @param mode frame mode * @return string with the framed collection */ default String addFrameString(Collection<StrBuilder> coll, int mode) { return new StrBuilder().appendWithSeparators(this.addFrame(coll, mode), "\n").toString(); }
From source file:de.vandermeer.asciitable.examples.AT_00g_AddColumn_DoesRenderToWidth.java
@Override public void showOutput() { // tag::example[] AsciiTable at = new AsciiTable(); class ObjectDoesRenderToWidth implements DoesRenderToWidth { @Override/*from ww w . j av a 2 s . c om*/ public String render(int width) { return new StrBuilder().appendWithSeparators( Text_To_FormattedText.left(new LoremIpsum().getWords(10), width), "\n").toString(); } } at.addRule(); at.addRow(new ObjectDoesRenderToWidth()); at.addRule(); System.out.println(at.render(30)); // end::example[] }
From source file:de.vandermeer.asciithemes.TA_Line_String.java
/** * Returns a line of given length./*from www .java2s .c om*/ * @param length number of in the line * @param builder builder to append the line to, new builder will be created if null * @return line of given length, empty if length was null or negative */ default StrBuilder getLine(int length, StrBuilder builder) { StrBuilder append = new StrBuilder(); if (this.getLineString().length() == 0 || length == 0) { return append; } while (append.length() < (length)) { append.append(this.getLineString()); } while (append.length() > length) { append.deleteCharAt(append.length() - 1); } if (builder == null) { return append; } return builder.append(append); }
From source file:de.vandermeer.asciithemes.TA_Line_SplitChar.java
/** * Returns a line of given length./* ww w .ja va 2 s . c o m*/ * @param length number of characters in the line * @param builder builder to append the line to, new builder will be created if null * @return line of given length, empty if length was null or negative */ default StrBuilder getLine(int length, StrBuilder builder) { StrBuilder ret = new StrBuilder(); if (length < 1) { return (builder == null) ? ret : builder; } ret.appendPadding(length / 2, this.getLeftLineChar()); while (ret.length() < length) { ret.appendPadding(1, this.getRightLineChar()); } return (builder == null) ? ret : builder.append(ret); }
From source file:de.vandermeer.asciithemes.TA_Corner_Strings.java
@Override default StrBuilder getCorner(int mode, StrBuilder builder) { StrBuilder ret = (builder == null) ? new StrBuilder() : builder; switch (mode) { case TA_Corner.MODE_TOP_LEFT: return ret.append(this.getTopLeftString()); case TA_Corner.MODE_TOP_RIGHT: return ret.append(this.getTopRightString()); case TA_Corner.MODE_BOTTOM_LEFT: return ret.append(this.getBottomLeftString()); case TA_Corner.MODE_BOTTOM_RIGHT: return ret.append(this.getBottomRightString()); default:/*from ww w. j a v a 2 s . c o m*/ return ret; } }
From source file:de.vandermeer.skb.datatool.commons.DataEntrySchema.java
/** * Tests the map against the data entry schema (programmatic). * @param data original data, should be a mapping of strings to objects * @return empty on success, string builder with explanations on error *///from w w w . j a v a 2 s .c om default StrBuilder testSchema(Object data) { StrBuilder ret = new StrBuilder(); if (!(data instanceof Map)) { ret.append("test schema: input data not of type map, cannot test schema"); return ret; } Map<?, ?> map = (Map<?, ?>) data; for (Entry<EntryKey, Boolean> e : this.getKeyMap().entrySet()) { if (e.getValue() == true && !map.containsKey(e.getKey().getKey())) { ret.append("missing mandatory entry key <").append(e.getKey().getKey()).append(">").appendNewLine(); } else if (e.getValue() == true && StringUtils.isEmpty(map.get(e.getKey().getKey()).toString())) { ret.append("empty mandatory entry key <").append(e.getKey().getKey()).append(">").appendNewLine(); } } for (Object o : map.keySet()) { if (!this.getKeySet().contains(o.toString())) { ret.append("unknown entry key <").append(o).append(">").appendNewLine(); } } return ret; }
From source file:de.vandermeer.asciithemes.TA_Corner_Chars.java
@Override default StrBuilder getCorner(int mode, StrBuilder builder) { StrBuilder ret = (builder == null) ? new StrBuilder() : builder; switch (mode) { case TA_Corner.MODE_TOP_LEFT: return ret.append(this.getTopLeftChar()); case TA_Corner.MODE_TOP_RIGHT: return ret.append(this.getTopRightChar()); case TA_Corner.MODE_BOTTOM_LEFT: return ret.append(this.getBottomLeftChar()); case TA_Corner.MODE_BOTTOM_RIGHT: return ret.append(this.getBottomRightChar()); default:/*from w ww . j ava2 s. co m*/ return ret; } }
From source file:de.vandermeer.asciitable.examples.AT_00c_AddColumn_ST.java
@Override public StrBuilder getSource() { String[] source = new String[] { "ST st = new ST(new LoremIpsum().getWords(10));", "AsciiTable at = new AsciiTable();", "at.addRule();", "at.addRow(st);", "at.addRule();", "System.out.println(at.render());", }; return new StrBuilder().appendWithSeparators(source, "\n"); }