com.ideo.sweetdev.core.util
Class FormatString

java.lang.Object
  extended bycom.ideo.sweetdev.core.util.FormatString

public class FormatString
extends java.lang.Object

FormatString

 

Field Summary
static java.lang.String CARRIAGERETURN
          carriage return (\\n)
static java.lang.String HTMLCARRIAGERETURN
          html carriage return (\)
 
Constructor Summary
protected FormatString()
          Constructor
 
Method Summary
static java.lang.String addParameterToUrl(java.lang.String _url, java.lang.String _parameter, java.lang.String _value)
          This method add a parameter and his value in an URL (for GET request).
static java.lang.String beginZero(int _i, int _size)
          Prefixe l'entier _i d'autant de zeros necessaire pour que la taille de la String correspondante soit de _size
static java.lang.String beginZero(java.lang.String _number, int _size)
          This method add zero at the beginning.
static java.lang.String buildRequestQueryString(java.lang.String _uriPath, java.util.Map _parameters)
          Build Path with QueryString.
static java.lang.String formatFloat(java.lang.String _number, int _size, java.util.Locale _locale)
          formatFloat converti un flottant stocke en flottant avec size x chiffre
static java.lang.String formatString(java.lang.String _message, java.lang.Object[] _parameters)
          This method has the same behavior than the MessageFormat.format() method, except that it does not remove all quote in the given message
static java.lang.String formatStringToLength(java.lang.String _s, int _size)
          Allonge la chaine _s en lui rajoutant a la fin autant de caracteres blank que necessaire pour qu'elle atteigne _size.
static java.lang.String formatStringToLength(java.lang.String _s, int _size, char _c)
          Allonge la chaine _s en lui rajoutant a la fin autant de caracteres _c que necessaire pour qu'elle atteigne _size.
static java.lang.String generateCoupleParameterValue(java.util.Map.Entry _entry)
          Build the couple Parameter, Value for QueryString.
static boolean isNumeric(java.lang.String _chaine)
          This method checks if a string is composed by numerics.
static java.lang.String removeDoubleQuote(java.lang.String _string)
          This method removes the double quotes in a string.
static java.lang.String replace(java.lang.String _initialString, java.lang.String _stringWouldBeReplace, java.lang.String _newString)
          This method replace the first String contained in another String by another String
static java.lang.String replaceAll(java.lang.String _initialString, java.lang.String _stringWouldBeReplace, java.lang.String _newString)
          This method replace the first String contained in another String by another String
static java.lang.String replaceComaByPoint(java.lang.String _chaine)
          This method replace the coma by the point.
static java.lang.String replacePointByComa(java.lang.String _chaine)
          This method replace the point by the coma.
static java.lang.String replaceSimpleQuoteDoubleQuote(java.lang.String _string)
          This method replace the SimpleQuote by the double quotes in a string.
static java.lang.String textToHTML(java.lang.String _txt)
          Name textToHTML
static java.lang.String upperCaseFirstLetter(java.lang.String _string)
          upperCaseFirstLetter This method transform all letter in lower case and excepted the first in upper case
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTMLCARRIAGERETURN

public static final java.lang.String HTMLCARRIAGERETURN
html carriage return (\)

See Also:
Constant Field Values

CARRIAGERETURN

public static final java.lang.String CARRIAGERETURN
carriage return (\\n)

See Also:
Constant Field Values
Constructor Detail

FormatString

protected FormatString()
Constructor

Method Detail

generateCoupleParameterValue

public static java.lang.String generateCoupleParameterValue(java.util.Map.Entry _entry)
Build the couple Parameter, Value for QueryString. NB: This method can be redefined to generate Parameter with multiple values [array for instance].

Parameters:
_entry - Map.Entry entry [ParameterName, ParameterValue].
Returns:
String piece of QueryString for Parameter.

buildRequestQueryString

public static java.lang.String buildRequestQueryString(java.lang.String _uriPath,
                                                       java.util.Map _parameters)
Build Path with QueryString.

Parameters:
_uriPath - String original path without any parameter.
_parameters - Map of couples [ParameterName, ParameterValue].
Returns:
String PathwithQueryString.

textToHTML

public static java.lang.String textToHTML(java.lang.String _txt)
Name textToHTML

Parameters:
_txt - text to be formatted
Returns:
String well formatted

removeDoubleQuote

public static java.lang.String removeDoubleQuote(java.lang.String _string)
This method removes the double quotes in a string.

Parameters:
_string - The string with the double quotes.
Returns:
String The string without the double quotes.

upperCaseFirstLetter

public static java.lang.String upperCaseFirstLetter(java.lang.String _string)
upperCaseFirstLetter This method transform all letter in lower case and excepted the first in upper case

Parameters:
_string - to be formatted
Returns:
String string formatted

beginZero

public static java.lang.String beginZero(int _i,
                                         int _size)
Prefixe l'entier _i d'autant de zeros necessaire pour que la taille de la String correspondante soit de _size

Parameters:
_i - entier
_size - taille en sortie
Returns:
String dont la taille de la String vaut _size

beginZero

public static java.lang.String beginZero(java.lang.String _number,
                                         int _size)
This method add zero at the beginning.

Parameters:
_number - String to be formatted
_size - number of zero
Returns:
String string formatted

replaceSimpleQuoteDoubleQuote

public static java.lang.String replaceSimpleQuoteDoubleQuote(java.lang.String _string)
This method replace the SimpleQuote by the double quotes in a string.

Parameters:
_string - The string with the simple quotes.
Returns:
String The string with the double quotes.

replacePointByComa

public static java.lang.String replacePointByComa(java.lang.String _chaine)
This method replace the point by the coma.

Parameters:
_chaine - The string with the point.
Returns:
String The string with the coma.

formatFloat

public static java.lang.String formatFloat(java.lang.String _number,
                                           int _size,
                                           java.util.Locale _locale)
formatFloat converti un flottant stocke en flottant avec size x chiffre

Parameters:
_number - le nombre a formatter
_size - nombre de chiffre après la virgule
_locale - si la langue utilisé est le français, on utilise une virgule, sinon un point
Returns:
String le nombre formatte

isNumeric

public static boolean isNumeric(java.lang.String _chaine)
This method checks if a string is composed by numerics.

Parameters:
_chaine - The string to checked.
Returns:
boolean true or false.

replaceComaByPoint

public static java.lang.String replaceComaByPoint(java.lang.String _chaine)
This method replace the coma by the point.

Parameters:
_chaine - The string with the coma.
Returns:
String The string with the point.

replace

public static java.lang.String replace(java.lang.String _initialString,
                                       java.lang.String _stringWouldBeReplace,
                                       java.lang.String _newString)
This method replace the first String contained in another String by another String

Parameters:
_initialString - InitialString
_stringWouldBeReplace - String would be replace
_newString - The new String
Returns:
String String formatted

replaceAll

public static java.lang.String replaceAll(java.lang.String _initialString,
                                          java.lang.String _stringWouldBeReplace,
                                          java.lang.String _newString)
This method replace the first String contained in another String by another String

Parameters:
_initialString - InitialString
_stringWouldBeReplace - String would be replace
_newString - The new String
Returns:
String String formatted

addParameterToUrl

public static java.lang.String addParameterToUrl(java.lang.String _url,
                                                 java.lang.String _parameter,
                                                 java.lang.String _value)
This method add a parameter and his value in an URL (for GET request). If a '?' is already present in the url, this method add the parameter after a '&'

Parameters:
_url - The original URL without the new parameter
_parameter - the parameter to add
_value - the parameter value
Returns:
the URL with the new parameter

formatString

public static java.lang.String formatString(java.lang.String _message,
                                            java.lang.Object[] _parameters)
This method has the same behavior than the MessageFormat.format() method, except that it does not remove all quote in the given message

Parameters:
_message - message to format
_parameters - messages parameters
Returns:
formatted message

formatStringToLength

public static java.lang.String formatStringToLength(java.lang.String _s,
                                                    int _size)
Allonge la chaine _s en lui rajoutant a la fin autant de caracteres blank que necessaire pour qu'elle atteigne _size.

Parameters:
_s - Chaine a formater
_size - Taille de la chaine en retour (sauf si _s.length() > _size)
Returns:
Chaine formatée, ou _s si _s.length() > _size

formatStringToLength

public static java.lang.String formatStringToLength(java.lang.String _s,
                                                    int _size,
                                                    char _c)
Allonge la chaine _s en lui rajoutant a la fin autant de caracteres _c que necessaire pour qu'elle atteigne _size.

Parameters:
_s - Chaine a formater
_size - Taille de la chaine en retour (sauf si _s.length() > _size)
_c - Caractere a ajouter en fin de chaine
Returns:
Chaine formatée, ou _s si _s.length() > _size