| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AcceptLanguageHeaderResolver |
|
| 3.0;3 |
| 1 | /* | |
| 2 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net | |
| 3 | * Copyright (C) 2004-2010 Frederico Caldeira Knabben | |
| 4 | * | |
| 5 | * == BEGIN LICENSE == | |
| 6 | * | |
| 7 | * Licensed under the terms of any of the following licenses at your | |
| 8 | * choice: | |
| 9 | * | |
| 10 | * - GNU General Public License Version 2 or later (the "GPL") | |
| 11 | * http://www.gnu.org/licenses/gpl.html | |
| 12 | * | |
| 13 | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") | |
| 14 | * http://www.gnu.org/licenses/lgpl.html | |
| 15 | * | |
| 16 | * - Mozilla Public License Version 1.1 or later (the "MPL") | |
| 17 | * http://www.mozilla.org/MPL/MPL-1.1.html | |
| 18 | * | |
| 19 | * == END LICENSE == | |
| 20 | */ | |
| 21 | package net.fckeditor.localization.impl; | |
| 22 | ||
| 23 | import java.util.Locale; | |
| 24 | ||
| 25 | import javax.servlet.ServletRequest; | |
| 26 | import javax.servlet.http.HttpServletRequest; | |
| 27 | ||
| 28 | import net.fckeditor.localization.LocaleResolver; | |
| 29 | import net.fckeditor.tool.Utils; | |
| 30 | ||
| 31 | /** | |
| 32 | * HTTP header implementation of the locale resolver. It resolves the current | |
| 33 | * user locale by calling {@link ServletRequest#getLocale()} if and only if the | |
| 34 | * <code>Accept-Language</code> header is not empty. | |
| 35 | * | |
| 36 | * @version $Id: AcceptLanguageHeaderResolver.java 4785 2009-12-21 20:10:28Z mosipov $ | |
| 37 | */ | |
| 38 | 0 | public class AcceptLanguageHeaderResolver implements LocaleResolver { |
| 39 | ||
| 40 | public Locale resolveLocale(final HttpServletRequest request) { | |
| 41 | ||
| 42 | 0 | if (Utils.isNotEmpty(request.getHeader("Accept-Language"))) |
| 43 | 0 | return request.getLocale(); |
| 44 | else | |
| 45 | 0 | return null; |
| 46 | } | |
| 47 | ||
| 48 | } |