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.Charset DEFAULT_CHARSET  
    static java.lang.String DEFAULT_ENCODING  
    static java.util.Locale DEFAULT_LOCALE  
    static I18nMessageFormatter DEFAULT_MESSAGE_FORMATTER  
    static java.lang.String[] EMPTY_STRING_ARRAY  
    static java.lang.String ISO_8859_1_ENCODING  
    static org.nuiton.converter.LocaleConverter LOCALE_CONVERTER  
    static java.lang.String UTF_8_ENCODING  
  • Constructor Summary

    Constructors 
    Constructor Description
    I18nUtil()  
  • Method Summary

    Modifier and Type Method Description
    static boolean containsDirectDirectory​(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 a URLClassLoader.
    static java.net.URL[] getURLs​(java.net.URLClassLoader classLoader)
    Recupere la liste des urls d'un URLClassLoader.
    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 boolean isJar​(java.lang.String name)
    Verifie si le fichier est un fichier jar.
    static boolean isZip​(java.lang.String name)
    Verifie si le fichier est un fichier zip
    static java.util.Locale newLocale​(java.lang.String str)  
    static java.util.Locale newLocale​(java.lang.String language, java.lang.String country)  
    static java.util.Locale[] parseLocales​(java.lang.String str)
    Parse a list of Locale seperated by comma.
    static java.util.Optional<java.net.URL[]> tryGetDeepURLs​(java.lang.ClassLoader loader)
    Returns the all URLs to be used in a ClassLoader.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • parseLocales

      public static java.util.Locale[] parseLocales​(java.lang.String str) throws java.lang.IllegalArgumentException
      Parse a list of Locale seperated 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.IOException
      Test if an url contains the given directory with no recurse seeking.
      Parameters:
      url - the url to seek
      directory - the directory to find
      Returns:
      true if directory was found, false otherwise.
      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 fichiers
      pattern - 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 a ClassLoader. If the given classloader is an URLClassLoader, will do the same as getDeepURLs(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 a URLClassLoader. 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'un URLClassLoader. 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.IOException
      java.net.URISyntaxException