com.generationjava.lang
Class StringW

java.lang.Object
  |
  +--com.generationjava.lang.StringW

public final class StringW
extends java.lang.Object

A set of String library static methods. While extending String or StringBuffer would have been the nicest solution, that is not possible, so a simple set of static methods seems the most workable. Most methods have now gone to Commons Lang StringUtils. Method ideas have so far been taken from the PHP4, Ruby and .NET languages.


Constructor Summary
StringW()
           
 
Method Summary
static int getLevenshteinDistance(java.lang.String s, java.lang.String t)
          Deprecated. in favour of Commons Codec
static java.lang.String join(java.lang.Object[] objs, java.lang.String sep, java.lang.String pre, java.lang.String post)
           
static java.lang.String quoteRegularExpression(java.lang.String str)
          Deprecated. Useless as it doesn't handle character classes and I never use it. Gone in 3.0.
static java.lang.String wordWrap(java.lang.String str)
          Create a word-wrapped version of a String.
static java.lang.String wordWrap(java.lang.String str, int width)
          Create a word-wrapped version of a String.
static java.lang.String wordWrap(java.lang.String str, int width, java.lang.String delim, java.lang.String split)
          Word-wrap a string.
static java.lang.String wordWrap(java.lang.String str, java.lang.String width, java.lang.String delim, java.lang.String split)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringW

public StringW()
Method Detail

join

public static java.lang.String join(java.lang.Object[] objs,
                                    java.lang.String sep,
                                    java.lang.String pre,
                                    java.lang.String post)

getLevenshteinDistance

public static int getLevenshteinDistance(java.lang.String s,
                                         java.lang.String t)
Deprecated. in favour of Commons Codec

Find the Levenshtein distance between two strings. This is the number of changes needed to change one string into another. Where each change is a single character modification. This implemmentation of the levenshtein distance algorithm is from http://www.merriampark.com/ld.htm


quoteRegularExpression

public static java.lang.String quoteRegularExpression(java.lang.String str)
Deprecated. Useless as it doesn't handle character classes and I never use it. Gone in 3.0.

Quote a string so that it may be used in a regular expression without any parts of the string being considered as a part of the regular expression's control characters.


wordWrap

public static java.lang.String wordWrap(java.lang.String str)
Create a word-wrapped version of a String. Wrap at 80 characters and use newlines as the delimiter. If a word is over 80 characters long use a - sign to split it.


wordWrap

public static java.lang.String wordWrap(java.lang.String str,
                                        int width)
Create a word-wrapped version of a String. Wrap at a specified width and use newlines as the delimiter. If a word is over the width in lenght use a - sign to split it.


wordWrap

public static java.lang.String wordWrap(java.lang.String str,
                                        java.lang.String width,
                                        java.lang.String delim,
                                        java.lang.String split)

wordWrap

public static java.lang.String wordWrap(java.lang.String str,
                                        int width,
                                        java.lang.String delim,
                                        java.lang.String split)
Word-wrap a string.

Parameters:
str - String to word-wrap
width - int to wrap at
delim - String to use to separate lines
split - String to use to split a word greater than width long
Returns:
String that has been word wrapped


Copyright © 2000-2003 OSJava. All Rights Reserved.