public class StringLinker extends Object implements CharSequence, Serializable
| 构造器和说明 |
|---|
StringLinker(CharSequence delimiter)
Constructs a
StringJoiner with no characters in it, with no
prefix or suffix, and a copy of the supplied
delimiter. |
StringLinker(CharSequence delimiter,
CharSequence prefix,
CharSequence suffix)
Constructs a
StringJoiner with no characters in it using copies
of the supplied prefix, delimiter and suffix. |
| 限定符和类型 | 方法和说明 |
|---|---|
StringLinker |
add(byte[] newElement) |
StringLinker |
add(CharSequence newElement,
int times) |
StringLinker |
add(double[] newElement) |
StringLinker |
add(float[] newElement) |
StringLinker |
add(int[] newElement) |
StringLinker |
add(long[] newElement) |
StringLinker |
add(Object newElement) |
StringLinker |
add(Object[] newElement) |
StringLinker |
add(short[] newElement) |
char |
charAt(int index) |
int |
length()
Returns the length of the
String representation
of this StringJoiner. |
StringLinker |
link(Object... newElements) |
StringLinker |
merge(StringLinker other)
Adds the contents of the given
StringJoiner without prefix and
suffix as the next element if it is non-empty. |
static StringLinker |
of() |
static StringLinker |
of(CharSequence delimiter) |
static StringLinker |
of(CharSequence delimiter,
CharSequence prefix,
CharSequence suffix) |
StringLinker |
setEmptyValue(CharSequence emptyValue)
Sets the sequence of characters to be used when determining the string
representation of this
StringJoiner and no elements have been
added yet, that is, when it is empty. |
StringLinker |
setNullElement(CharSequence defaultElementIfNull) |
CharSequence |
subSequence(int start,
int end) |
String |
toString()
Returns the current value, consisting of the
prefix, the values
added so far separated by the delimiter, and the suffix,
unless no elements have been added in which case, the
prefix + suffix or the emptyValue characters are returned |
StringLinker |
wrapper(CharSequence prefix,
CharSequence suffix) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitchars, codePointspublic StringLinker(CharSequence delimiter)
StringJoiner with no characters in it, with no
prefix or suffix, and a copy of the supplied
delimiter.
If no characters are added to the StringJoiner and methods
accessing the value of it are invoked, it will not return a
prefix or suffix (or properties thereof) in the result,
unless setEmptyValue has first been called.delimiter - the sequence of characters to be used between each
element added to the StringJoiner valueNullPointerException - if delimiter is nullpublic StringLinker(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
StringJoiner with no characters in it using copies
of the supplied prefix, delimiter and suffix.
If no characters are added to the StringJoiner and methods
accessing the string value of it are invoked, it will return the
prefix + suffix (or properties thereof) in the result, unless
setEmptyValue has first been called.delimiter - the sequence of characters to be used between each
element added to the StringJoinerprefix - the sequence of characters to be used at the beginningsuffix - the sequence of characters to be used at the endNullPointerException - if prefix, delimiter, or
suffix is nullpublic static StringLinker of()
public static StringLinker of(CharSequence delimiter)
public static StringLinker of(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
public StringLinker wrapper(CharSequence prefix, CharSequence suffix)
public StringLinker setEmptyValue(CharSequence emptyValue)
StringJoiner and no elements have been
added yet, that is, when it is empty. A copy of the emptyValue
parameter is made for this purpose. Note that once an add method has been
called, the StringJoiner is no longer considered empty, even if
the element(s) added correspond to the empty String.emptyValue - the characters to return as the value of an empty
StringJoinerStringJoiner itself so the calls may be chainedNullPointerException - when the emptyValue parameter is
nullpublic StringLinker setNullElement(CharSequence defaultElementIfNull)
public StringLinker link(Object... newElements)
public StringLinker add(Object newElement)
public StringLinker add(CharSequence newElement, int times)
public StringLinker add(byte[] newElement)
public StringLinker add(int[] newElement)
public StringLinker add(float[] newElement)
public StringLinker add(long[] newElement)
public StringLinker add(short[] newElement)
public StringLinker add(double[] newElement)
public StringLinker add(Object[] newElement)
public StringLinker merge(StringLinker other)
StringJoiner without prefix and
suffix as the next element if it is non-empty. If the given StringJoiner is empty, the call has no effect.
A StringJoiner is empty if add()
has never been called, and if merge() has never been called
with a non-empty StringJoiner argument.
If the other StringJoiner is using a different delimiter,
then elements from the other StringJoiner are concatenated with
that delimiter and the result is appended to this StringJoiner
as a single element.
other - The StringJoiner whose contents should be merged
into this oneStringJoinerNullPointerException - if the other StringJoiner is nullpublic int length()
String representation
of this StringJoiner. Note that if
no add methods have been called, then the length of the String
representation (either prefix + suffix or emptyValue)
will be returned. The value should be equivalent to
toString().length().length 在接口中 CharSequenceStringJoinerpublic char charAt(int index)
charAt 在接口中 CharSequencepublic CharSequence subSequence(int start, int end)
subSequence 在接口中 CharSequencepublic String toString()
prefix, the values
added so far separated by the delimiter, and the suffix,
unless no elements have been added in which case, the
prefix + suffix or the emptyValue characters are returnedtoString 在接口中 CharSequencetoString 在类中 ObjectStringJoinerCopyright © 2022. All rights reserved.