CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.util
Class Strings

java.lang.Object
  extended by ch.randelshofer.util.Strings

public class Strings
extends java.lang.Object

This class contains various methods for manipulating strings.

Version:
1.3 2006-04-15 Method reverse(String) added.
1.2.1 2003-06-13 Method translate(String, char, char) removed.
1.2 2002-05-10 Method replace(String, String, String) added.
1.1 2002-02-05 Created.
Author:
Werner Randelshofer, Hausmatt 10, Immensee, CH-6405, Switzerland

Constructor Summary
Strings()
           
 
Method Summary
static java.lang.String replace(java.lang.String str, java.lang.String from, java.lang.String to)
          Replaces all occurences of 'from' by 'to'.
static java.lang.String reverse(java.lang.String str)
          Reverses the characters in a String.
static java.lang.String translate(java.lang.String s, char[] from, char[] to)
          Translates all occurences of characters in the char array 'from' to the characters in 'to'.
static java.lang.String translate(java.lang.String s, java.lang.String from, java.lang.String to)
          Translates all occurences of characters in String 'from' to the characters in String 'to'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Strings

public Strings()
Method Detail

translate

public static java.lang.String translate(java.lang.String s,
                                         java.lang.String from,
                                         java.lang.String to)
Translates all occurences of characters in String 'from' to the characters in String 'to'. This is a convenience method for calling translate(s, from.toCharArray(), to.toCharArray())

Parameters:
s - The string to be translated.
from - The characters to be replaced.
to - The replacement characters.
Returns:
The translated String.

translate

public static java.lang.String translate(java.lang.String s,
                                         char[] from,
                                         char[] to)
Translates all occurences of characters in the char array 'from' to the characters in 'to'.

Parameters:
s - The string to be translated.
from - The characters to be replaced.
to - The replacement characters.
Returns:
The translated String.

replace

public static java.lang.String replace(java.lang.String str,
                                       java.lang.String from,
                                       java.lang.String to)
Replaces all occurences of 'from' by 'to'.

Parameters:
str - The string to be processed.
from - The text to be replaced.
to - The replacement text.
Returns:
The translated String.

reverse

public static java.lang.String reverse(java.lang.String str)
Reverses the characters in a String.

Parameters:
str - The string to be reversed.
Returns:
The reversed String.

(c) Werner Randelshofer.
All rights reserved.