Class Strings.BoundedDelimitedStringCollector

java.lang.Object
org.elasticsearch.common.Strings.BoundedDelimitedStringCollector
Enclosing class:
Strings

public static final class Strings.BoundedDelimitedStringCollector extends Object
Collects a sequence of objects into a delimited string, dropping objects once the string reaches a certain maximum length. Similar to Strings.collectionToDelimitedStringWithLimit(java.lang.Iterable<?>, java.lang.String, int, java.lang.StringBuilder) except that this doesn't need the collection of items to be provided up front.
  • Constructor Details

    • BoundedDelimitedStringCollector

      public BoundedDelimitedStringCollector(StringBuilder stringBuilder, String delimiter, int appendLimit)
  • Method Details

    • appendItem

      public void appendItem(Object item)
      Add the given item's string representation to the string, with a delimiter if necessary and surrounded by the given prefix and suffix, as long as the string is not already too long.
    • finish

      public void finish()
      Complete the collection, adding to the string a summary of omitted objects, if any.