| |
|
| java.lang.Object com.knowgate.dataxslt.FastStreamReplacer
FastStreamReplacer | public class FastStreamReplacer (Code) | | Search and Replace a set of substrings with another substrings.
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.
author: Sergio Montoro Ten version: 2.1 |
Method Summary | |
public static HashMap | createMap(String[] aKeys, String[] aValues) | public int | lastReplacements() Number of replacements done in last call to replace() method. | public String | replace(InputStream oFileInStream, HashMap oMap) Replace subtrings from a Stream.
Parameters: oInStream - Input Stream containing substrings to be replaced. Parameters: oMap - Map with values to be replaced. Each map key will be replaced by its value. Map keys must appear in stream text as {#key} For example: InputStream "Today is {#System.Date}" will be replaced with "Today is 2002-02-21 11:32:44" No wildcards are accepted. Map keys must not contain {# } key markers. | public String | replace(StringBuffer oStrBuff, HashMap oMap) Replace subtrings from a Stream.
Parameters: oInStream - Input Stream containing substrings to be replaced. Parameters: oMap - Map with values to be replaced. Each map key will be replaced by its value. Map keys must appear in stream text as {#key} For example: InputStream "Today is {#System.Date}" will be replaced with "Today is 2002-02-21 11:32:44" No wildcards are accepted. Map keys must not contain {# } key markers. | public String | replace(String sFilePath, HashMap oMap) Replace substrings from a Text File.
Parameters: sFilePath - File containing text to be replaced. Parameters: oMap - Map with values to be replaced. Each map key will be replaced by its value. Map keys must appear in stream text as {#key} For example: InputStream "Today is {#System.Date}" will be replaced with "Today is 2002-02-21 11:32:44" No wildcards are accepted. Map keys must not contain {# } key markers. |
BufferSize | int BufferSize(Code) | | |
iReplacements | int iReplacements(Code) | | |
FastStreamReplacer | public FastStreamReplacer()(Code) | | |
FastStreamReplacer | public FastStreamReplacer(int iBufferSize)(Code) | | |
createMap | public static HashMap createMap(String[] aKeys, String[] aValues)(Code) | | 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
Parameters: aKeys - An array of Strings to be used as keys Parameters: aValues - An array of Strings that will be the actual values for the keys A HashMap with the given keys and values |
lastReplacements | public int lastReplacements()(Code) | | Number of replacements done in last call to replace() method.
|
replace | public String replace(InputStream oFileInStream, HashMap oMap) throws IOException(Code) | | Replace subtrings from a Stream.
Parameters: oInStream - Input Stream containing substrings to be replaced. Parameters: oMap - Map with values to be replaced. Each map key will be replaced by its value. Map keys must appear in stream text as {#key} For example: InputStream "Today is {#System.Date}" will be replaced with "Today is 2002-02-21 11:32:44" No wildcards are accepted. Map keys must not contain {# } key markers. String Replacements Result throws: IOException - |
replace | public String replace(StringBuffer oStrBuff, HashMap oMap) throws IOException, IndexOutOfBoundsException(Code) | | Replace subtrings from a Stream.
Parameters: oInStream - Input Stream containing substrings to be replaced. Parameters: oMap - Map with values to be replaced. Each map key will be replaced by its value. Map keys must appear in stream text as {#key} For example: InputStream "Today is {#System.Date}" will be replaced with "Today is 2002-02-21 11:32:44" No wildcards are accepted. Map keys must not contain {# } key markers. String Replacements Result throws: IOException - throws: IndexOutOfBoundsException - |
replace | public String replace(String sFilePath, HashMap oMap) throws IOException(Code) | | Replace substrings from a Text File.
Parameters: sFilePath - File containing text to be replaced. Parameters: oMap - Map with values to be replaced. Each map key will be replaced by its value. Map keys must appear in stream text as {#key} For example: InputStream "Today is {#System.Date}" will be replaced with "Today is 2002-02-21 11:32:44" No wildcards are accepted. Map keys must not contain {# } key markers. String Replacements Result. throws: IOException - |
|
|
|