bsharp.strings
Class Strings

java.lang.Object
  extended by bsharp.strings.Strings

public class Strings
extends java.lang.Object

Helper methods for string modifcations.

Author:
brandon@sharpideas.ca

Field Summary
static java.lang.String NL
          NEW LINE.
static java.lang.String QUOTE
          A QUOTE.
static java.lang.String SPACE
          A SPACE.
 
Method Summary
static java.lang.String indent(java.lang.String s, char fill, int targetSize)
          Prepend the given character until the string is the width of targetSize.
static java.lang.String quote(java.lang.String s)
          Enclose the given string in quotes.
static java.lang.String replaceAll(java.lang.String input, java.lang.String match, java.lang.String replaceWith)
          Replace all occurrences of the character with the replacement string.
static java.lang.String subtractLeft(java.lang.String source, java.lang.String subtract)
          Subtract the second string from the left side of the first.
static java.lang.String subtractRight(java.lang.String source, java.lang.String subtract)
          Subtract the second string from the right side of the first.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NL

public static final java.lang.String NL
NEW LINE.

See Also:
Constant Field Values

SPACE

public static final java.lang.String SPACE
A SPACE.

See Also:
Constant Field Values

QUOTE

public static final java.lang.String QUOTE
A QUOTE.

See Also:
Constant Field Values
Method Detail

subtractRight

public static java.lang.String subtractRight(java.lang.String source,
                                             java.lang.String subtract)
Subtract the second string from the right side of the first.

Parameters:
source - the first string.
subtract - subtract this from the first string.
Returns:
the remainder of the first string.

subtractLeft

public static java.lang.String subtractLeft(java.lang.String source,
                                            java.lang.String subtract)
Subtract the second string from the left side of the first.

Parameters:
source - the first string.
subtract - subtract this from the first string.
Returns:
the remainder of the first string.

indent

public static java.lang.String indent(java.lang.String s,
                                      char fill,
                                      int targetSize)
Prepend the given character until the string is the width of targetSize.

Parameters:
s - the string to indent.
fill - the character to prepend.
targetSize - the size to make the final string.
Returns:

quote

public static java.lang.String quote(java.lang.String s)
Enclose the given string in quotes.

Parameters:
s - the input string.
Returns:
the string enclosed in quotes.

replaceAll

public static java.lang.String replaceAll(java.lang.String input,
                                          java.lang.String match,
                                          java.lang.String replaceWith)
Replace all occurrences of the character with the replacement string.

Parameters:
input - the input string.
match -
replaceWith -
Returns:
the input string with all occurrences of the character with the replacement string.