org.alicebot.server.core.util
Class Substituter

java.lang.Object
  extended by org.alicebot.server.core.util.Substituter

public class Substituter
extends java.lang.Object

Provides generic substitution utilities for classes that don't have their own.

Author:
Noel Bush

Constructor Summary
Substituter()
           
 
Method Summary
static java.lang.String applySubstitutions(java.util.HashMap substitutionMap, java.lang.String input)
          Same as replaceIgnoreCase(java.lang.String, java.lang.String, java.lang.String) except a substitution map is given, and extra care is taken to ensure that a replaced value does not have further substitutions performed on it.
static java.lang.String replace(java.lang.String find, java.lang.String replace, java.lang.String input)
           Replaces all instances of find with replace.
static java.lang.String replaceIgnoreCase(java.lang.String find, java.lang.String replace, java.lang.String input)
           Same as replace(java.lang.String, java.lang.String, java.lang.String) except case is ignored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Substituter

public Substituter()
Method Detail

replace

public static java.lang.String replace(java.lang.String find,
                                       java.lang.String replace,
                                       java.lang.String input)

Replaces all instances of find with replace.

NB: This method does not take care that further substitutions are not performed on replaced text. For this extra caution, use applySubstitutions(java.util.HashMap, java.lang.String).

Parameters:
input - the string on which to perform the replacement
find - the string to find
replace - the string with which to replace it
Returns:
the str

replaceIgnoreCase

public static java.lang.String replaceIgnoreCase(java.lang.String find,
                                                 java.lang.String replace,
                                                 java.lang.String input)

Same as replace(java.lang.String, java.lang.String, java.lang.String) except case is ignored.

NB: This method does not take care that further substitutions are not performed on replaced text. For this extra caution, use applySubstitutions(java.util.HashMap, java.lang.String).

Parameters:
input - the string on which to perform the replacement
find - the string to find
replace - the string with which to replace it
Returns:
the str

applySubstitutions

public static java.lang.String applySubstitutions(java.util.HashMap substitutionMap,
                                                  java.lang.String input)
Same as replaceIgnoreCase(java.lang.String, java.lang.String, java.lang.String) except a substitution map is given, and extra care is taken to ensure that a replaced value does not have further substitutions performed on it.

Parameters:
substitutionMap - the map of substitutions to be performed
input - the string on which to perform the replacement
Returns:
the input with substitutions applied