|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcommon.SubstringReplacer
public class SubstringReplacer
A SubstringReplacer is an engine for replacing substrings of a given string.
The user specifies an original string and a set of (beginIndex, endIndex,
replacement) triples; then the getResult
method returns a
version of the original string where the specified substrings are replaced
with the specified replacements.
Constructor Summary | |
---|---|
SubstringReplacer()
Creates a new SubstringReplacer. |
|
SubstringReplacer(java.lang.String orig)
Creates a new SubstringReplacer with the given original string. |
Method Summary | |
---|---|
void |
addReplacement(int begin,
int end,
java.lang.String repl)
Adds an operation to replace the substring [begin, end) of the original string with the given replacement string. |
java.lang.String |
getResult()
Returns the string obtained by taking the original string specified in the last call to reset , and applying all the substring
replacement operations specified using addReplacement
since the last call to reset . |
static void |
main(java.lang.String[] args)
|
void |
reset(java.lang.String orig)
Sets the original string to the orig , and clears the
set of replacement operations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SubstringReplacer()
reset
method; if you call
addReplacement
or getResult
before
reset
, an IllegalStateException will be thrown.
public SubstringReplacer(java.lang.String orig)
Method Detail |
---|
public void reset(java.lang.String orig)
orig
, and clears the
set of replacement operations.
public void addReplacement(int begin, int end, java.lang.String repl)
public java.lang.String getResult()
reset
, and applying all the substring
replacement operations specified using addReplacement
since the last call to reset
.
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |