Class SegmentSequence.Builder

java.lang.Object
org.eclipse.emf.common.util.SegmentSequence.Builder
Enclosing class:
SegmentSequence

public static final class SegmentSequence.Builder extends Object
A builder for creating a composed string or a toSegmentSequence(). It may be a more efficient alternative to StringBuilder because the strings are not copied to a character-based buffer until toString() is called. At that time, the total number of characters needed is known, so a character array can be allocated and used direct to create a string. Using the empty string as the delimiter is particularly useful for that purpose.
  • Field Details

    • delimiter

      protected final String delimiter
      The delimiter of the builder.
    • size

      protected int size
      The number of strings in the builder.
    • strings

      protected String[] strings
      The string sin the builder.
  • Constructor Details

    • Builder

      protected Builder(String delimiter, int capacity)
      Creates an instance with the given capacity.
  • Method Details

    • append

      public SegmentSequence.Builder append(String string)
      Appends a string to the builder and returns the builder itself.
    • append

      public SegmentSequence.Builder append(char c)
      Appends a string representation of the character to the builder and returns the builder itself.
    • reverse

      public SegmentSequence.Builder reverse()
      Reverses the strings in the builder and returns the builder itself.
    • toSegmentSequence

      public SegmentSequence toSegmentSequence()
      Converts the builder to a corresponding segment sequence.
    • toString

      public String toString()
      Converts the builder to a string representation, i.e,. the delimiter-separated composition of the appended strings.
      Overrides:
      toString in class Object