Class I18nBundleEntry

java.lang.Object
org.nuiton.i18n.bundle.I18nBundleEntry
All Implemented Interfaces:
Comparable<I18nBundleEntry>

public class I18nBundleEntry extends Object implements Comparable<I18nBundleEntry>
A class to represent an entry in a bundle. The object matches exactly one resource file in a given scope. The object has three properties :
  • path : the path to resource file where to find transaltion for the entry.
  • locale : the locale of the entry
  • {link #scope} ; the scope of the entry
This object defines a equals order base on property path. This object is Comparable, the order relation is defined like this :
Author:
Tony Chemit - chemit@codelutin.com
See Also:
  • Field Details

    • path

      protected URL path
      path to resource file
    • locale

      protected Locale locale
      local of the entry, can be null if general scope
    • scope

      protected I18nBundleScope scope
      scope of the entry
  • Constructor Details

    • I18nBundleEntry

      public I18nBundleEntry(URL path, Locale locale, I18nBundleScope scope)
      Constructor if an bundle entry. It is defined by a path of the resource file, a scope and a locale.
      Parameters:
      path - the path of the resource file fo the bundle entry
      locale - the given locale of the bundle entry
      scope - the scope of the given entry
  • Method Details

    • getPath

      public URL getPath()
    • getLocale

      public Locale getLocale()
    • getScope

      public I18nBundleScope getScope()
    • matchLocale

      public boolean matchLocale(Locale locale, I18nBundleScope scope)
      Method to match or not a bundle entry for a given scope and locale. We use the inclusive property of scope, means that we accept all entries on the path to the generalest entry for a givne locale.
      Parameters:
      locale - the locale to match
      scope - the highest scope to match
      Returns:
      true if the entry match the scope and locale *
    • load

      @Deprecated public void load(Properties resource) throws IOException
      Deprecated.
      since 2.4 use load(Properties, Charset) instead, charset must be provided to avoid encoding problems
      For a given language, load the resource file of this entry into the resource properties object.
      Parameters:
      resource - the save of resources already loaded
      Throws:
      IOException - if any pb while reading resource file
    • load

      public void load(Properties resource, Charset encoding) throws IOException
      For a given language, load the resource file of this entry into the resource properties object. Use charset to load properties. It could be different from resulting properties store.
      Parameters:
      resource - the save of resources already loaded
      encoding - Charset used to store the properties
      Throws:
      IOException - if any pb while reading resource file
      Since:
      2.4
    • compareTo

      public int compareTo(I18nBundleEntry o)
      Specified by:
      compareTo in interface Comparable<I18nBundleEntry>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object