Class I18nBundleEntry

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

public class I18nBundleEntry
extends java.lang.Object
implements java.lang.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:
I18nBundleScope
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.util.Locale locale
    local of the entry, can be null if general scope
    protected java.net.URL path
    path to resource file
    protected I18nBundleScope scope
    scope of the entry
  • Constructor Summary

    Constructors 
    Constructor Description
    I18nBundleEntry​(java.net.URL path, java.util.Locale locale, I18nBundleScope scope)
    Constructor if an bundle entry.
  • Method Summary

    Modifier and Type Method Description
    int compareTo​(I18nBundleEntry o)  
    boolean equals​(java.lang.Object o)  
    java.util.Locale getLocale()  
    java.net.URL getPath()  
    I18nBundleScope getScope()  
    int hashCode()  
    void load​(java.util.Properties resource)
    Deprecated.
    since 2.4 use load(Properties, Charset) instead, charset must be provided to avoid encoding problems
    void load​(java.util.Properties resource, java.nio.charset.Charset encoding)
    For a given language, load the resource file of this entry into the resource properties object.
    boolean matchLocale​(java.util.Locale locale, I18nBundleScope scope)
    Method to match or not a bundle entry for a given scope and locale.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • path

      protected java.net.URL path
      path to resource file
    • locale

      protected java.util.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​(java.net.URL path, java.util.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 java.net.URL getPath()
    • getLocale

      public java.util.Locale getLocale()
    • getScope

      public I18nBundleScope getScope()
    • matchLocale

      public boolean matchLocale​(java.util.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​(java.util.Properties resource) throws java.io.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:
      java.io.IOException - if any pb while reading resource file
    • load

      public void load​(java.util.Properties resource, java.nio.charset.Charset encoding) throws java.io.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:
      java.io.IOException - if any pb while reading resource file
      Since:
      2.4
    • compareTo

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

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

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

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object