net.lightoze.gwt.i18n.server.FallbackChainLocaleProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwt-i18n-server Show documentation
Show all versions of gwt-i18n-server Show documentation
A project to make GWT localization available on server side.
package net.lightoze.gwt.i18n.server;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
/**
* @author Vladimir Kulev
*/
public class FallbackChainLocaleProvider implements LocaleProvider {
private LinkedList chain = new LinkedList();
public FallbackChainLocaleProvider(List chain) {
this.chain.addAll(chain);
}
public void addLast(LocaleProvider provider) {
chain.addLast(provider);
}
public void addFirst(LocaleProvider provider) {
chain.addFirst(provider);
}
public void remove(LocaleProvider provider) {
chain.remove(provider);
}
public List getChain() {
return Collections.unmodifiableList(chain);
}
@Override
public Locale getLocale() {
for (LocaleProvider provider : chain) {
Locale locale = provider.getLocale();
if (locale != null) {
return locale;
}
}
return null;
}
}