org.olat.core.util
Class StringHelper

java.lang.Object
  extended by org.olat.core.util.StringHelper

public class StringHelper
extends java.lang.Object

enclosing_type Description:
helper class for formating Strings (not locale specific)

Author:
Felix Jost

Field Summary
static java.lang.String ALL_WITHOUT_COMMA_2POINT_STRPNT
          regex for not allowing ;,: ALL_WITHOUT_COMMA_2POINT_STRPNT
 
Constructor Summary
StringHelper()
           
 
Method Summary
static java.lang.String check4xMacRoman(java.lang.String extractedCharset)
           
static boolean containsNoneOfCoDouSemi(java.lang.String s)
          matches any but ^[^,;:]*$
static boolean containsNonWhitespace(java.lang.String s)
          Checks if a string has anything in it to display.
static java.lang.String formatAsCSVString(java.util.List<java.lang.String> entries)
          list of strings to one string comma separated.
e.g.
static java.lang.String formatAsCSVString(java.util.Set<java.lang.String> entries)
          set of strings to one string comma separated.
e.g.
static java.lang.String formatFloat(float f, int fractionDigits)
           
static java.lang.String formatIdentitesAsEmailToString(Identity[] emailRecipientIdentities)
          takes an array of Identies and converts them to a String containing the Identity-Emails separated by a , .
static java.lang.String formatIdentitesAsEmailToString(java.util.List emailRecipients, java.lang.String delimiter)
          takes a List containing email Strings and converts them to a String containing the Email Strings separated by a , .
static java.lang.String formatLocaleDate(long date, java.util.Locale locale)
           
static java.lang.String formatLocaleDateFull(long date, java.util.Locale locale)
           
static java.lang.String formatLocaleDateTime(long date, java.util.Locale locale)
           
static java.lang.String formatLocaleTime(long time, java.util.Locale locale)
           
static java.lang.String formatMemory(long mem)
           
static java.lang.String[] getMapKeysAsStringArray(java.util.Map m)
          Converts all keys of a hash map to a string array.
static java.lang.String[] getMapValuesAsStringArray(java.util.Map m)
          Converts all values of a hash map to a string array.
static java.util.List getParts(java.lang.String in, java.lang.String delim)
          unused
static java.lang.String stripLineBreaks(java.lang.String cellValue)
           
static java.lang.String transformDisplayNameToFileSystemName(java.lang.String s)
          transforms a displayname to a name that causes no problems on the filesystem (e.g.
static java.lang.String urlEncodeISO88591(java.lang.String url)
           
static java.lang.String urlEncodeUTF8(java.lang.String url)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_WITHOUT_COMMA_2POINT_STRPNT

public static final java.lang.String ALL_WITHOUT_COMMA_2POINT_STRPNT
regex for not allowing ;,: ALL_WITHOUT_COMMA_2POINT_STRPNT

See Also:
Constant Field Values
Constructor Detail

StringHelper

public StringHelper()
Method Detail

getParts

public static java.util.List getParts(java.lang.String in,
                                      java.lang.String delim)
unused

Parameters:
in -
delim -
Returns:
List

formatLocaleDate

public static java.lang.String formatLocaleDate(long date,
                                                java.util.Locale locale)
Parameters:
date -
locale -
Returns:
formatted date

formatLocaleDateFull

public static java.lang.String formatLocaleDateFull(long date,
                                                    java.util.Locale locale)
Parameters:
date -
locale -
Returns:
formatted date

formatLocaleDateTime

public static java.lang.String formatLocaleDateTime(long date,
                                                    java.util.Locale locale)
Parameters:
date -
locale -
Returns:
formatted date/time

formatLocaleTime

public static java.lang.String formatLocaleTime(long time,
                                                java.util.Locale locale)
Parameters:
time -
locale -
Returns:
formatted time

formatMemory

public static java.lang.String formatMemory(long mem)
Parameters:
mem -
Returns:
formatted memory

formatFloat

public static java.lang.String formatFloat(float f,
                                           int fractionDigits)
Parameters:
f -
fractionDigits -
Returns:
formatted float

urlEncodeISO88591

public static java.lang.String urlEncodeISO88591(java.lang.String url)
Parameters:
url -
Returns:
encoded string

urlEncodeUTF8

public static java.lang.String urlEncodeUTF8(java.lang.String url)
Parameters:
url -
Returns:
encoded string

getMapKeysAsStringArray

public static java.lang.String[] getMapKeysAsStringArray(java.util.Map m)
Converts all keys of a hash map to a string array.

Parameters:
m - The (hash) map with the key and values
Returns:
The string array containing all keys for this map

getMapValuesAsStringArray

public static java.lang.String[] getMapValuesAsStringArray(java.util.Map m)
Converts all values of a hash map to a string array.

Parameters:
m - The (hash) map with the key and values
Returns:
The string array containing all values for this map

containsNoneOfCoDouSemi

public static boolean containsNoneOfCoDouSemi(java.lang.String s)
matches any but ^[^,;:]*$

Parameters:
s -
Returns:
true if does not match regexp

containsNonWhitespace

public static boolean containsNonWhitespace(java.lang.String s)
Checks if a string has anything in it to display. Will return true if the string is not null and does contain at least one none-whitespace character.

Parameters:
s - The String to be evaluated
Returns:
true if the string contains any non-whitespace character, false otherwhise

formatIdentitesAsEmailToString

public static java.lang.String formatIdentitesAsEmailToString(Identity[] emailRecipientIdentities)
takes an array of Identies and converts them to a String containing the Identity-Emails separated by a , . The returned String can be fed directly to the e-mailer helper as the e-mail to field.

Parameters:
emailRecipientIdentities -
Returns:
"email1, email2, email3," or null if emailRecipientIdentites was null

formatIdentitesAsEmailToString

public static java.lang.String formatIdentitesAsEmailToString(java.util.List emailRecipients,
                                                              java.lang.String delimiter)
takes a List containing email Strings and converts them to a String containing the Email Strings separated by a , . The returned String can be fed directly to the e-mailer helper as the e-mail to field.

Parameters:
emailRecipients -
delimiter -
Returns:
"email1, email2, email3," or null if emailRecipientIdentites was null

stripLineBreaks

public static java.lang.String stripLineBreaks(java.lang.String cellValue)
Parameters:
cellValue -
Returns:
stripped string

transformDisplayNameToFileSystemName

public static java.lang.String transformDisplayNameToFileSystemName(java.lang.String s)
transforms a displayname to a name that causes no problems on the filesystem (e.g. Webclass Energie 2004/2005 -> Webclass_Energie_2004_2005)

Parameters:
s -
Returns:
transformed string

check4xMacRoman

public static java.lang.String check4xMacRoman(java.lang.String extractedCharset)
Parameters:
extractedCharset -
Returns:

formatAsCSVString

public static java.lang.String formatAsCSVString(java.util.Set<java.lang.String> entries)
set of strings to one string comma separated.
e.g. ["a","b","c","s"] -> "a,b,c,s"

Parameters:
selection -
Returns:

formatAsCSVString

public static java.lang.String formatAsCSVString(java.util.List<java.lang.String> entries)
list of strings to one string comma separated.
e.g. ["a","b","c","s"] -> "a,b,c,s"

Parameters:
selection -
Returns: