/** * Append the contents of a given StringConcatenation to this sequence. Does nothing * if the concatenation is <code>null</code>. * * @param concat * the to-be-appended StringConcatenation. * @since 2.11 */ public void append(StringConcatenation concat) { if (concat != null) appendSegments(segments.size(), concat.getSignificantContent(), concat.lineDelimiter); }
appendSegments(index, otherSegments); } else { if (otherSegments.isEmpty()) {
/** * Add the list of segments to this sequence at the given index. The given indentation will be prepended to each * line except the first one if the object has a multi-line string representation. * * @param index * the index in this instance's list of segments. * @param otherSegments * the to-be-appended segments. May not be <code>null</code>. * @param otherDelimiter * the line delimiter that was used in the otherSegments list. * @since 2.5 */ protected void appendSegments(int index, List<String> otherSegments, String otherDelimiter) { if (otherDelimiter.equals(lineDelimiter)) { appendSegments(index, otherSegments); } else { if (otherSegments.isEmpty()) { return; } growSegments(otherSegments.size()); for (String otherSegment : otherSegments) { if (otherDelimiter.equals(otherSegment)) { segments.add(index++, lineDelimiter); } else { segments.add(index++, otherSegment); } } cachedToString = null; } }
/** * Append the contents of a given StringConcatenation to this sequence. Does nothing * if the concatenation is <code>null</code>. The given indentation will be prepended to each line except * the first one. * * @param concat * the to-be-appended StringConcatenation. * @param indentation * the indentation string that should be prepended. May not be <code>null</code>. * @since 2.11 */ public void append(StringConcatenation concat, String indentation) { if (indentation.isEmpty()) { append(concat); } else if (concat != null) appendSegments(indentation, segments.size(), concat.getSignificantContent(), concat.lineDelimiter); }
private void append(String indentation, String text, int index) { final int initial = initialSegmentSize(text); if (initial == text.length()) { appendSegment(index, text); } else { appendSegments(indentation, index, continueSplitting(text, initial), lineDelimiter); } }
private void append(String text, int index) { final int initial = initialSegmentSize(text); if (initial == text.length()) { appendSegment(index, text); } else { appendSegments(index, continueSplitting(text, initial)); } }
/** * Add the string representation of the given object to this sequence at the given index. Does nothing if the object * is <code>null</code>. * * @param object * the to-be-appended object. * @param index * the index in the list of segments. */ protected void append(Object object, int index) { if (object == null) return; if (object instanceof StringConcatenation) { StringConcatenation other = (StringConcatenation) object; appendSegments(index, other.getSignificantContent(), other.lineDelimiter); return; } else if (object instanceof StringConcatenationClient) { StringConcatenationClient other = (StringConcatenationClient) object; other.appendTo(new SimpleTarget(this, index)); return; } else { String value = getStringRepresentation(object); List<String> newSegments = splitLinesAndNewLines(value); appendSegments(index, newSegments, lineDelimiter); } }
StringConcatenation other = (StringConcatenation) object; List<String> otherSegments = other.getSignificantContent(); appendSegments(indentation, index, otherSegments, other.lineDelimiter); } else if (object instanceof StringConcatenationClient) { StringConcatenationClient other = (StringConcatenationClient) object; String value = getStringRepresentation(object); List<String> newSegments = splitLinesAndNewLines(value); appendSegments(indentation, index, newSegments, lineDelimiter);
protected void append(Object object, int index) { if (object == null) return; if (object instanceof String) { append((String) object, index); } else if (object instanceof StringConcatenation) { StringConcatenation other = (StringConcatenation) object; appendSegments(index, other.getSignificantContent(), other.lineDelimiter); } else if (object instanceof StringConcatenationClient) { StringConcatenationClient other = (StringConcatenationClient) object; other.appendTo(new SimpleTarget(this, index)); } else { final String text = getStringRepresentation(object); if (text != null) { append(text, index); } } }
StringConcatenation other = (StringConcatenation) object; List<String> otherSegments = other.getSignificantContent(); appendSegments(indentation, index, otherSegments, other.lineDelimiter); } else if (object instanceof StringConcatenationClient) { StringConcatenationClient other = (StringConcatenationClient) object;