Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.dataxslt
Class FastStreamReplacer

    java.lang.Object
      com.knowgate.dataxslt.FastStreamReplacer

    public class FastStreamReplacer

extends java.lang.Object

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.

Constructor Summary
`FastStreamReplacer()`
`FastStreamReplacer(int iBufferSize)`

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FastStreamReplacer

    public FastStreamReplacer()

### FastStreamReplacer

    public FastStreamReplacer(int iBufferSize)

Method Detail

### replace

    public java.lang.String replace(java.io.InputStream oFileInStream,
                                    java.util.HashMap oMap)
                             throws java.io.IOException

  Replace subtrings from a Stream.

  Parameters:
    `oInStream` - Input Stream containing substrings to be replaced.
    `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.
  Returns:
    String Replacements Result
  Throws:
    `java.io.IOException`

### replace

    public java.lang.String replace(java.lang.StringBuffer oStrBuff,
                                    java.util.HashMap oMap)
                             throws java.io.IOException,
                                    java.lang.IndexOutOfBoundsException

  Replace subtrings from a Stream.

  Parameters:
    `oInStream` - Input Stream containing substrings to be replaced.
    `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.
  Returns:
    String Replacements Result
  Throws:
    `java.io.IOException`
    `java.lang.IndexOutOfBoundsException`

### replace

    public java.lang.String replace(java.lang.String sFilePath,
                                    java.util.HashMap oMap)
                             throws java.io.IOException

  Replace substrings from a Text File.

  Parameters:
    `sFilePath` - File containing text to be replaced.
    `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.
  Returns:
    String Replacements Result.
  Throws:
    `java.io.IOException`

### lastReplacements

    public int lastReplacements()

  Number of replacements done in last call to replace() method.

### createMap

    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 class

  Parameters:
    `aKeys` - An array of Strings to be used as keys
    `aValues` - An array of Strings that will be the actual values for the keys
  Returns:
    A HashMap with the given keys and values
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD