Copyright 2002 by aragost

com.aragost.lang
Class Strings

java.lang.Object
  |
  +--com.aragost.lang.Strings

public class Strings
extends java.lang.Object

Utility class with some String manipulating methods.


Field Summary
static char DEFAULT_ESCAPE
          The default escape characters.
static java.lang.String LINE_SEPARATOR
          The line separator.
 
Constructor Summary
Strings()
           
 
Method Summary
static java.lang.String escape(java.lang.String s, java.lang.String specials)
          Insert the default escape character in a String.
static java.lang.String escape(java.lang.String s, java.lang.String specials, char escape)
          Utility method to insert escape characters in the specified String.
static java.lang.String extend(java.lang.String s, int size)
          Pad the specified String with space so it gets the specified length.
static java.lang.String lineWrap(java.lang.String s, int lineLength)
           
static java.lang.String lineWrap(java.lang.String s, int lineLength, java.lang.String marker)
          Insert newlines into the specified String, so if possible no line is longer than specified by lineLength.
static java.lang.String replace(java.lang.String source, java.lang.String old, java.lang.String nue)
          Replace all occurences of a String with another String, in the specified String.
static java.lang.String spaces(int size)
          Return a String with only space, and of the specified length.
static java.lang.String trimEnd(java.lang.String s)
          Remove all whitespace from the end of the specified String.
static java.lang.String trimStart(java.lang.String s)
          Remove all whitespaces from the start of the specified String.
static java.lang.String unescape(java.lang.String s)
           
static java.lang.String unescape(java.lang.String s, char escape)
          Utility method to remove escape characters from the specified String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_SEPARATOR

public static final java.lang.String LINE_SEPARATOR
The line separator. This is the value of the system property line.separator at the time the class is loaded.


DEFAULT_ESCAPE

public static final char DEFAULT_ESCAPE
The default escape characters.

See Also:
Constant Field Values
Constructor Detail

Strings

public Strings()
Method Detail

escape

public static java.lang.String escape(java.lang.String s,
                                      java.lang.String specials,
                                      char escape)
Utility method to insert escape characters in the specified String. All characters that is special will be preceded by the escape character.

Parameters:
s - The String to insert escape characters into
specials - All characters that should be consider special.
escape - The character to insert in front of special characters

escape

public static java.lang.String escape(java.lang.String s,
                                      java.lang.String specials)
Insert the default escape character in a String.

See Also:
escape(String, String, char)

unescape

public static java.lang.String unescape(java.lang.String s,
                                        char escape)
Utility method to remove escape characters from the specified String.


unescape

public static java.lang.String unescape(java.lang.String s)

trimStart

public static java.lang.String trimStart(java.lang.String s)
Remove all whitespaces from the start of the specified String.


trimEnd

public static java.lang.String trimEnd(java.lang.String s)
Remove all whitespace from the end of the specified String.


lineWrap

public static java.lang.String lineWrap(java.lang.String s,
                                        int lineLength,
                                        java.lang.String marker)
Insert newlines into the specified String, so if possible no line is longer than specified by lineLength. The method will try to replace spaces with newlines. If marker is non-null marker will be prepended to the lines created by inserting newlines.


lineWrap

public static java.lang.String lineWrap(java.lang.String s,
                                        int lineLength)

replace

public static java.lang.String replace(java.lang.String source,
                                       java.lang.String old,
                                       java.lang.String nue)
Replace all occurences of a String with another String, in the specified String.

Parameters:
source - The String to make replacements in
old - The String to replace
nue - The String to insert as replacement

spaces

public static java.lang.String spaces(int size)
Return a String with only space, and of the specified length.


extend

public static java.lang.String extend(java.lang.String s,
                                      int size)
Pad the specified String with space so it gets the specified length.


Copyright 2002 by aragost