Package org.nuiton.i18n
Class I18nUtil
java.lang.Object
org.nuiton.i18n.I18nUtil
public class I18nUtil
extends java.lang.Object
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
Fields Modifier and Type Field Description static java.nio.charset.CharsetDEFAULT_CHARSETstatic java.lang.StringDEFAULT_ENCODINGstatic java.util.LocaleDEFAULT_LOCALEstatic I18nMessageFormatterDEFAULT_MESSAGE_FORMATTERstatic java.lang.String[]EMPTY_STRING_ARRAYstatic java.lang.StringISO_8859_1_ENCODINGstatic org.nuiton.converter.LocaleConverterLOCALE_CONVERTERstatic java.lang.StringUTF_8_ENCODING -
Constructor Summary
Constructors Constructor Description I18nUtil() -
Method Summary
Modifier and Type Method Description static booleancontainsDirectDirectory(java.net.URL url, java.lang.String directory)Test if an url contains the given directory with no recurse seeking.static java.net.URL[]getClassPathURLsFromJarManifest(java.net.URL jarURL)static java.net.URL[]getDeepURLs(java.net.URLClassLoader loader)Returns the all urls to be used in aURLClassLoader.static java.net.URL[]getURLs(java.net.URLClassLoader classLoader)Recupere la liste des urls d'unURLClassLoader.static java.util.List<java.net.URL>getURLsFromDirectory(java.io.File repository, java.lang.String pattern)Retourne la liste des fichiers correspondant au pattern donne, aucun ordre ne doit être supposé sur les fichiers.static booleanisJar(java.lang.String name)Verifie si le fichier est un fichier jar.static booleanisZip(java.lang.String name)Verifie si le fichier est un fichier zipstatic java.util.LocalenewLocale(java.lang.String str)static java.util.LocalenewLocale(java.lang.String language, java.lang.String country)static java.util.Locale[]parseLocales(java.lang.String str)Parse a list ofLocaleseperated by comma.static java.util.Optional<java.net.URL[]>tryGetDeepURLs(java.lang.ClassLoader loader)Returns the all URLs to be used in aClassLoader.
-
Field Details
-
ISO_8859_1_ENCODING
public static final java.lang.String ISO_8859_1_ENCODING- See Also:
- Constant Field Values
-
UTF_8_ENCODING
public static final java.lang.String UTF_8_ENCODING- See Also:
- Constant Field Values
-
DEFAULT_ENCODING
public static final java.lang.String DEFAULT_ENCODING- See Also:
- Constant Field Values
-
DEFAULT_CHARSET
public static final java.nio.charset.Charset DEFAULT_CHARSET -
DEFAULT_MESSAGE_FORMATTER
-
DEFAULT_LOCALE
public static final java.util.Locale DEFAULT_LOCALE -
EMPTY_STRING_ARRAY
public static final java.lang.String[] EMPTY_STRING_ARRAY -
LOCALE_CONVERTER
public static final org.nuiton.converter.LocaleConverter LOCALE_CONVERTER
-
-
Constructor Details
-
I18nUtil
public I18nUtil()
-
-
Method Details
-
parseLocales
public static java.util.Locale[] parseLocales(java.lang.String str) throws java.lang.IllegalArgumentExceptionParse a list ofLocaleseperated by comma. Example : fr_FR,en_GB- Parameters:
str- the string representation of locale separated by comma- Returns:
- list of available locales
- Throws:
java.lang.IllegalArgumentException- ia a locale is not valid
-
newLocale
public static java.util.Locale newLocale(java.lang.String str) -
newLocale
public static java.util.Locale newLocale(java.lang.String language, java.lang.String country) -
containsDirectDirectory
public static boolean containsDirectDirectory(java.net.URL url, java.lang.String directory) throws java.io.IOExceptionTest if an url contains the given directory with no recurse seeking.- Parameters:
url- the url to seekdirectory- the directory to find- Returns:
trueif directory was found,falseotherwise.- Throws:
java.io.IOException- if any io pb
-
isJar
public static boolean isJar(java.lang.String name)Verifie si le fichier est un fichier jar.- Parameters:
name- nom du fichier a tester- Returns:
- vrai si le fichier se termine par .jar faux sinon
-
isZip
public static boolean isZip(java.lang.String name)Verifie si le fichier est un fichier zip- Parameters:
name- nom du fichier a tester- Returns:
- vrai si le fichier se termine par .zip faux sinon
-
getURLsFromDirectory
public static java.util.List<java.net.URL> getURLsFromDirectory(java.io.File repository, java.lang.String pattern)Retourne la liste des fichiers correspondant au pattern donne, aucun ordre ne doit être supposé sur les fichiers.- Parameters:
repository- repertoire dans lequel on recherche les fichierspattern- le nom du fichier a extraire du fichier du repertoire doit correspondre au pattern (repertoire + nom compris). si le pattern est null, tous les fichiers trouvé sont retourné.- Returns:
- la liste des urls correspondant au pattern
-
tryGetDeepURLs
public static java.util.Optional<java.net.URL[]> tryGetDeepURLs(java.lang.ClassLoader loader)Returns the all URLs to be used in aClassLoader. If the given classloader is an URLClassLoader, will do the same asgetDeepURLs(URLClassLoader). Otherwise this method will try to find URLs by another way.- Parameters:
loader- the classloader (if null will use system one)- Returns:
- all the url found in the classloader if applicable
- See Also:
getDeepURLs(URLClassLoader)
-
getDeepURLs
public static java.net.URL[] getDeepURLs(java.net.URLClassLoader loader)Returns the all urls to be used in aURLClassLoader. If classloader has only one url and the url is a jar, try to load in manifest class-path.- Parameters:
loader- the classloader (if null will use system one)- Returns:
- all the url found in the classloader
-
getURLs
public static java.net.URL[] getURLs(java.net.URLClassLoader classLoader)Recupere la liste des urls d'unURLClassLoader. Note : Un cas particulier est positionné pour JBoss qui utilise la method getAllURLs.- Parameters:
classLoader- le class loader a scanner- Returns:
- les urls du classloade.
-
getClassPathURLsFromJarManifest
public static java.net.URL[] getClassPathURLsFromJarManifest(java.net.URL jarURL) throws java.io.IOException, java.net.URISyntaxException- Throws:
java.io.IOExceptionjava.net.URISyntaxException
-