Class TwineBuilder

java.lang.Object
net.sf.saxon.str.TwineBuilder

public abstract class TwineBuilder extends Object
A builder class for unicode strings. This is a simpler and more efficient alternative to UnicodeBuilder for use when small strings (especially strings consisting exclusively of 8-bit characters) are constructed one character at a time.
  • Constructor Details

    • TwineBuilder

      public TwineBuilder()
  • Method Details

    • make

      public static TwineBuilder make(int initialSize)
      Create a builder for strings with an estimate of the string size
      Parameters:
      initialSize - the expected size of the string, once built
      Returns:
      a new builder
    • append

      public abstract TwineBuilder append(int codepoint)
      Append a codepoint to the Unicode string
      Parameters:
      codepoint - the codepoint to be appended
      Returns:
      a replacement builder. NOTE: although this will often be the original builder, it will sometimes be a new one, so it is important to use the returned builder for future calls.
    • append

      public final TwineBuilder append(CharSequence chars)
      Append a string or other CharSequence
      Parameters:
      chars - the string to be appended
      Returns:
      the new TwineBuilder to be used for subsequent calls
    • append

      public TwineBuilder append(UnicodeString chars)
      Append a unicode string
      Parameters:
      chars - the string to be appended
      Returns:
      the new TwineBuilder to be used for subsequent calls
    • length

      public abstract int length()
      Get the length, in codepoints
      Returns:
      the length in codepoints
    • isEmpty

      public boolean isEmpty()
      Ask if the buffer is empty
      Returns:
      true if it is empty
    • toUnicodeString

      public abstract UnicodeString toUnicodeString()
      Get the completed Unicode string
      Returns:
      the unicode string that has been built.
    • toString

      public final String toString()
      Get the completed result as a Java string
      Overrides:
      toString in class Object
      Returns:
      the string that has been built.