public class FastStreamReplacer
extends java.lang.Object
This class is a single-pass fast no wildcards replacer for a given set of substrings.
It is primarily designed for mail merge document personalization routines, where a small number of substrings have to be replaced at a master document with data retrieved from a list or database.
Constructor and Description |
---|
FastStreamReplacer() |
FastStreamReplacer(int iBufferSize) |
Modifier and Type | Method and Description |
---|---|
static java.util.HashMap |
createMap(java.lang.String[] aKeys,
java.lang.String[] aValues)
Create a HashMap for a couple of String Arrays
This method is just a convenient shortcut for creating input HashMap for
replace methods from this class
|
int |
lastReplacements()
Number of replacements done in last call to replace() method.
|
java.lang.String |
replace(java.io.InputStream oFileInStream,
java.util.HashMap oMap)
Replace subtrings from a Stream.
|
java.lang.String |
replace(java.lang.StringBuffer oStrBuff,
java.util.HashMap oMap)
Replace subtrings from a Stream.
|
java.lang.String |
replace(java.lang.String sFilePath,
java.util.HashMap oMap)
Replace substrings from a Text File.
|
public FastStreamReplacer()
public FastStreamReplacer(int iBufferSize)
public java.lang.String replace(java.io.InputStream oFileInStream, java.util.HashMap oMap) throws java.io.IOException
oInStream
- Input Stream containing substrings to be replaced.oMap
- Map with values to be replaced.java.io.IOException
public java.lang.String replace(java.lang.StringBuffer oStrBuff, java.util.HashMap oMap) throws java.io.IOException, java.lang.IndexOutOfBoundsException
oInStream
- Input Stream containing substrings to be replaced.oMap
- Map with values to be replaced.java.io.IOException
java.lang.IndexOutOfBoundsException
public java.lang.String replace(java.lang.String sFilePath, java.util.HashMap oMap) throws java.io.IOException
sFilePath
- File containing text to be replaced.oMap
- Map with values to be replaced.java.io.IOException
public int lastReplacements()
public static java.util.HashMap createMap(java.lang.String[] aKeys, java.lang.String[] aValues) throws java.lang.ArrayIndexOutOfBoundsException
Create a HashMap for a couple of String Arrays
This method is just a convenient shortcut for creating input HashMap for replace methods from this classaKeys
- An array of Strings to be used as keysaValues
- An array of Strings that will be the actual values for the keysjava.lang.ArrayIndexOutOfBoundsException