jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt BundleSupport.java LocaleSupport.java RequestEncodingSupport.java TimeZoneSupport.java
Date Fri, 01 Feb 2002 01:16:47 GMT
luehe       02/01/31 17:16:47

  Modified:    standard/src/org/apache/taglibs/standard/tag/common/fmt
                        BundleSupport.java LocaleSupport.java
                        RequestEncodingSupport.java TimeZoneSupport.java
  Added:       standard/src/javax/servlet/jsp/jstl/fmt LocaleSupport.java
  Removed:     standard/src/org/apache/taglibs/standard/extra/i18n
                        LocaleSupport.java
  Log:
  Changed 'i18n' to 'fmt' in all scoped attribute and config parameter names. Upgraded LocaleSupport.java
from org.apache.taglibs.standard.extra.i18n to javax.servlet.jsp.jstl.fmt
  
  Revision  Changes    Path
  1.1                  jakarta-taglibs/standard/src/javax/servlet/jsp/jstl/fmt/LocaleSupport.java
  
  Index: LocaleSupport.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */ 
  
  package javax.servlet.jsp.jstl.fmt;
  
  import java.util.*;
  import java.text.*;
  import javax.servlet.jsp.*;
  import org.apache.taglibs.standard.tag.common.fmt.BundleSupport;
  import org.apache.taglibs.standard.tag.common.fmt.MessageSupport;
  import org.apache.taglibs.standard.resources.Resources;
  
  /**
   * Class which exposes the locale-determination logic for resource bundles
   * through convenience methods.
   *
   * <p> This class may be useful to any tag handler implementation that needs
   * to produce localized messages. For example, this might be useful for 
   * exception messages that are intended directly for user consumption on an 
   * error page.
   *
   * @author Jan Luehe
   */
  
  public class LocaleSupport {
  
      /** 
       * Retrieves the localized message corresponding to the given key. 
       * 
       * <p> The given key is looked up in the resource bundle with the default
       * base name, which is retrieved from the
       * <tt>javax.servlet.jsp.jsptl.fmt.basename</tt> scoped attribute or
       * context configuration parameter.
       * 
       * <p> If the <tt>javax.servlet.jsp.jsptl.fmt.basename</tt> scoped
       * attribute or context configuration parameter does not exist, or no
       * resource bundle with the default base name exists, or the given key is
       * undefined in the resource bundle with the default base name, the string
       * &quot;???&lt;key&gt;???&quot; is returned, where
       * &quot;&lt;key&gt;&quot; is replaced with the given <tt>key</tt>.
       * 
       * @param pageContext the page in which to get the localized message
       * corresponding to the given key  
       * @param key the message key
       * 
       * @return the localized message corresponding to the given key 
       */ 
      public static String getLocalizedMessage(PageContext pageContext, 
                                               String key) {
  	return getLocalizedMessage(pageContext, key, null, null);
      }
  
      /** 
       * Retrieves the localized message corresponding to the given key. 
       * 
       * <p> The given key is looked up in the resource bundle with the given 
       * base name. If no resource bundle with the given base name exists, 
       * or the given key is undefined in the resource bundle, the string
       * &quot;???&lt;key&gt;???&quot; is returned, where
       * &quot;&lt;key&gt;&quot; is replaced with the given <tt>key</tt>
       * argument.
       * 
       * @param pageContext the page in which to get the localized message
       * corresponding to the given key  
       * @param key the message key
       * @param basename the resource bundle base name 
       * 
       * @return the localized message corresponding to the given key 
       */ 
      public static String getLocalizedMessage(PageContext pageContext, 
                                               String key, 
                                               String basename) {
  	return getLocalizedMessage(pageContext, key, null, basename);
      }
  
      /** 
       * Retrieves the localized message corresponding to the given key and 
       * performs parametric replacement on it.
       * 
       * <p> The localized message is retrieved as in
       * {@link #getLocalizedMessage(javax.servlet.jsp.PageContext,java.lang.String) getLocalizedMessage(pageContext,
key)}.
       * Parametric replacement is performed using the arguments specified via 
       * <tt>args</tt>. 
       *
       * @param pageContext the page in which to get the localized message
       * corresponding to the given key  
       * @param key the message key
       * @param args the arguments for parametric replacement 
       * 
       * @return the localized message corresponding to the given key 
       */ 
      public static String getLocalizedMessage(PageContext pageContext, 
                                               String key, 
                                               Object[] args) {
  	return getLocalizedMessage(pageContext, key, args, null);
      }
  
      /** 
       * Retrieves the localized message corresponding to the given key and
       * performs parametric replacement on it.
       *
       * <p> The localized message is retrieved as in
       * {@link #getLocalizedMessage(javax.servlet.jsp.PageContext,java.lang.String, java.lang.String)
getLocalizedMessage(pageContext, key, basename)}.
       * Parametric replacement is performed using the arguments specified via 
       * <tt>args</tt>. 
       * 
       * @param pageContext the page in which to get the localized message
       * corresponding to the given key  
       * @param key the message key
       * @param args the arguments for parametric replacement 
       * @param basename the resource bundle base name 
       * 
       * @return the localized message corresponding to the given key 
       */ 
      public static String getLocalizedMessage(PageContext pageContext, 
                                               String key, 
                                               Object[] args, 
                                               String basename) {
  	ResourceBundle bundle = null;
  	String message = MessageSupport.UNDEFINED_KEY + key
  	    + MessageSupport.UNDEFINED_KEY;
  
  	if (basename != null)
  	    bundle = BundleSupport.getBundle(pageContext, basename);
  	else
  	    bundle = BundleSupport.getDefaultBundle(
                  pageContext, BundleSupport.DEFAULT_BASENAME);
  
  	if (bundle != null) {
  	    try {
  		message = bundle.getString(key);
  		if (args != null) {
  		    MessageFormat formatter = new MessageFormat("");
  		    formatter.setLocale(bundle.getLocale());
  		    formatter.applyPattern(message);
  		    message = formatter.format(args);
  		}
  	    } catch (MissingResourceException mre) {
  	    }
  	}
  
  	return message;
      }
  }
  
  
  
  
  1.10      +5 -5      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.java
  
  Index: BundleSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BundleSupport.java	30 Jan 2002 23:26:33 -0000	1.9
  +++ BundleSupport.java	1 Feb 2002 01:16:47 -0000	1.10
  @@ -76,14 +76,14 @@
       // Public constants
   
       public static final String DEFAULT_BASENAME =
  -	"javax.servlet.jsp.jstl.i18n.basename";
  +	"javax.servlet.jsp.jstl.fmt.basename";
   
   
       //*********************************************************************
       // Package-scoped constants
   
       static final String DEFAULT_EXCEPTION_BASENAME =
  -	"javax.servlet.jsp.jstl.i18n.exception.basename";
  +	"javax.servlet.jsp.jstl.fmt.exception.basename";
   
   
       //*********************************************************************
  @@ -167,7 +167,7 @@
   	} else if (getBodyContent() == null) {
   	    /*
   	     * If no 'var' attribute and empty body, we store our base name
  -	     * in the javax.servlet.jsp.jstl.i18n.basename scoped attribute
  +	     * in the javax.servlet.jsp.jstl.fmt.basename scoped attribute
   	     */
   	    pageContext.setAttribute(DEFAULT_BASENAME, basename, scope);
   	} else {
  @@ -196,7 +196,7 @@
        * <p> The resource bundle's locale is determined as follows:
        *
        * <ul>
  -     * <li> If the <tt>javax.servlet.jsp.jstl.i18n.locale</tt> scoped

  +     * <li> If the <tt>javax.servlet.jsp.jstl.fmt.locale</tt> scoped

        * attribute exists, use the locale stored as its value.
        *
        * <li> Otherwise, compare the client's preferred locales (in order of
  @@ -204,7 +204,7 @@
        * use the best matching locale.
        *
        * <li> If no match is found, use the fallback locale given by the
  -     * <tt>javax.servlet.jsp.jstl.i18n.fallbackLocale</tt> scoped attribute
  +     * <tt>javax.servlet.jsp.jstl.fmt.fallbackLocale</tt> scoped attribute
        * or config parameter (if present).
        * </ul>
        *
  
  
  
  1.10      +6 -6      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/LocaleSupport.java
  
  Index: LocaleSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/LocaleSupport.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LocaleSupport.java	30 Jan 2002 23:26:33 -0000	1.9
  +++ LocaleSupport.java	1 Feb 2002 01:16:47 -0000	1.10
  @@ -74,9 +74,9 @@
       //*********************************************************************
       // Package-scoped constants
   
  -    static final String LOCALE = "javax.servlet.jsp.jstl.i18n.locale";
  +    static final String LOCALE = "javax.servlet.jsp.jstl.fmt.locale";
       static final String FALLBACK_LOCALE =
  -	"javax.servlet.jsp.jstl.i18n.fallbackLocale";
  +	"javax.servlet.jsp.jstl.fmt.fallbackLocale";
   
       
       //*********************************************************************
  @@ -195,7 +195,7 @@
       /*
        * Stores the given locale in the response object of the given page
        * context, and stores the locale's associated charset in the
  -     * javax.servlet.jsp.jstl.i18n.request.charset session attribute, which
  +     * javax.servlet.jsp.jstl.fmt.request.charset session attribute, which
        * may be used by the <requestEncoding> action in a page invoked by a
        * form included in the response to set the request charset to the same as
        * the response charset (this makes it possible for the container to
  @@ -224,13 +224,13 @@
        * <p> The formatting locale is determined as follows:
        *
        * <ul>
  -     * <li> If the <tt>javax.servlet.jsp.jstl.i18n.locale</tt> scoped
  +     * <li> If the <tt>javax.servlet.jsp.jstl.fmt.locale</tt> scoped
        * attribute or context configuration parameter exists, use its locale.
        *
        * <li> If the formatting action is enclosed within a <bundle> action,
use
        * the locale of the parent bundle.
        *
  -     * <li> If the <tt>javax.servlet.jsp.jstl.i18n.basename</tt> scoped
  +     * <li> If the <tt>javax.servlet.jsp.jstl.fmt.basename</tt> scoped
        * attribute exists, retrieve the default base name from it and use the
        * best matching locale for the resource bundle with this base name.
        *
  @@ -239,7 +239,7 @@
        * <tt>avail</tt> parameter, and use the best matching locale.
        *
        * <li> If no match is found, use the fallback locale given by the
  -     * <tt>javax.servlet.jsp.jstl.i18n.fallbackLocale</tt> scoped attribute
  +     * <tt>javax.servlet.jsp.jstl.fmt.fallbackLocale</tt> scoped attribute
        * or config parameter (if present).
        *
        * <li> If no match is found, use the runtime's default locale.
  
  
  
  1.3       +1 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/RequestEncodingSupport.java
  
  Index: RequestEncodingSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/RequestEncodingSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestEncodingSupport.java	12 Dec 2001 01:24:19 -0000	1.2
  +++ RequestEncodingSupport.java	1 Feb 2002 01:16:47 -0000	1.3
  @@ -75,7 +75,7 @@
       // Package-scoped constants
   
       static final String REQUEST_CHAR_SET =
  -	"javax.servlet.jsp.jstl.i18n.request.charset";
  +	"javax.servlet.jsp.jstl.fmt.request.charset";
   
   
       //*********************************************************************
  
  
  
  1.6       +3 -3      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/TimeZoneSupport.java
  
  Index: TimeZoneSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/TimeZoneSupport.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TimeZoneSupport.java	11 Dec 2001 17:21:47 -0000	1.5
  +++ TimeZoneSupport.java	1 Feb 2002 01:16:47 -0000	1.6
  @@ -75,7 +75,7 @@
       // Package-scoped constants
   
       static final String TIMEZONE_ATTRIBUTE =
  -	"javax.servlet.jsp.jstl.i18n.timeZone";
  +	"javax.servlet.jsp.jstl.fmt.timeZone";
   
   
       //*********************************************************************
  @@ -140,7 +140,7 @@
   	} else if (getBodyContent() == null) {
   	    /*
   	     * If no 'var' attribute and empty body, we store our time zone
  -	     * in the javax.servlet.jsp.jstl.i18n.timeZone scoped attribute
  +	     * in the javax.servlet.jsp.jstl.fmt.timeZone scoped attribute
   	     */
   	    pageContext.setAttribute(TIMEZONE_ATTRIBUTE, timeZone, scope);
   	} else {
  @@ -170,7 +170,7 @@
        * the time zone is taken from the enclosing &lt;timeZone&gt; tag.
        *
        * <p> Otherwise, the default time zone given by the
  -     * <tt>javax.servlet.jsp.jstl.i18n.timeZone</tt> scoped attribute is used,
  +     * <tt>javax.servlet.jsp.jstl.fmt.timeZone</tt> scoped attribute is used,
        * which is searched in the page, request, session (if valid),
        * and application scope(s) (in this order).
        * 
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message