public class DefaultCharAppender extends Object implements CharAppender
CharAppender interface| Constructor and Description |
|---|
DefaultCharAppender(int maxLength,
String emptyValue,
int whitespaceRangeStart)
Creates a DefaultCharAppender with a maximum limit of characters to append and the default value to return when no characters have been accumulated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(char ch)
Appends the given character.
|
void |
append(char[] ch)
Appends characters from an input array
|
void |
append(char[] ch,
int from,
int length)
Appends characters from an input array
|
void |
append(DefaultCharAppender appender)
Appends the contents of another DefaultCharAppender, discarding any of its trailing whitespace characters
|
void |
append(int ch)
Appends the given codepoint.
|
void |
append(int[] ch)
Appends codepoints from an input array
|
void |
append(Object o)
Appends the
String representation of a given object. |
void |
append(String string)
Appends characters from an input
String |
void |
append(String string,
int from,
int to)
Appends the contents of a String to this appender
|
void |
appendIgnoringPadding(char ch,
char padding)
Appends the given character and marks it as ignored if it is a padding character (the definition of a padding character is implementation dependent.)
|
void |
appendIgnoringWhitespace(char ch)
Appends the given character and marks it as ignored if it is a whitespace (
ch <= ' ') |
void |
appendIgnoringWhitespaceAndPadding(char ch,
char padding)
Appends the given character and marks it as ignored if it is a whitespace (
ch <= ' ') or a padding character (the definition of a padding character is implementation dependent.) |
char |
appendUntil(char ch,
CharInput input,
char stop)
Appends characters from the input, until a stop character is found
|
char |
appendUntil(char ch,
CharInput input,
char stop1,
char stop2)
Appends characters from the input, until a stop character is found
|
char |
appendUntil(char ch,
CharInput input,
char stop1,
char stop2,
char stop3)
Appends characters from the input, until a stop character is found
|
char |
charAt(int i) |
void |
fill(char ch,
int length)
Adds a sequence of repeated characters to the input.
|
String |
getAndReset()
Returns the accumulated value as a String, discarding any trailing whitespace characters identified when using
appendIgnoringWhitespace(char), appendIgnoringPadding(char, char) or appendIgnoringWhitespaceAndPadding(char, char) |
char[] |
getChars()
Returns the internal character array.
|
char[] |
getCharsAndReset()
Returns the accumulated characters, discarding any trailing whitespace characters identified when using
appendIgnoringWhitespace(char), appendIgnoringPadding(char, char) or appendIgnoringWhitespaceAndPadding(char, char) |
void |
ignore(int count)
Ignores the given number of characters at the end of the appended content,
effectively marking these as whitespace.
|
int |
length()
Returns the current accumulated value length (the sum of all appended characters - whitespaceCount).
|
void |
prepend(char ch)
Prepends the current accumulated value with a character
|
void |
prepend(char[] chars)
Prepends the current accumulated value a sequence of characters
|
void |
prepend(char ch1,
char ch2)
Prepends the current accumulated value with a couple of characters
|
void |
reset()
Clears the accumulated value and the whitespace count.
|
void |
resetWhitespaceCount()
Resets the number of whitespaces accumulated after the last non-whitespace character.
|
String |
subSequence(int from,
int to) |
String |
toString()
Returns the accumulated value as a String, discarding any trailing whitespace characters identified when using
appendIgnoringWhitespace(char), appendIgnoringPadding(char, char) or appendIgnoringWhitespaceAndPadding(char, char) |
void |
updateWhitespace()
Updates the internal whitespace count of this appender to trim trailing whitespaces.
|
int |
whitespaceCount()
Returns the current number of whitespaces accumulated after the last non-whitespace character.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitchars, codePointspublic DefaultCharAppender(int maxLength,
String emptyValue,
int whitespaceRangeStart)
maxLength - maximum limit of characters to appendemptyValue - default value to return when no characters have been accumulatedwhitespaceRangeStart - starting range of characters considered to be whitespace.public void appendIgnoringPadding(char ch,
char padding)
CharAppenderappendIgnoringPadding in interface CharAppenderch - character to appendpadding - the padding character to ignorepublic void appendIgnoringWhitespaceAndPadding(char ch,
char padding)
CharAppenderch <= ' ') or a padding character (the definition of a padding character is implementation dependent.)appendIgnoringWhitespaceAndPadding in interface CharAppenderch - character to appendpadding - the padding character to ignorepublic void appendIgnoringWhitespace(char ch)
CharAppenderch <= ' ')appendIgnoringWhitespace in interface CharAppenderch - character to appendpublic void append(char ch)
CharAppenderappend in interface CharAppenderch - the character to appendpublic final void append(Object o)
CharAppenderString representation of a given object.append in interface CharAppendero - the object whose String representation will be appended.public final void append(int ch)
CharAppenderappend in interface CharAppenderch - the codepoint to appendpublic final void append(int[] ch)
CharAppenderappend in interface CharAppenderch - the codepoint arraypublic String getAndReset()
appendIgnoringWhitespace(char), appendIgnoringPadding(char, char) or appendIgnoringWhitespaceAndPadding(char, char)
The internal accumulated value is discarded after invoking this method (as in reset())
If the accumulated value is empty (i.e. no characters were appended, or all appended characters where ignored as whitespace or padding), then the return value will be emptyValue attribute defined in the constructor of this class.
getAndReset in interface CharAppenderemptyValue defined in the constructor of this class.public final String toString()
appendIgnoringWhitespace(char), appendIgnoringPadding(char, char) or appendIgnoringWhitespaceAndPadding(char, char)
Does not discard the accumulated value.
If the accumulated value is empty (i.e. no characters were appended, or all appended characters where ignored as whitespace or padding), then the return value will be emptyValue attribute defined in the constructor of this class.
toString in interface CharSequencetoString in class ObjectemptyValue defined in the constructor of this class.public final int length()
CharAppenderlength in interface CharAppenderlength in interface CharSequencepublic char[] getCharsAndReset()
appendIgnoringWhitespace(char), appendIgnoringPadding(char, char) or appendIgnoringWhitespaceAndPadding(char, char)
The internal accumulated value is discarded after invoking this method (as in reset())
If the accumulated value is empty (i.e. no characters were appended, or all appended characters where ignored as whitespace or padding), then the return value will be character sequence of the emptyValue attribute defined in the constructor of this class.
getCharsAndReset in interface CharAppenderemptyValue defined in the constructor of this class.public final int whitespaceCount()
CharAppender This is the number of whitespaces accumulated using CharAppender.appendIgnoringWhitespace(char), CharAppender.appendIgnoringPadding(char, char) or CharAppender.appendIgnoringWhitespaceAndPadding(char, char)
whitespaceCount in interface CharAppenderCharAppender.appendIgnoringWhitespace(char), CharAppender.appendIgnoringPadding(char, char) or CharAppender.appendIgnoringWhitespaceAndPadding(char, char)public void reset()
CharAppenderreset in interface CharAppenderpublic void append(DefaultCharAppender appender)
appender - The DefaultCharAppender instance got get contents from.public final void resetWhitespaceCount()
CharAppender This is the number of whitespaces accumulated using CharAppender.appendIgnoringWhitespace(char), CharAppender.appendIgnoringPadding(char, char) or CharAppender.appendIgnoringWhitespaceAndPadding(char, char)
A subsequent call to CharAppender.whitespaceCount() should return 0.
resetWhitespaceCount in interface CharAppenderpublic final char[] getChars()
CharAppendergetChars in interface CharAppenderpublic void fill(char ch,
int length)
CharAppenderfill in interface CharAppenderch - the character to appendlength - the number of times the given character should be appended.public void prepend(char ch)
prepend in interface CharAppenderch - the character to prepend in front of the current accumulated value.public void prepend(char ch1,
char ch2)
CharAppenderprepend in interface CharAppenderch1 - the first character to prepend in front of the current accumulated value.ch2 - the second character to prepend in front of the current accumulated value.public void prepend(char[] chars)
CharAppenderprepend in interface CharAppenderchars - the character sequence to prepend in front of the current accumulated value.public final void updateWhitespace()
updateWhitespace in interface CharAppenderpublic char appendUntil(char ch,
CharInput input,
char stop)
CharAppenderappendUntil in interface CharAppenderch - the first character of the input to be appended.input - the input whose the following characters will be appendedstop - the stop characterpublic char appendUntil(char ch,
CharInput input,
char stop1,
char stop2)
CharAppenderappendUntil in interface CharAppenderch - the first character of the input to be appended.input - the input whose the following characters will be appendedstop1 - the first stop characterstop2 - the second stop characterpublic char appendUntil(char ch,
CharInput input,
char stop1,
char stop2,
char stop3)
CharAppenderappendUntil in interface CharAppenderch - the first character of the input to be appended.input - the input whose the following characters will be appendedstop1 - the first stop characterstop2 - the second stop characterstop3 - the third stop characterpublic void append(char[] ch,
int from,
int length)
CharAppenderappend in interface CharAppenderch - the character arrayfrom - the position of the first character in the array to be appendedlength - the number of characters to be appended from the given posiion.public final void append(char[] ch)
CharAppenderappend in interface CharAppenderch - the character arraypublic void append(String string, int from, int to)
CharAppenderappend in interface CharAppenderstring - the string whose characters will be appended.from - the index of the first character to appendto - the index of the last character to appendpublic final void append(String string)
CharAppenderStringappend in interface CharAppenderstring - the input Stringpublic final char charAt(int i)
charAt in interface CharSequencepublic final String subSequence(int from, int to)
subSequence in interface CharSequencepublic final void ignore(int count)
CharAppenderCharAppender.resetWhitespaceCount()
or CharAppender.updateWhitespace() will undo this effect.ignore in interface CharAppendercount - the number of characters to ignoreCopyright © 2018 Univocity Software Pty Ltd. All rights reserved.