SSF.OS.BGP4.Util
Class StringManip

java.lang.Object
  |
  +--SSF.OS.BGP4.Util.StringManip

public class StringManip
extends java.lang.Object

This class contains public utility methods useful for manipulating character strings.


Constructor Summary
StringManip()
           
 
Method Summary
static java.lang.String pad(java.lang.String str)
          Pads a string by adding characters to it.
static java.lang.String pad(java.lang.String str, int places)
          Pads a string by adding characters to it.
static java.lang.String pad(java.lang.String str, int places, char ch)
          Pads a string by adding characters to it.
static java.lang.String pad(java.lang.String str, int places, char ch, boolean atend)
          Pads a string by adding characters to it.
static java.lang.String repeat(char ch, int len)
          Creates a string of arbitrary length by repeating just one character.
static java.lang.String repeat(char ch, int len, int min)
          Creates a string of arbitrary length by repeating just one character.
static java.lang.String unpad(java.lang.String str)
          Removes "padding" characters from a string.
static java.lang.String unpad(java.lang.String str, char ch)
          Removes "padding" characters from a string.
static java.lang.String unpad(java.lang.String str, char ch, boolean atend)
          Removes "padding" characters from a string.
static java.lang.String unpad(java.lang.String str, char ch, boolean atend, int minplaces)
          Removes "padding" characters from a string.
static java.lang.String ws(int len)
          Creates a string of whitespace composed of space characters only.
static java.lang.String ws(int len, int min)
          Creates a string of whitespace composed of space characters only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringManip

public StringManip()
Method Detail

repeat

public static final java.lang.String repeat(char ch,
                                            int len,
                                            int min)
Creates a string of arbitrary length by repeating just one character.

Parameters:
ch - The character to use for the string.
len - The length (in characters) of the string to be created. A negative value will be treated as a 0.
min - The minimum length (in characters) of the string to be created. This may seem odd since length is specified, but it is useful sometimes when an expression with unknown value is provided for the length.
Returns:
a string composed only of spaces

repeat

public static final java.lang.String repeat(char ch,
                                            int len)
Creates a string of arbitrary length by repeating just one character.

Parameters:
ch - The character to use for the string.
len - The length (in characters) of the string to be created. A non-positive value is be treated as a 1.
Returns:
a string composed only of spaces

ws

public static final java.lang.String ws(int len,
                                        int min)
Creates a string of whitespace composed of space characters only.

Parameters:
len - The length (in characters) of the whitespace to be created. A negative value will be treated as a 0.
min - The minimum length (in characters) of the whitespace to be created.
Returns:
a string composed only of spaces

ws

public static final java.lang.String ws(int len)
Creates a string of whitespace composed of space characters only.

Parameters:
len - The length (in characters) of the whitespace to be created. A non-positive value is treated as a 1.
Returns:
a string composed only of spaces

pad

public static final java.lang.String pad(java.lang.String str,
                                         int places,
                                         char ch,
                                         boolean atend)
Pads a string by adding characters to it.

Parameters:
str - The string to pad.
places - The maximum length of the string to pad up to.
ch - The character to pad with.
atend - Whether to pad at the end or the beginning of the string.
Returns:
the padded string

pad

public static final java.lang.String pad(java.lang.String str,
                                         int places,
                                         char ch)
Pads a string by adding characters to it.

Parameters:
str - The string to pad.
places - The maximum length of the string to pad up to.
ch - The character to pad with.
Returns:
the padded string

pad

public static final java.lang.String pad(java.lang.String str,
                                         int places)
Pads a string by adding characters to it.

Parameters:
str - The string to pad.
places - The maximum length of the string to pad up to.
Returns:
the padded string

pad

public static final java.lang.String pad(java.lang.String str)
Pads a string by adding characters to it.

Parameters:
str - The string to pad.
Returns:
the padded string

unpad

public static final java.lang.String unpad(java.lang.String str,
                                           char ch,
                                           boolean atend,
                                           int minplaces)
Removes "padding" characters from a string. The opposite of pad.

Parameters:
str - The string to unpad.
ch - The character used as padding.
atend - Whether to unpad at the end or beginning of the string.
minplaces - The minimum number of characters to leave in the string after unpadding.
Returns:
the unpadded string

unpad

public static final java.lang.String unpad(java.lang.String str,
                                           char ch,
                                           boolean atend)
Removes "padding" characters from a string. The opposite of pad.

Parameters:
str - The string to unpad.
ch - The character used as padding.
atend - Whether to unpad at the end or beginning of the string.
Returns:
the unpadded string

unpad

public static final java.lang.String unpad(java.lang.String str,
                                           char ch)
Removes "padding" characters from a string. The opposite of pad.

Parameters:
str - The string to unpad.
ch - The character used as padding.
Returns:
the unpadded string

unpad

public static final java.lang.String unpad(java.lang.String str)
Removes "padding" characters from a string. The opposite of pad.

Parameters:
str - The string to unpad.
Returns:
the unpadded string