/** * Substitute sub-strings in side of a string. * * @param from String to substitute from * @param to String to substitute to * @param string String to look for from in * @return Substituted string */ public static String subst(final String from, final String to, final String string) { return subst(new StringBuffer(), from, to, string); }
/** * Substitute sub-strings in side of a string. * * @param string String to subst mappings in * @param map Map of from->to strings * @param beginToken Beginning token * @param endToken Ending token * @return Substituted string */ public static String subst(final String string, final Map map, final String beginToken, final String endToken) { return subst(new StringBuffer(), string, map, beginToken, endToken); }
/** * Substitute index identifiers with the replacement value from the * given array for the corresponding index. * * @param string String substitution format. * @param replace Array of strings whose values will be used as * replacements in the given string when a token with * their index is found. * @param token The character token to specify the start of an index * reference. * @return Substituted string. */ public static String subst(final String string, final String replace[], final char token) { return subst(new StringBuffer(), string, replace, token); }
/** * Substitute index identifiers (with <code>%</code> for the index token) * with the replacement value from the given array for the corresponding * index. * * @param string String substitution format. * @param replace Array of strings whose values will be used as * replacements in the given string when a token with * their index is found. * @return Substituted string. */ public static String subst(final String string, final String replace[]) { return subst(new StringBuffer(), string, replace, '%'); }