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
Builder class for constructing CharsWrappers.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(int initialCapacity) Creates a new CharsWrapper's builder with the specified initial capacity. -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) append(char... chars) Appends a char array to this builder.append(char[] chars, int begin, int end) Appends a portion of a char array to this builder.append(CharsWrapper cw) Appends a CharsWrapper to this builder.append(CharSequence csq) append(CharSequence csq, int start, int end) Appends the string representation of an object to this builder.Appends multiple objects to this builder.Appends a String to this builder.Appends a String to this builder.build()Builds a CharsWrapper with the content of this builder.build(int start) Builds a CharsWrapper with the content of this builder.build(int start, int end) Builds a CharsWrapper with the content of this builder.voidclose()voidcompact()Compacts this builder, minimizing its size in memory.Builds a CharsWrapper with a copy of the content of this builder.copyAndBuild(int start) Builds a CharsWrapper with a copy of the content of this builder.copyAndBuild(int start, int end) Builds a CharsWrapper with a copy of the content of this builder.voidflush()charget(int index) char[]getChars()Gets the underlying array of this builder.intlength()Gets the length (number of characters) of this builder.voidset(int index, char ch) Sets the value of a character.toString()toString(int start) toString(int start, int end) voidwrite(char c) Writes a character.voidwrite(char... cbuf) Writes an array of characters.voidwrite(char[] chars, int offset, int length) Writes a portion of an array of characters.voidwrite(int c) voidwrite(CharsWrapper cw) Writes all the characters in the given CharsWrapper.voidWrites all the characters in the given String.voidWrites a portion of a String.Methods inherited from class java.io.Writer
nullWriter
-
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
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
Appends a char array to this builder.- Parameters:
chars- the array to append, not null- Returns:
- this builder
-
append
Appends a portion of a char array to this builder.- Parameters:
chars- the array to append, not nullbegin- the index to start atend- the index to stop at (exclusive)- Returns:
- this builder
-
append
Appends a String to this builder.- Parameters:
str- the String to append, not null- Returns:
- this builder
-
append
Appends a String to this builder.- Parameters:
str- the String to append, not nullbegin- the index to start atend- the index to stop at (exclusive)- Returns:
- this builder
-
append
Appends a CharsWrapper to this builder.- Parameters:
cw- the wrapper to append, not null- Returns:
- this builder
-
append
Appends the string representation of an object to this builder. This is equivalent toappend(String.valueOf(o)).- Parameters:
o- the object to append, may be null- Returns:
- this builder
-
append
Appends multiple objects to this builder. This is equivalent to callingappend(String.valueOf(o))in a loop.- Parameters:
objects- the objects to append, may be null- Returns:
- this builder
-
flush
public void flush() -
close
public void close() -
write
public void write(int c) -
write
public void write(char c) Description copied from interface:CharacterOutputWrites a character.- Specified by:
writein interfaceCharacterOutput- Parameters:
c- the character to write
-
write
public void write(char... cbuf) Description copied from interface:CharacterOutputWrites an array of characters.- Specified by:
writein interfaceCharacterOutput- Overrides:
writein classWriter- Parameters:
cbuf- the characters to write
-
write
public void write(char[] chars, int offset, int length) Description copied from interface:CharacterOutputWrites a portion of an array of characters.- Specified by:
writein interfaceCharacterOutput- Specified by:
writein classWriter- Parameters:
chars- the characters to writeoffset- the index to start atlength- the number of characters to write
-
write
Description copied from interface:CharacterOutputWrites all the characters in the given String.- Specified by:
writein interfaceCharacterOutput- Overrides:
writein classWriter- Parameters:
str- the string to write
-
write
Description copied from interface:CharacterOutputWrites a portion of a String.- Specified by:
writein interfaceCharacterOutput- Overrides:
writein classWriter- Parameters:
s- the string to writeoffset- the index to start atlength- the number of characters to write
-
write
Description copied from interface:CharacterOutputWrites all the characters in the given CharsWrapper.- Specified by:
writein interfaceCharacterOutput- 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
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
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
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 useend- index after the last character to use- Returns:
- a new CharsWrapper with the content of this builder
-
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
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
Builds a CharsWrapper with a copy of the content of this builder.- Parameters:
start- index of the 1st character to useend- index after the last character to use- Returns:
- a new CharsWrapper with a copy of the content of this builder
-
toString
-
toString
-
toString
-