Java Utililty Methods List Replace

List of utility methods to do List Replace

Description

The list of methods to do List Replace are organized into topic(s).

Method

voidreplaceAndAdd(List par3List, String translateToLocal)
replace And Add
translateToLocal = translateToLocal.replace('&', ((char) 167));
for (String str : translateToLocal.split("@NL@"))
    par3List.add(str);
StringreplaceAtSymbol(String s, List params)
replace At Symbol
for (String param : params) {
    String paramTemp = VELOCITY_VARIABLE_PREFIX + param + VELOCITY_VARIABLE_SUFFIX;
    s = s.replaceFirst("@([\\w]*)", paramTemp);
return s;
ListreplaceColons(List unstructuredSentences)
replace Colons
List<String> colonFreeSentences = new ArrayList<String>();
for (String unstructuredSentence : unstructuredSentences) {
    String colonFreeSentence = unstructuredSentence.replaceAll("\\.", SPACE);
    colonFreeSentences.add(colonFreeSentence);
return colonFreeSentences;
StringreplaceFields(Map mapFields, String changeStr, List listString)
replace Fields
Object[] keys = mapFields.keySet().toArray();
Comparator comparator = new Comparator() {
    public int compare(Object o1, Object o2) {
        int length1 = ((String) o1).length();
        int length2 = ((String) o2).length();
        if (length1 > length2)
            return -1;
        if (length1 == length2) {
...
StringreplaceIgnoreList(String text)
Replaces the ignored characters.
text = " " + text;
for (String exception : exceptionToReplaceWith.keySet()) {
    text = text.replaceAll(exception, exceptionToReplaceWith.get(exception));
text = text.replaceAll(ignoredCharRegex, replacementForIgnoredChar);
return text;
ListreplaceInLines(List lines, String from, String to, int fromIndex, int toIndex)
replace In Lines
List<String> list = new ArrayList<String>();
if (fromIndex == -1)
    fromIndex = 0;
if (toIndex == -1)
    toIndex = lines.size();
for (int i = 0; i < lines.size(); i++) {
    String line = lines.get(i);
    String outputLine = line;
...
booleanreplaceInList(T a, T b, List list)
replace In List
final int max = list.size();
for (int i = 0; i < max; i++) {
    if (list.get(i) == a) {
        list.set(i, b);
        return true;
return false;
...
StringreplaceList(String v, String[] patterns, String[] values)
Replaces all occurrences of "patterns" in "v" with "values"
for (int i = 0; i < patterns.length; i++) {
    v = replace(v, patterns[i], values[i]);
return v;
voidreplaceNpcId(final List npcListSqlLines, final int lineIndex, final int newNpcId, final boolean markAsGuess)
Method to Replace the NPC ID on the Current Line w/ a New One
final String npcIdLine = npcListSqlLines.get(lineIndex);
final int endIndex = npcIdLine.indexOf(",");
final String insertStringFragment = npcIdLine.substring(0, NPC_LIST_INSERT_START.length());
final String postIdFragment = npcIdLine.substring(endIndex, npcIdLine.length());
String newNpcIdLine = insertStringFragment + newNpcId + postIdFragment;
if (markAsGuess) {
    newNpcIdLine = "FIXME: " + newNpcIdLine;
npcListSqlLines.set(lineIndex, newNpcIdLine);
ListreplaceOrAdd(List list, T object)
replace Or Add
if (list == null || object == null)
    return list;
int i = list.indexOf(object);
if (i != -1) {
    list.remove(object);
    list.add(i, object);
} else {
    list.add(object);
...