All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.servlet.jsp.jstl.fmt.LocalizationContext Maven / Gradle / Ivy

There is a newer version: 3.0.2
Show newest version
/*
 * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
 * Copyright 2004 The Apache Software Foundation
 *
 * Licensed 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 javax.servlet.jsp.jstl.fmt;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Class representing an I18N localization context.
 *
 * 

An I18N localization context has two components: a resource bundle and * the locale that led to the resource bundle match. * *

The resource bundle component is used by <fmt:message> for mapping * message keys to localized messages, and the locale component is used by the * <fmt:message>, <fmt:formatNumber>, <fmt:parseNumber>, <fmt:formatDate>, * and <fmt:parseDate> actions as their formatting or parsing locale, respectively. * * @author Jan Luehe */ public class LocalizationContext { // the localization context's resource bundle final private ResourceBundle bundle; // the localization context's locale final private Locale locale; /** * Constructs an empty I18N localization context. */ public LocalizationContext() { bundle = null; locale = null; } /** * Constructs an I18N localization context from the given resource bundle * and locale. * *

The specified locale is the application- or browser-based preferred * locale that led to the resource bundle match. * * @param bundle The localization context's resource bundle * @param locale The localization context's locale */ public LocalizationContext(ResourceBundle bundle, Locale locale) { this.bundle = bundle; this.locale = locale; } /** * Constructs an I18N localization context from the given resource bundle. * *

The localization context's locale is taken from the given * resource bundle. * * @param bundle The resource bundle */ public LocalizationContext(ResourceBundle bundle) { this.bundle = bundle; this.locale = bundle.getLocale(); } /** * Gets the resource bundle of this I18N localization context. * * @return The resource bundle of this I18N localization context, or null * if this I18N localization context is empty */ public ResourceBundle getResourceBundle() { return bundle; } /** * Gets the locale of this I18N localization context. * * @return The locale of this I18N localization context, or null if this * I18N localization context is empty, or its resource bundle is a * (locale-less) root resource bundle. */ public Locale getLocale() { return locale; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy