fr.paris.lutece.util.string
Class StringUtil

java.lang.Object
  extended by fr.paris.lutece.util.string.StringUtil

public final class StringUtil
extends java.lang.Object

This class provides String utils.


Method Summary
static boolean checkAccentuatedCharacter(java.lang.String strString)
          This function checks if an string is in a valid format Returns true if the string is valid
static boolean checkCodeKey(java.lang.String strCodeKey)
          Check a code key.
static boolean checkEmail(java.lang.String strEmail)
          This function checks if an email is in a valid format Returns true if the email is valid
static boolean containsHtmlSpecialCharacters(java.lang.String strValue)
          Checks if a string literal contains any HTML special characters (&, ", ' <, >).
static boolean containsXssCharacters(java.lang.String strValue)
          Checks if a String contains characters that could be used for a cross-site scripting attack.
static boolean containsXssCharacters(java.lang.String strValue, char[] aXssCharacters)
          Checks if a String contains characters that could be used for a cross-site scripting attack.
static boolean containsXssCharacters(java.lang.String strValue, java.lang.String strXssCharacters)
          Checks if a String contains characters that could be used for a cross-site scripting attack.
static int getIntValue(java.lang.String strValue, int nDefaultValue)
          Converts strValue to an int value.
static java.lang.String getXssCharactersAsString()
          Simple convenience method to return the XSS characters as a string, to include it in error messages.
static java.lang.String replaceAccent(java.lang.String strInit)
          This function converts French diacritics characters into non diacritics.
static java.lang.String substitute(java.lang.String strSource, java.lang.String strValue, java.lang.String strBookmark)
          This function substitutes all occurences of a given bookmark by a given value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

substitute

public static java.lang.String substitute(java.lang.String strSource,
                                          java.lang.String strValue,
                                          java.lang.String strBookmark)
This function substitutes all occurences of a given bookmark by a given value

Parameters:
strSource - The input string that contains bookmarks to replace
strValue - The value to substitute to the bookmark
strBookmark - The bookmark name
Returns:
The output string.

replaceAccent

public static java.lang.String replaceAccent(java.lang.String strInit)
This function converts French diacritics characters into non diacritics.

Parameters:
strInit - The String to convert
Returns:
The sTring converted to French non diacritics characters

containsHtmlSpecialCharacters

public static boolean containsHtmlSpecialCharacters(java.lang.String strValue)
Checks if a string literal contains any HTML special characters (&, ", ' <, >).

Parameters:
strValue - The string literal to check
Returns:
True if the string literal contains any special character

containsXssCharacters

public static boolean containsXssCharacters(java.lang.String strValue)
Checks if a String contains characters that could be used for a cross-site scripting attack.

Parameters:
strValue - a character String
Returns:
true if the String contains illegal characters

containsXssCharacters

public static boolean containsXssCharacters(java.lang.String strValue,
                                            char[] aXssCharacters)
Checks if a String contains characters that could be used for a cross-site scripting attack.

Parameters:
strValue - a character String
aXssCharacters - a Xss characters tab to check in strValue
Returns:
true if the String contains illegal characters

containsXssCharacters

public static boolean containsXssCharacters(java.lang.String strValue,
                                            java.lang.String strXssCharacters)
Checks if a String contains characters that could be used for a cross-site scripting attack.

Parameters:
strValue - a character String
strXssCharacters - a String wich contain a list of Xss characters to check in strValue
Returns:
true if the String contains illegal characters

getXssCharactersAsString

public static java.lang.String getXssCharactersAsString()
Simple convenience method to return the XSS characters as a string, to include it in error messages.

Returns:
a String containing a comma-separated list of the XSS characters

checkEmail

public static boolean checkEmail(java.lang.String strEmail)
This function checks if an email is in a valid format Returns true if the email is valid

Parameters:
strEmail - The mail to check
Returns:
boolean true if strEmail is valid

checkAccentuatedCharacter

public static boolean checkAccentuatedCharacter(java.lang.String strString)
This function checks if an string is in a valid format Returns true if the string is valid

Parameters:
strString - The string to check
Returns:
boolean true if r is valid

checkCodeKey

public static boolean checkCodeKey(java.lang.String strCodeKey)
Check a code key.
Return true if each character of String is

Parameters:
strCodeKey - The code Key
Returns:
True if code key is valid

getIntValue

public static int getIntValue(java.lang.String strValue,
                              int nDefaultValue)
Converts strValue to an int value.

Parameters:
strValue - the value to convert
nDefaultValue - the default returned value
Returns:
strValue int value, nDefaultValue if strValue is not an Integer.


Copyright © 2011 Mairie de Paris. All Rights Reserved.