* @see org.apache.pluto.om.common.LanguageSet#get(java.util.Locale)
*/
public Language get( Locale locale )
{
Language fallBack = null;
Iterator searchItr = innerCollection.iterator();
while (searchItr.hasNext())
{
Language lang = (Language) searchItr.next();
if (lang.getLocale().equals(locale))
{
if (resources != null)
{
LanguageImpl language = (LanguageImpl)createLanguage(lang.getLocale(), loadResourceBundle(lang.getLocale()),"","","");
language.setTitle(lang.getTitle());
language.setShortTitle(lang.getShortTitle());
language.setKeywords(StringUtils.join(lang.getKeywords(), ","));
return language;
}
else
{
return lang;
}
}
else if (lang.getLocale().getLanguage().equals(locale.getLanguage()))
{
fallBack = lang;
}
}
if (fallBack != null && resources != null)
{
LanguageImpl language = (LanguageImpl)createLanguage(fallBack.getLocale(), loadResourceBundle(fallBack.getLocale()),"","","");
language.setTitle(fallBack.getTitle());
language.setShortTitle(fallBack.getShortTitle());
language.setKeywords(StringUtils.join(fallBack.getKeywords(), ","));
fallBack = language;
}
if (fallBack == null)
{
if(!getDefaultLocale().equals(locale))
{
Language defaultLang=get(getDefaultLocale());
fallBack = new LanguageImpl(locale, loadResourceBundle(locale), defaultLang.getTitle(), defaultLang.getShortTitle(), StringUtils.join(defaultLang.getKeywords(), ","));
}
else
{
fallBack = new LanguageImpl(locale, loadResourceBundle(locale), "","","");
}