changeset 49:823850c63d95

Convenience method in call meta to get preferred language. artifacts/trunk@175 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 02 Oct 2009 09:44:58 +0000
parents 41c225c8bd41
children 0b04fa8a19c6
files Changelog artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultCallMeta.java artifacts/src/main/java/de/intevation/artifacts/CallMeta.java
diffstat 3 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Changelog	Thu Oct 01 16:03:12 2009 +0000
+++ b/Changelog	Fri Oct 02 09:44:58 2009 +0000
@@ -1,3 +1,11 @@
+2009-10-02	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* artifacts/src/main/java/de/intevation/artifacts/CallMeta.java:
+	Added method to fetch preferred locale.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultCallMeta.java:
+	Trivial (and incorrect!) implementation.
+
 2009-10-01	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	Add i18n support via "Accept-Language" HTTP headers.
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultCallMeta.java	Thu Oct 01 16:03:12 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultCallMeta.java	Fri Oct 02 09:44:58 2009 +0000
@@ -1,5 +1,7 @@
 package de.intevation.artifactdatabase;
 
+import java.util.Locale;
+
 import de.intevation.artifacts.CallMeta;
 import de.intevation.artifacts.PreferredLocale;
 
@@ -20,5 +22,13 @@
     public PreferredLocale [] getLanguages() {
         return languages;
     }
+
+    public Locale getPreferredLocale(Locale [] locales) {
+        if (locales == null || locales.length == 0) {
+            return null;
+        }
+
+        return locales[0];
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- a/artifacts/src/main/java/de/intevation/artifacts/CallMeta.java	Thu Oct 01 16:03:12 2009 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/CallMeta.java	Fri Oct 02 09:44:58 2009 +0000
@@ -1,5 +1,7 @@
 package de.intevation.artifacts;
 
+import java.util.Locale;
+
 /**
  * Interface to inject meta data like languages to CallContexts.
  *
@@ -8,5 +10,7 @@
 public interface CallMeta
 {
     PreferredLocale [] getLanguages();
+
+    Locale getPreferredLocale(Locale [] locales);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org