io.pelle.mango.client.base.util.MessageFormat Maven / Gradle / Ivy
The newest version!
package io.pelle.mango.client.base.util;
import java.util.Map;
public class MessageFormat
{
public static String format(String string, Map tokens)
{
for (Map.Entry token : tokens.entrySet())
{
String delimiter = "{" + token.getKey() + "}";
while (string.contains(delimiter))
{
string = string.replace(delimiter, String.valueOf(token.getValue()));
}
}
return string;
}
public static String format(String string, Object... tokens)
{
int i = 0;
while (i < tokens.length)
{
String delimiter = "{" + i + "}";
while (string.contains(delimiter))
{
string = string.replace(delimiter, String.valueOf(tokens[i]));
}
i++;
}
return string;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy