org.apache.sling.i18n.DefaultLocaleResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aem-sdk-api Show documentation
Show all versions of aem-sdk-api Show documentation
The Adobe Experience Manager SDK
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.sling.i18n;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import org.apache.sling.api.SlingHttpServletRequest;
/**
* The DefaultLocaleResolver
resolves the request's Locale by
* calling the ServletRequest.getLocales()
method, which generally
* will be the Servlet Container's implementation of this method and thus be
* based on the client's Accept-Language
header.
*/
public class DefaultLocaleResolver implements LocaleResolver, RequestLocaleResolver {
/**
* Return the Locales provided by the
* ServletRequest.getLocales()
method collected in a
* List
.
*/
public List resolveLocale(final SlingHttpServletRequest request) {
return this.resolveLocale((HttpServletRequest)request);
}
/**
* @see org.apache.sling.i18n.RequestLocaleResolver#resolveLocale(javax.servlet.http.HttpServletRequest)
*/
public List resolveLocale(final HttpServletRequest request) {
Enumeration> locales = request.getLocales();
ArrayList localeList = new ArrayList();
while (locales.hasMoreElements()) {
localeList.add((Locale) locales.nextElement());
}
return localeList;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy