|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.schmant.support.text.TextReplacer
public class TextReplacer
The text replacer uses one or several PatternAndStrategy
objects to
replace text in a text file.
Field Summary | |
---|---|
static int |
DEFAULT_BUFFER_SIZE
|
Constructor Summary | |
---|---|
TextReplacer(Collection<? extends PatternAndStrategy> replaces)
Create a new text replacer. |
|
TextReplacer(Collection<? extends PatternAndStrategy> replaces,
Charset inputEncoding,
Charset outputEncoding,
int bufSize)
Create a new text replacer. |
|
TextReplacer(Collection<? extends PatternAndStrategy> replaces,
Charset inputEncoding,
Charset outputEncoding,
int bufSize,
boolean errorIfReplaceNotFound)
Create a new text replacer. |
Method Summary | |
---|---|
void |
replace(ReadableFile source,
WritableFile target)
Run the replaces on the source file and put the result in the target file. |
void |
replace(ReadableFile source,
WritableFile target,
DirectoryView tempFilesDir,
int maxNoOfReplacesPerPattern)
Run the replaces on the source file and put the result in the target file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BUFFER_SIZE
Constructor Detail |
---|
public TextReplacer(Collection<? extends PatternAndStrategy> replaces)
replaces
- A collection of PatternAndStrategy
objects that
are used to replace text. The replaces are run in the order that they are
returned when iterating over the collection.public TextReplacer(Collection<? extends PatternAndStrategy> replaces, Charset inputEncoding, Charset outputEncoding, int bufSize) throws IllegalArgumentException
replaces
- A collection of PatternAndStrategy
objects that
are used to replace text. The replaces are run in the order that they are
returned when iterating over the collection.inputEncoding
- The character encoding for source files. Set this to
null
to use the platform's default encoding.outputEncoding
- The character encoding for target files (the files
where replace results are written to). Set to null
to use the
platform's default encoding.bufSize
- The size of internal in-memory buffers used by this
object.
IllegalArgumentException
- If the buffer size is less than 1
.public TextReplacer(Collection<? extends PatternAndStrategy> replaces, Charset inputEncoding, Charset outputEncoding, int bufSize, boolean errorIfReplaceNotFound) throws IllegalArgumentException
replaces
- A collection of PatternAndStrategy
objects that
are used to replace text. The replaces are run in the order that they are
returned when iterating over the collection.inputEncoding
- The character encoding for source files. Set this to
null
to use the platform's default encoding.outputEncoding
- The character encoding for target files (the files
where replace results are written to). Set to null
to use the
platform's default encoding.bufSize
- The size of internal in-memory buffers used by this
object.errorIfReplaceNotFound
- If a replace is not found, is that an
error?
IllegalArgumentException
- If the buffer size is less than 1
.Method Detail |
---|
public void replace(ReadableFile source, WritableFile target) throws WrappedIOException, ReplaceNotFoundException
source
- The source file.target
- The target file.
WrappedIOException
- On I/O errors.
ReplaceNotFoundException
- If one text to replace was not found and
this object is configured to treat that as an error.public void replace(ReadableFile source, WritableFile target, DirectoryView tempFilesDir, int maxNoOfReplacesPerPattern) throws WrappedIOException, ReplaceNotFoundException
source
- The source file.target
- The target file.tempFilesDir
- A directory for temporary files. If there is more
than one replace, the intermediate results are stored in temporary files
in that directory. Set this to null
to use the default temporary
files directory.maxNoOfReplacesPerPattern
- Don't replace text more than this number
of times for each pattern, even if more strings match. Set this to
-1
for an unlimited number of replaces.
WrappedIOException
- On I/O errors.
ReplaceNotFoundException
- If one text to replace was not found and
this object is configured to treat that as an error.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |