@NotThreadSafe public class NonBlockingStringWriter extends Writer implements IHasSize, Serializable
StringWriter.StringBuilder instead of StringBuffer and therefore
does not need synchronized access!StringWriter,
Serialized Form| Constructor and Description |
|---|
NonBlockingStringWriter()
Create a new string writer using the default initial string-buffer size.
|
NonBlockingStringWriter(int nInitialSize)
Create a new string writer using the specified initial string-buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
NonBlockingStringWriter |
append(char c)
Appends the specified character to this writer.
|
NonBlockingStringWriter |
append(CharSequence aCS)
Appends the specified character sequence to this writer.
|
NonBlockingStringWriter |
append(CharSequence aCS,
int nStart,
int nEnd)
Appends a subsequence of the specified character sequence to this writer.
|
void |
close()
Closing a StringWriter has no effect.
|
StringBuilder |
directGetStringBuilder() |
void |
flush()
Flush the stream.
|
char[] |
getAsCharArray() |
String |
getAsString() |
boolean |
isEmpty() |
void |
reset()
Remove all content of the buffer.
|
int |
size() |
String |
toString()
Deprecated.
Use getAsString instead
|
void |
write(char[] aBuf,
int nOfs,
int nLen)
Write a portion of an array of characters.
|
void |
write(int c)
Write a single character.
|
void |
write(String sStr)
Write a string.
|
void |
write(String sStr,
int nOfs,
int nLen)
Write a portion of a string.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisNotEmptypublic NonBlockingStringWriter()
public NonBlockingStringWriter(@Nonnegative int nInitialSize)
nInitialSize - The number of char values that will fit into this buffer
before it is automatically expandedIllegalArgumentException - If initialSize is negativepublic void write(@Nonnull char[] aBuf, @Nonnegative int nOfs, @Nonnegative int nLen)
public NonBlockingStringWriter append(CharSequence aCS)
An invocation of this method of the form out.append(csq) behaves in exactly the same way as the invocation
out.write (csq.toString ())
Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. For instance, invoking the toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.
append in interface Appendableappend in class WriteraCS - The character sequence to append. If csq is null,
then the four characters "null" are appended to this writer.public NonBlockingStringWriter append(CharSequence aCS, int nStart, int nEnd)
An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation
out.write (csq.subSequence (start, end).toString ())
append in interface Appendableappend in class WriteraCS - The character sequence from which a subsequence will be appended. If
csq is null, then characters will be appended as if
csq contained the four characters "null".nStart - The index of the first character in the subsequencenEnd - The index of the character following the last character in the
subsequenceIndexOutOfBoundsException - If start or end are negative, start is
greater than end, or end is greater than
csq.length()public NonBlockingStringWriter append(char c)
An invocation of this method of the form out.append(c) behaves in exactly the same way as the invocation
out.write (c)
append in interface Appendableappend in class Writerc - The 16-bit character to appendpublic void flush()
public void close()
@Nonnull @ReturnsMutableObject(value="design") public StringBuilder directGetStringBuilder()
null. Handle with
care!@Nonnull @ReturnsMutableCopy public char[] getAsCharArray()
public void reset()
@Nonnegative public int size()
public boolean isEmpty()
isEmpty in interface IHasSizetrue if no items are present, false if at
least a single item is present.IHasSize.size(),
IHasSize.isNotEmpty()@Deprecated public String toString()
Copyright © 2014–2019 Philip Helger. All rights reserved.