Java Utililty Methods String Translate

List of utility methods to do String Translate

Description

The list of methods to do String Translate are organized into topic(s).

Method

Stringtranslate(String input, String xmlName)
translate
if (xmlName.startsWith("B")) {
    if (input.equalsIgnoreCase("yes")) {
        return "true";
    } else if (input.equalsIgnoreCase("no"))
        return "false";
} else if (xmlName.startsWith("Sel")) {
    if (input.equalsIgnoreCase("yes")) {
        return "Present";
...
Stringtranslate(String message, String charsToBeReplaced, String replacementChars)
translate method replaces a sequence of characters in a string with another set of characters.
if (message == null)
    return message;
boolean useEmpty = false;
if (replacementChars == null || "".equals(replacementChars))
    useEmpty = true;
if (!useEmpty && (replacementChars.length() != charsToBeReplaced.length()))
    throw new IllegalArgumentException(
            "The replacement characters are not of the same length of the replaced characters.");
...
Stringtranslate(String name, int type)
translate
if (type == 0) { 
    name = name.substring(1, name.length() - 1);
    name = name.replace('/', '.');
    return name;
} else {
    name = name.replace('.', '/');
    name = "/" + name + "/";
    return name;
...
Stringtranslate(String originalHtml)
translate
String html = originalHtml;
while (true) {
    int end;
    int start = html.indexOf("<br/>* ");
    int offset = 7;
    if (start < 0) {
        start = html.indexOf("\n* ");
        offset = 3;
...
chartranslate(String s)
translate
switch (s) {
case "&amp;":
    return '&';
case "&lt;":
case "&Lt;":
    return '<';
case "&gt;":
case "&Gt;":
...
chartranslate(String s)
translate
if (s.equals("&amp;")) {
    return '&';
} else if (s.equals("&lt;") || s.equals("&Lt;")) {
    return '<';
} else if (s.equals("&gt;") || s.equals("&Gt;")) {
    return '>';
} else if (s.equals("&quot;")) {
    return '\"';
...
Stringtranslate(String s, String identifier, String associator)
Performs a character-for-character replacement within a string.
String newString = "";
for (int index = 0; index < s.length(); index++) {
    String substring = s.substring(index, index + 1);
    int position = identifier.indexOf(substring);
    if (position != -1)
        newString = newString + associator.substring(position, position + 1);
    else
        newString = newString + s.substring(index, index + 1);
...
Stringtranslate(String s, String oldChars, String newChars)
Translate characters from the String inStr found in the String oldChars to the corresponding character found in newChars.
if (s == null || s.length() == 0)
    return s; 
StringBuffer outBuf = new StringBuffer(s.length()); 
int idx = -1;
int limit = s.length();
for (int i = 0; i < limit; ++i) {
    char c = s.charAt(i);
    if ((idx = oldChars.indexOf(c)) != -1) { 
...
Objecttranslate(String sequence, String match, String replacement)
This method is used to translate characters in the input sequence that match the characters in the match list to the corresponding character in the replacement list.
if (sequence == null) {
    return sequence;
StringBuffer buffer = new StringBuffer(sequence);
for (int index = 0; index < buffer.length(); index++) {
    char ch = buffer.charAt(index);
    int position = match.indexOf(ch);
    if (position == -1) {
...
Stringtranslate(String source)
translate
String target = source;
return target.replace("<", "&lt;").replace(">", "&gt;");