- From: Denis Tea via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 12 Feb 2008 15:23:31 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/org/w3c/unicorn/tests In directory hutz:/tmp/cvs-serv13782/org/w3c/unicorn/tests Modified Files: FirstServlet.java Log Message: use of getLocales() method to get a sorted Accept-Language Index: FirstServlet.java =================================================================== RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/tests/FirstServlet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- FirstServlet.java 12 Feb 2008 09:20:52 -0000 1.6 +++ FirstServlet.java 12 Feb 2008 15:23:29 -0000 1.7 @@ -128,8 +128,7 @@ // Returns the preferred Locale that the client will accept content in, // based on the Accept-Language header - final String aLocale = aHttpServletRequest.getHeader("Accept-Language"); - + final String aLocale = convertEnumerationToString(aHttpServletRequest.getLocales()); final UnicornCall aUnicornCall = new UnicornCall(); // Language of the template @@ -229,7 +228,7 @@ // Returns the preferred Locale that the client will accept content in, // based on the Accept-Language header - final String aLocale = aHttpServletRequest.getHeader("Accept-Language"); + final String aLocale = convertEnumerationToString(aHttpServletRequest.getLocales()); // Language of the template @@ -480,7 +479,6 @@ */ private String chooseTemplateLang(String aLocale){ String[] tabLang = aLocale.split(";|,"); - for (int i=0; i<tabLang.length; i++){ if (Framework.outputLang.contains(tabLang[i])) return tabLang[i]; @@ -490,5 +488,13 @@ return LocalizedString.DEFAULT_LANGUAGE; } + + private String convertEnumerationToString(Enumeration myEnum){ + String ret = ""; + while (myEnum.hasMoreElements()){ + ret += myEnum.nextElement().toString() + ","; + } + return ret.substring(0,ret.length()-1); + } }
Received on Tuesday, 12 February 2008 15:23:40 UTC