com.cc.framework.util
Class StringHelp

java.lang.Object
  extended bycom.cc.framework.util.StringHelp

public abstract class StringHelp
extends java.lang.Object

Helper class for string operations.

Since:
1.0
Version:
$Revision: 1.32 $
Author:
Harald Schulz

Field Summary
static java.lang.String CRLF
          Code for carriage return
 
Constructor Summary
private StringHelp()
          Constructor
 
Method Summary
static java.lang.String expand(java.lang.String str, java.util.Map macros)
          This method expands the markups (Format %macro%) in a string by the specified macros.
static java.lang.String fill(java.lang.Object obj, int fillLength, char fillChar)
          Fills a String with the specified pattern till the specified length.
static boolean isWhitespaceOnlyStr(java.lang.String str)
          Checks if a String contains only Whitespace characters
static java.lang.String join(java.util.Collection tokens, char delimiter)
          Joins an array and inserts the specified delimiter between the array elements.
static java.lang.String join(java.util.Collection tokens, java.lang.String delimiter)
          Joins an array and inserts the specified delimiter between the array elements.
static java.lang.String join(java.lang.Object[] tokens, char delimiter)
          Joins an array and inserts the specified delimiter between the array elements.
static java.lang.String join(java.lang.String token, int repeat, char delimiter)
          Joins on token.
static java.lang.String join(java.lang.String t1, java.lang.String t2, char delimiter)
          Joins two strings and inserts the specified delimiter between the string.
static java.lang.String join(java.lang.String t1, java.lang.String t2, java.lang.String t3, char delimiter)
          Joins three strings and inserts the specified delimiter between the string.
static java.lang.String join(java.lang.String t1, java.lang.String t2, java.lang.String t3, java.lang.String t4, char delimiter)
          Joins four strings and inserts the specified delimiter between the string.
static boolean safeequals(java.lang.Object o1, java.lang.Object o2)
          Method safe equals
static java.lang.String safetrim(java.lang.String str)
          Removes white spaces at the end of a string.
static java.lang.String[] split(java.lang.String text, java.lang.String delimiter)
          Splits the provided text into a list, based on a given separator.
static java.lang.String[] splitRetainEmpty(java.lang.String text, char delimiter)
          Splits the provided text into a list, based on a given separator.
static java.lang.String strcat(java.util.List tokens)
          Concatenates an array of Objects.
static java.lang.String strcat(java.lang.String[] tokens)
          Concatenates an array.
static java.lang.String strcat(java.lang.String t1, java.lang.String t2)
          Concatenates two strings
static java.lang.String strcat(java.lang.String t1, java.lang.String t2, java.lang.String t3)
          Concatenates three strings
static java.lang.String strcat(java.lang.String t1, java.lang.String t2, java.lang.String t3, java.lang.String t4)
          Concatenates four strings
static java.lang.String strcat(java.lang.String t1, java.lang.String t2, java.lang.String t3, java.lang.String t4, java.lang.String t5)
          Concatenates four strings
static java.lang.String[] toStringArray(java.lang.Object value)
          Transforms an object into a String Array
static java.util.Set toStringSet(java.lang.Object[] values)
          Transforms an object into a String Set
static java.lang.String trimRight(java.lang.String str)
          Trims a String
static java.lang.String truncate(java.lang.String str, int maxlength)
          Truncates a given string to a maximum number of characters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CRLF

public static final java.lang.String CRLF
Code for carriage return

See Also:
Constant Field Values
Constructor Detail

StringHelp

private StringHelp()
Constructor

Method Detail

isWhitespaceOnlyStr

public static boolean isWhitespaceOnlyStr(java.lang.String str)
Checks if a String contains only Whitespace characters

Parameters:
str - String to test
Returns:
returns if the string contains only whitespace Characters

toStringArray

public static java.lang.String[] toStringArray(java.lang.Object value)
Transforms an object into a String Array

Parameters:
value - Object
Returns:
Array of Strings

toStringSet

public static java.util.Set toStringSet(java.lang.Object[] values)
Transforms an object into a String Set

Parameters:
values - String Array
Returns:
Set of Strings

truncate

public static java.lang.String truncate(java.lang.String str,
                                        int maxlength)
Truncates a given string to a maximum number of characters

Parameters:
str - The string to truncate
maxlength - The maximum number of characters
Returns:
truncated string

fill

public static java.lang.String fill(java.lang.Object obj,
                                    int fillLength,
                                    char fillChar)
Fills a String with the specified pattern till the specified length.

Parameters:
obj - String
fillLength - length
fillChar - pattern
Returns:
String

safetrim

public static java.lang.String safetrim(java.lang.String str)
Removes white spaces at the end of a string. This function takes care of NULL-Values. This function should be used if CHAR(x) columns are read from a database because this values are filled up to the specified length with white spaces.

Parameters:
str - String
Returns:
String

trimRight

public static java.lang.String trimRight(java.lang.String str)
Trims a String

Parameters:
str - String to trim
Returns:
String

safeequals

public static boolean safeequals(java.lang.Object o1,
                                 java.lang.Object o2)
Method safe equals

Parameters:
o1 - Object1
o2 - Object2
Returns:
boolean

split

public static java.lang.String[] split(java.lang.String text,
                                       java.lang.String delimiter)
Splits the provided text into a list, based on a given separator. The separator is not included in the returned String array. The maximum number of splits to perform can be controlled. A null separator will cause parsing to be on whitespace.

Parameters:
text - The string to parse
delimiter - The delimiter character. If null, splits on whitespace.
Returns:
an array of parsed Strings

splitRetainEmpty

public static java.lang.String[] splitRetainEmpty(java.lang.String text,
                                                  char delimiter)
Splits the provided text into a list, based on a given separator. The separator is not included in the returned String array. The maximum number of splits to perform can be controlled. A null separator will cause parsing to be on whitespace.

Parameters:
text - The string to parse
delimiter - The delimiter character. If null, splits on whitespace.
Returns:
an array of parsed Strings

join

public static java.lang.String join(java.lang.Object[] tokens,
                                    char delimiter)
Joins an array and inserts the specified delimiter between the array elements.

Parameters:
tokens - The tokens to join
delimiter - The delimiter to insert between the tokens
Returns:
String

join

public static java.lang.String join(java.lang.String token,
                                    int repeat,
                                    char delimiter)
Joins on token.

Parameters:
token - The token to join
repeat - The repeat count
delimiter - The delimiter to insert between the tokens
Returns:
String

join

public static java.lang.String join(java.util.Collection tokens,
                                    java.lang.String delimiter)
Joins an array and inserts the specified delimiter between the array elements.

Parameters:
tokens - The tokens to join
delimiter - The delimiter to insert between the tokens
Returns:
String

join

public static java.lang.String join(java.util.Collection tokens,
                                    char delimiter)
Joins an array and inserts the specified delimiter between the array elements.

Parameters:
tokens - The tokens to join
delimiter - The delimiter to insert between the tokens
Returns:
String

join

public static java.lang.String join(java.lang.String t1,
                                    java.lang.String t2,
                                    char delimiter)
Joins two strings and inserts the specified delimiter between the string.

Parameters:
t1 - String1
t2 - String2
delimiter - The delimiter to used
Returns:
String

join

public static java.lang.String join(java.lang.String t1,
                                    java.lang.String t2,
                                    java.lang.String t3,
                                    char delimiter)
Joins three strings and inserts the specified delimiter between the string.

Parameters:
t1 - String1
t2 - String2
t3 - String3
delimiter - The delimiter to used
Returns:
String

join

public static java.lang.String join(java.lang.String t1,
                                    java.lang.String t2,
                                    java.lang.String t3,
                                    java.lang.String t4,
                                    char delimiter)
Joins four strings and inserts the specified delimiter between the string.

Parameters:
t1 - String1
t2 - String2
t3 - String3
t4 - String4
delimiter - The delimiter to used
Returns:
String

strcat

public static java.lang.String strcat(java.lang.String[] tokens)
Concatenates an array.

Parameters:
tokens - The tokens to join
Returns:
String

strcat

public static java.lang.String strcat(java.util.List tokens)
Concatenates an array of Objects.

Parameters:
tokens - The tokens to join
Returns:
String

strcat

public static java.lang.String strcat(java.lang.String t1,
                                      java.lang.String t2)
Concatenates two strings

Parameters:
t1 - String1
t2 - String2
Returns:
String

strcat

public static java.lang.String strcat(java.lang.String t1,
                                      java.lang.String t2,
                                      java.lang.String t3)
Concatenates three strings

Parameters:
t1 - String1
t2 - String2
t3 - String3
Returns:
String

strcat

public static java.lang.String strcat(java.lang.String t1,
                                      java.lang.String t2,
                                      java.lang.String t3,
                                      java.lang.String t4)
Concatenates four strings

Parameters:
t1 - String1
t2 - String2
t3 - String3
t4 - String4
Returns:
String

strcat

public static java.lang.String strcat(java.lang.String t1,
                                      java.lang.String t2,
                                      java.lang.String t3,
                                      java.lang.String t4,
                                      java.lang.String t5)
Concatenates four strings

Parameters:
t1 - String1
t2 - String2
t3 - String3
t4 - String4
t5 - String5
Returns:
String

expand

public static java.lang.String expand(java.lang.String str,
                                      java.util.Map macros)
This method expands the markups (Format %macro%) in a string by the specified macros.

Parameters:
str - String to expand
macros - Map with macros
Returns:
Bei erfolgreicher Ausführung wird die expandierte Zeichenkette zurückgegeben


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.