public class PreparedString
extends java.lang.Object
Invocation of the toString(String[]) method will resolve
the placeholders to the elements of the string array.
If the string array contains too few elements, placeholders characters will
be left in the output string. If the string array contains too many elements,
the superfluous elements will not be inserted in the output string.
Note:
Relationship between PreparedString
and VariableString:
PreparedString uses positional
parameters to replace placeholders with the elements of a string array.
VariableString uses named
parameters to replace placeholders with real values from a map.
| Constructor and Description |
|---|
PreparedString(java.lang.String p)
Constructs an instance with the given source string and "?" as
the placeholder character for later insertions.
|
PreparedString(java.lang.String p,
char placeholder)
Constructs an instance with the given source string and the given
placeholder character.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String[] pieces)
Returns a version of the original source string where the
placeholders have been replaced with the given string elements.
|
public PreparedString(java.lang.String p)
p - pattern like "my name is ?"public PreparedString(java.lang.String p,
char placeholder)
p - pattern like "my name is ?" (if the placeholder is "?")