/** * Add a newline to this sequence according to the configured lineDelimiter. */ public void newLine() { growSegments(1); segments.add(lineDelimiter); cachedToString = null; }
private void appendSegment(int index, String segment) { growSegments(1); segments.add(index, segment); cachedToString = null; }
/** * 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>. * @since 2.5 */ protected void appendSegments(int index, List<String> otherSegments) { growSegments(otherSegments.size()); if (segments.addAll(index, otherSegments)) { cachedToString = null; } }
/** * 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 indentation * the indentation string that should be prepended. May not be <code>null</code>. * @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. */ protected void appendSegments(String indentation, int index, List<String> otherSegments, String otherDelimiter) { if (otherSegments.isEmpty()) { return; } // This may not be accurate, but it's better than nothing growSegments(otherSegments.size()); for (String otherSegment : otherSegments) { if (otherDelimiter.equals(otherSegment)) { segments.add(index++, lineDelimiter); segments.add(index++, indentation); } else { segments.add(index++, otherSegment); } } cachedToString = null; }
/** * 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; } }