org.nuiton.i18n.bundle
Class I18nBundleEntry

java.lang.Object
  extended by 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 :

This object defines a equals order base on property path.

This object is Comparable, the order relation is defined like this :

Author:
tchemit
See Also:
I18nBundleScope

Field Summary
protected  Locale locale
          local of the entry, can be null if general scope
protected  URL path
          path to resource file
protected  I18nBundleScope scope
          scope of the entry
 
Constructor Summary
I18nBundleEntry(URL path, Locale locale, I18nBundleScope scope)
          Constructor if an bundle entry.
 
Method Summary
 int compareTo(I18nBundleEntry o)
           
 boolean equals(Object o)
           
 Locale getLocale()
           
 URL getPath()
           
 I18nBundleScope getScope()
           
 int hashCode()
           
 void load(Properties resource)
          For a given language, load the resource file of this entry into the resource properties object.
 boolean matchLocale(Locale locale, I18nBundleScope scope)
          Method to match or not a bundle entry for a given scope and locale.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

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 Detail

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 Detail

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

public void load(Properties resource)
          throws IOException
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

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


Copyright © 2004-2011 CodeLutin. All Rights Reserved.