org.ws4d.java.util
Class StringUtil

java.lang.Object
  extended by org.ws4d.java.util.StringUtil

public final class StringUtil
extends java.lang.Object


Field Summary
static java.lang.String[] day
           
static java.lang.String[] month
           
static java.lang.String[][] zone
           
 
Constructor Summary
StringUtil()
           
 
Method Summary
static java.lang.String arrayToStringByte(byte[] array)
          Creates a String from an array of byte.
static java.lang.String arrayToStringInt(int[] array)
          Creates a String from an array of int.
static java.lang.String arrayToStringLong(long[] array)
          Creates a String form a array of long.
static java.lang.String chomp(java.lang.String inStr)
          Deletes the Line Feed (10) and Carriage Return (13) fields of the given String.
static java.lang.String decodeURL(java.lang.String url)
          Decodes a String in application/x-www-form-urlencoded format as specified in Chapter Forms of the HTML 4.01 Specification.
static java.lang.String decodeURL(java.lang.String url, java.lang.String encoding)
          Decodes a String in application/x-www-form-urlencoded format as specified in Chapter Forms of the HTML 4.01 Specification.
static java.lang.String encodeURL(java.lang.String url)
          Encodes an given URL.
static boolean equalsIgnoreCase(java.lang.String s1, java.lang.String s2)
           
static java.lang.String formatClassName(java.lang.Class clazz)
          Depending on the value of USE_LONG_CLASS_NAMES returns either the fully qualified class name of clazz or the result of calling simpleClassName(Class) on it.
static java.lang.String formatClassName(java.lang.String qualifiedClassName)
          Depending on the value of USE_LONG_CLASS_NAMES returns either the same String given in argument qualifiedClassName or the result of calling simpleClassName(String) on it.
static java.lang.String getHTTPDate(long date)
           
static long getHTTPDateAsLong(java.lang.String httpDate)
           
static java.lang.String getStringEncoding()
           
static int lastIndexOf(java.lang.String what, java.lang.String within)
           
static HashMap parseStringOptions(java.lang.String args)
          Parses options from a String.
static HashMap parseStringProperties(java.lang.String args)
          Parses properties from a String.
static void printStream(java.io.InputStream in)
          Prints a stream to System.out.
static java.lang.String simpleClassName(java.lang.Class clazz)
          Returns only the substring after the last dot character ("e;.
static java.lang.String simpleClassName(java.lang.String qualifiedClassName)
          Given a fully qualified class name (like java.lang.Object), returns only the substring after the last dot character ("e;.
static java.lang.String[] split(java.lang.String s, char c)
          Splits a string at a given separator char in substrings and returns these elements in a string array.
static java.lang.String[] split(java.lang.String s, java.lang.String separator)
          Splits a string at a given separator char in substrings and returns these elements in a string array.
static java.lang.String[] splitAtWhitespace(java.lang.String s)
           
static java.util.Vector stringToVector(java.lang.String s, java.lang.String separator)
          Converts text with spaces into Vector.
static java.lang.String[] toStringArray(java.util.Vector strings)
          Converts the given Vector to String array
static java.lang.String vectorToString(java.util.Vector v, java.lang.String separator)
          Concats the elements of a vector to a string (calls toString of each element) separated by given string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

day

public static final java.lang.String[] day

month

public static final java.lang.String[] month

zone

public static final java.lang.String[][] zone
Constructor Detail

StringUtil

public StringUtil()
Method Detail

equalsIgnoreCase

public static boolean equalsIgnoreCase(java.lang.String s1,
                                       java.lang.String s2)

lastIndexOf

public static int lastIndexOf(java.lang.String what,
                              java.lang.String within)

getStringEncoding

public static final java.lang.String getStringEncoding()

split

public static java.lang.String[] split(java.lang.String s,
                                       char c)
Splits a string at a given separator char in substrings and returns these elements in a string array.

Parameters:
s - The string to split.
c - The separator char.
Returns:
The array containing the substrings.

split

public static java.lang.String[] split(java.lang.String s,
                                       java.lang.String separator)
Splits a string at a given separator char in substrings and returns these elements in a string array.

Parameters:
s - The string to split.
separator - The separator char.
Returns:
The array containing the substrings.

splitAtWhitespace

public static java.lang.String[] splitAtWhitespace(java.lang.String s)

stringToVector

public static java.util.Vector stringToVector(java.lang.String s,
                                              java.lang.String separator)
Converts text with spaces into Vector.

Parameters:
s - The text to convert.
Returns:
Vector containing the text parts.

vectorToString

public static java.lang.String vectorToString(java.util.Vector v,
                                              java.lang.String separator)
Concats the elements of a vector to a string (calls toString of each element) separated by given string. Returns null if no vector is given, returns "" if no elements are in the vector.

Parameters:
v - Vector to work on.
separator - The string which should be used as separator.
Returns:
The built string.

encodeURL

public static java.lang.String encodeURL(java.lang.String url)
Encodes an given URL.

Parameters:
url - the URL to encode.
Returns:
the encoded URL.

decodeURL

public static java.lang.String decodeURL(java.lang.String url)
Decodes a String in application/x-www-form-urlencoded format as specified in Chapter Forms of the HTML 4.01 Specification. Uses default character encoding.

Parameters:
url - String to decode.
Returns:
Decoded String.
Throws:
java.io.UnsupportedEncodingException

decodeURL

public static java.lang.String decodeURL(java.lang.String url,
                                         java.lang.String encoding)
                                  throws java.io.UnsupportedEncodingException
Decodes a String in application/x-www-form-urlencoded format as specified in Chapter Forms of the HTML 4.01 Specification.

Parameters:
url - String to decode.
encoding - Encoding.
Returns:
Decoded String.
Throws:
java.io.UnsupportedEncodingException

formatClassName

public static java.lang.String formatClassName(java.lang.Class clazz)
Depending on the value of USE_LONG_CLASS_NAMES returns either the fully qualified class name of clazz or the result of calling simpleClassName(Class) on it.

Parameters:
clazz - the class to return a formatted name of
Returns:
either the fully qualified or the simple class name of argument clazz
See Also:
USE_LONG_CLASS_NAMES, simpleClassName(Class)

formatClassName

public static java.lang.String formatClassName(java.lang.String qualifiedClassName)
Depending on the value of USE_LONG_CLASS_NAMES returns either the same String given in argument qualifiedClassName or the result of calling simpleClassName(String) on it.

Parameters:
qualifiedClassName - a fully qualified Java class name
Returns:
either the same String as qualifiedClassName or the simple class name
See Also:
USE_LONG_CLASS_NAMES, simpleClassName(String)

simpleClassName

public static java.lang.String simpleClassName(java.lang.Class clazz)
Returns only the substring after the last dot character ("e;."e;), within the name of clazz, i.e. Object instead of java.lang.Object.

Parameters:
clazz - the class to return the simple name of
Returns:
the simple class name

simpleClassName

public static java.lang.String simpleClassName(java.lang.String qualifiedClassName)
Given a fully qualified class name (like java.lang.Object), returns only the substring after the last dot character ("e;."e;), i.e. Object instead of java.lang.Object.

Parameters:
qualifiedClassName - a fully qualified Java class name
Returns:
the simple class name

toStringArray

public static java.lang.String[] toStringArray(java.util.Vector strings)
Converts the given Vector to String array

Parameters:
strings - The Vector to convert.
Returns:
The array containing the Vector parts.

chomp

public static java.lang.String chomp(java.lang.String inStr)
Deletes the Line Feed (10) and Carriage Return (13) fields of the given String.

Parameters:
inStr - The String to work on.
Returns:
The string without Line Feed and Carriage Return.

parseStringOptions

public static HashMap parseStringOptions(java.lang.String args)
Parses options from a String. The options are defined as "-name " divided by a blank.

Parameters:
args - the String to parse the options from.
Returns:
Map containing the options properties.

parseStringProperties

public static HashMap parseStringProperties(java.lang.String args)
Parses properties from a String. The properties are defined as "name=value" pairs divided by a blank.

Parameters:
args - the String to parse the properties from.
Returns:
Map containing the properties.

printStream

public static void printStream(java.io.InputStream in)
Prints a stream to System.out.

Parameters:
in - the stream to print.

arrayToStringInt

public static java.lang.String arrayToStringInt(int[] array)
Creates a String from an array of int.

Parameters:
array - the array to show.
Returns:
the String.

arrayToStringByte

public static java.lang.String arrayToStringByte(byte[] array)
Creates a String from an array of byte.

Parameters:
array - the array to show.
Returns:
the String.

arrayToStringLong

public static java.lang.String arrayToStringLong(long[] array)
Creates a String form a array of long.

Parameters:
array - the array to show.
Returns:
the String.

getHTTPDateAsLong

public static long getHTTPDateAsLong(java.lang.String httpDate)

getHTTPDate

public static java.lang.String getHTTPDate(long date)