Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultCallMeta.java @ 59:8cd770330f1b
Added path to chart template and added a method to retrieve its configuration.
artifacts/trunk@361 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 23 Nov 2009 16:56:47 +0000 |
parents | 3a668da76463 |
children | 48d1a9a082c2 |
line wrap: on
line source
package de.intevation.artifactdatabase; import java.util.Locale; import de.intevation.artifacts.CallMeta; import de.intevation.artifacts.PreferredLocale; /** * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) */ public class DefaultCallMeta implements CallMeta { protected PreferredLocale [] languages; public DefaultCallMeta() { } public DefaultCallMeta(PreferredLocale [] languages) { this.languages = languages; } public PreferredLocale [] getLanguages() { return languages; } public Locale getPreferredLocale(Locale [] locales) { if (locales == null || locales.length == 0) { return null; } Locale best = null; float quality = -Float.MAX_VALUE; for (int i = 0; i < locales.length; ++i) { Locale wish = locales[i]; String wishLanguage = wish.getLanguage(); for (int j = 0; j < languages.length; ++j) { PreferredLocale have = languages[j]; Locale haveLocale = have.getLocale(); if (haveLocale.getLanguage().equals(wishLanguage)) { float haveQuality = have.getQuality(); if (haveQuality > quality) { quality = haveQuality; best = wish; } break; // Languages should not contain // same locale twice. } } } return best == null ? locales[0] : best; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: