Class CharsWrapper.Builder

java.lang.Object
java.io.Writer
com.electronwill.nightconfig.core.io.CharsWrapper.Builder
All Implemented Interfaces:
CharacterOutput, Closeable, Flushable, Appendable, AutoCloseable
Enclosing class:
CharsWrapper

public static final class CharsWrapper.Builder extends Writer implements CharacterOutput
Builder class for constructing CharsWrappers.
  • Constructor Details

    • Builder

      public Builder(int initialCapacity)
      Creates a new CharsWrapper's builder with the specified initial capacity. If the specified capacity is less than 2 then 2 will be used instead.
      Parameters:
      initialCapacity - the initial capacity
  • Method Details

    • append

      public CharsWrapper.Builder append(char c)
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
    • append

      public CharsWrapper.Builder append(CharSequence csq)
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
    • append

      public CharsWrapper.Builder append(CharSequence csq, int start, int end)
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
    • append

      public CharsWrapper.Builder append(char... chars)
      Appends a char array to this builder.
      Parameters:
      chars - the array to append, not null
      Returns:
      this builder
    • append

      public CharsWrapper.Builder append(char[] chars, int begin, int end)
      Appends a portion of a char array to this builder.
      Parameters:
      chars - the array to append, not null
      begin - the index to start at
      end - the index to stop at (exclusive)
      Returns:
      this builder
    • append

      public CharsWrapper.Builder append(String str)
      Appends a String to this builder.
      Parameters:
      str - the String to append, not null
      Returns:
      this builder
    • append

      public CharsWrapper.Builder append(String str, int begin, int end)
      Appends a String to this builder.
      Parameters:
      str - the String to append, not null
      begin - the index to start at
      end - the index to stop at (exclusive)
      Returns:
      this builder
    • append

      public CharsWrapper.Builder append(CharsWrapper cw)
      Appends a CharsWrapper to this builder.
      Parameters:
      cw - the wrapper to append, not null
      Returns:
      this builder
    • append

      public CharsWrapper.Builder append(Object o)
      Appends the string representation of an object to this builder. This is equivalent to append(String.valueOf(o)).
      Parameters:
      o - the object to append, may be null
      Returns:
      this builder
    • append

      public CharsWrapper.Builder append(Object... objects)
      Appends multiple objects to this builder. This is equivalent to calling append(String.valueOf(o)) in a loop.
      Parameters:
      objects - the objects to append, may be null
      Returns:
      this builder
    • flush

      public void flush()
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class Writer
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Writer
    • write

      public void write(int c)
      Overrides:
      write in class Writer
    • write

      public void write(char c)
      Description copied from interface: CharacterOutput
      Writes a character.
      Specified by:
      write in interface CharacterOutput
      Parameters:
      c - the character to write
    • write

      public void write(char... cbuf)
      Description copied from interface: CharacterOutput
      Writes an array of characters.
      Specified by:
      write in interface CharacterOutput
      Overrides:
      write in class Writer
      Parameters:
      cbuf - the characters to write
    • write

      public void write(char[] chars, int offset, int length)
      Description copied from interface: CharacterOutput
      Writes a portion of an array of characters.
      Specified by:
      write in interface CharacterOutput
      Specified by:
      write in class Writer
      Parameters:
      chars - the characters to write
      offset - the index to start at
      length - the number of characters to write
    • write

      public void write(String str)
      Description copied from interface: CharacterOutput
      Writes all the characters in the given String.
      Specified by:
      write in interface CharacterOutput
      Overrides:
      write in class Writer
      Parameters:
      str - the string to write
    • write

      public void write(String s, int offset, int length)
      Description copied from interface: CharacterOutput
      Writes a portion of a String.
      Specified by:
      write in interface CharacterOutput
      Overrides:
      write in class Writer
      Parameters:
      s - the string to write
      offset - the index to start at
      length - the number of characters to write
    • write

      public void write(CharsWrapper cw)
      Description copied from interface: CharacterOutput
      Writes all the characters in the given CharsWrapper.
      Specified by:
      write in interface CharacterOutput
      Parameters:
      cw - the CharsWrapper to write
    • length

      public int length()
      Gets the length (number of characters) of this builder.
      Returns:
      the length of this builder
    • getChars

      public char[] getChars()
      Gets the underlying array of this builder. Please note that its size may not be equal to the length of the builder.
      Returns:
      the array containing the characters of this builder.
    • get

      public char get(int index)
      Parameters:
      index - the character's index (the first character is at index 0)
      Returns:
      the character at the specified index
    • set

      public void set(int index, char ch)
      Sets the value of a character.
      Parameters:
      index - the character's index (the first character is at index 0)
      ch - the character value to set
    • compact

      public void compact()
      Compacts this builder, minimizing its size in memory.
    • build

      public CharsWrapper build()
      Builds a CharsWrapper with the content of this builder. The builder's content is directly used to create a new CharsWrapper.
      Returns:
      a new CharsWrapper with the content of this builder
    • build

      public CharsWrapper build(int start)
      Builds a CharsWrapper with the content of this builder. The builder's content is directly used to create a new CharsWrapper.
      Parameters:
      start - index of the 1st character to use
      Returns:
      a new CharsWrapper with the content of this builder
    • build

      public CharsWrapper build(int start, int end)
      Builds a CharsWrapper with the content of this builder. The builder's content is directly used to create a new CharsWrapper.
      Parameters:
      start - index of the 1st character to use
      end - index after the last character to use
      Returns:
      a new CharsWrapper with the content of this builder
    • copyAndBuild

      public CharsWrapper copyAndBuild()
      Builds a CharsWrapper with a copy of the content of this builder.
      Returns:
      a new CharsWrapper with a copy of the content of this builder
    • copyAndBuild

      public CharsWrapper copyAndBuild(int start)
      Builds a CharsWrapper with a copy of the content of this builder.
      Parameters:
      start - index of the 1st character to use
      Returns:
      a new CharsWrapper with a copy of the content of this builder
    • copyAndBuild

      public CharsWrapper copyAndBuild(int start, int end)
      Builds a CharsWrapper with a copy of the content of this builder.
      Parameters:
      start - index of the 1st character to use
      end - index after the last character to use
      Returns:
      a new CharsWrapper with a copy of the content of this builder
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(int start)
    • toString

      public String toString(int start, int end)