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 TimeZoneSupport.java
Date Thu, 11 Apr 2002 22:52:03 GMT
luehe       02/04/11 15:52:03

  Modified:    standard/src/org/apache/taglibs/standard/tag/common/fmt
                        BundleSupport.java LocaleSupport.java
                        TimeZoneSupport.java
  Log:
  Leverage new Config class
  
  Revision  Changes    Path
  1.17      +6 -18     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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- BundleSupport.java	4 Apr 2002 18:06:03 -0000	1.16
  +++ BundleSupport.java	11 Apr 2002 22:52:03 -0000	1.17
  @@ -60,6 +60,7 @@
   import javax.servlet.ServletContext;
   import javax.servlet.jsp.*;
   import javax.servlet.jsp.tagext.*;
  +import javax.servlet.jsp.jstl.core.Config;
   import org.apache.taglibs.standard.tag.common.core.Util;
   import org.apache.taglibs.standard.resources.Resources;
   
  @@ -72,12 +73,6 @@
   
   public abstract class BundleSupport extends BodyTagSupport {
   
  -    //*********************************************************************
  -    // Private constants
  -
  -    private static final String DEFAULT_BASE =
  -	"javax.servlet.jsp.jstl.fmt.basename";
  -
   
       //*********************************************************************
       // Protected state
  @@ -167,8 +162,8 @@
   	     * If no 'var' attribute and empty body, we store our base name
   	     * in the javax.servlet.jsp.jstl.fmt.basename scoped attribute
   	     */
  -	    pageContext.setAttribute(DEFAULT_BASE + "." + scope, basename,
  -				     Util.getScope(scope));
  +	    Config.set(pageContext, Config.FMT_BUNDLE, bundle,
  +		       Util.getScope(scope));
   	} else {
   	    try {
   		pageContext.getOut().print(getBodyContent().getString());
  @@ -219,7 +214,7 @@
   	ResourceBundle ret = null;
   	    
   	Locale pref = LocaleSupport.getLocale(pageContext,
  -					      LocaleSupport.LOCALE, true);
  +					      Config.FMT_LOCALE);
   	if (pref != null) {
   	    // Preferred locale is application-based
   	    ret = findMatch(basename, pref);
  @@ -231,8 +226,7 @@
   	if (ret == null) {
   	    // no match found, use fallback locale (if present)
   	    pref = LocaleSupport.getLocale(pageContext,
  -					   LocaleSupport.FALLBACK_LOCALE,
  -					   false);
  +					   Config.FMT_FALLBACKLOCALE);
   	    if (pref != null) {
   		ret = findMatch(basename, pref);
   	    }
  @@ -261,13 +255,7 @@
       public static ResourceBundle getDefaultBundle(PageContext pc) {
   	ResourceBundle ret = null;
   
  -	String def = (String) Util.findAttribute(pc, DEFAULT_BASE);
  -	if (def == null) {
  -	    def = (String) pc.findAttribute(DEFAULT_BASE);
  -	}
  -	if (def == null) {
  -	    def = pc.getServletContext().getInitParameter(DEFAULT_BASE);
  -	}
  +	String def = (String) Config.find(pc, Config.FMT_BASENAME);
   	if (def != null) {
   	    ret = getBundle(pc, def);
   	}
  
  
  
  1.16      +14 -33    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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- LocaleSupport.java	28 Mar 2002 01:24:07 -0000	1.15
  +++ LocaleSupport.java	11 Apr 2002 22:52:03 -0000	1.16
  @@ -59,6 +59,7 @@
   import javax.servlet.ServletResponse;
   import javax.servlet.jsp.*;
   import javax.servlet.jsp.tagext.*;
  +import javax.servlet.jsp.jstl.core.Config;
   import org.apache.taglibs.standard.tag.common.core.Util;
   import org.apache.taglibs.standard.resources.Resources;
   
  @@ -71,13 +72,6 @@
   
   public abstract class LocaleSupport extends TagSupport {
   
  -    //*********************************************************************
  -    // Package-scoped constants
  -
  -    static final String LOCALE = "javax.servlet.jsp.jstl.fmt.locale";
  -    static final String FALLBACK_LOCALE =
  -	"javax.servlet.jsp.jstl.fmt.fallbackLocale";
  -
       
       //*********************************************************************
       // Private constants
  @@ -131,8 +125,8 @@
   	} else {
   	    locale = parseLocale(value, variant);
   	}
  -	pageContext.setAttribute(LOCALE + "." + scope, locale,
  -				 Util.getScope(scope));
  +	Config.set(pageContext, Config.FMT_LOCALE, locale,
  +		   Util.getScope(scope));
   	setResponseLocale(pageContext, locale);
   
   	return EVAL_PAGE;
  @@ -272,7 +266,7 @@
   	     * the available formatting locales, and determine the best
   	     * matching locale.
   	     */
  -	    Locale pref = getLocale(pc, LOCALE, true);
  +	    Locale pref = getLocale(pc, Config.FMT_LOCALE);
   	    if (pref != null) {
   		// Preferred locale is application-based
   		match = findFormattingMatch(pref, avail);
  @@ -282,7 +276,7 @@
   	    }
   	    if (match == null) {
   		//Use fallback locale.
  -		pref = getLocale(pc, FALLBACK_LOCALE, false);
  +		pref = getLocale(pc, Config.FMT_FALLBACKLOCALE);
   		if ((pref == null)
   		        || ((match = findFormattingMatch(pref,
   							 avail)) == null)) {
  @@ -312,37 +306,24 @@
        * attribute or context configuration parameter
        * @param name the name of the scoped attribute or context configuration
        * parameter
  -     * @param extend <tt>true</tt> if the given attribute name should be
  -     * searched in each scope with the scope's name appended to it, prior to
  -     * being searched in all scopes using the PageContext method
  -     * findAttribute()
        *
        * @return the locale specified by the named scoped attribute or context
        * configuration parameter, or <tt>null</tt> if no scoped attribute or
        * configuration parameter with the given name exists
        */
  -    static Locale getLocale(PageContext pageContext, String name,
  -			    boolean extend) {
  -	String loc = null;
  -	Locale ret = null;
  +    static Locale getLocale(PageContext pageContext, String name) {
  +	Locale loc = null;
   
  -	if (extend) {
  -	    ret = (Locale) Util.findAttribute(pageContext, name);
  -	}
  -	if (ret == null) {
  -	    loc = (String) pageContext.findAttribute(name);
  -	    if (loc != null) {
  -		ret = parseLocale(loc);
  -	    }
  -	}
  -	if (ret == null) {
  -	    loc = pageContext.getServletContext().getInitParameter(name);
  -	    if (loc != null) {
  -		ret = parseLocale(loc);
  +	Object obj = Config.find(pageContext, name);
  +	if (obj != null) {
  +	    if (obj instanceof Locale) {
  +		loc = (Locale) obj;
  +	    } else {
  +		loc = parseLocale((String) obj);
   	    }
   	}
   
  -	return ret;
  +	return loc;
       }
   
   
  
  
  
  1.10      +13 -20    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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TimeZoneSupport.java	23 Mar 2002 01:33:50 -0000	1.9
  +++ TimeZoneSupport.java	11 Apr 2002 22:52:03 -0000	1.10
  @@ -59,6 +59,7 @@
   import java.util.TimeZone;
   import javax.servlet.jsp.*;
   import javax.servlet.jsp.tagext.*;
  +import javax.servlet.jsp.jstl.core.Config;
   import org.apache.taglibs.standard.tag.common.core.Util;
   import org.apache.taglibs.standard.resources.Resources;
   
  @@ -71,12 +72,6 @@
   
   public abstract class TimeZoneSupport extends BodyTagSupport {
   
  -    //*********************************************************************
  -    // Private Constants
  -
  -    private static final String TIMEZONE
  -	= "javax.servlet.jsp.jstl.fmt.timeZone";
  -
   
       //*********************************************************************
       // Protected state
  @@ -146,8 +141,8 @@
   	     * If no 'var' attribute and empty body, we store our time zone
   	     * in the javax.servlet.jsp.jstl.fmt.timeZone scoped attribute
   	     */
  -	    pageContext.setAttribute(TIMEZONE + "." + scope, timeZone,
  -				     Util.getScope(scope));
  +	    Config.set(pageContext, Config.FMT_TIMEZONE, timeZone,
  +		       Util.getScope(scope));
   	} else {
   	    try {
   		pageContext.getOut().print(getBodyContent().getString());
  @@ -188,27 +183,25 @@
        * @return the time zone
        */
       static TimeZone getTimeZone(PageContext pc, Tag fromTag) {
  -	TimeZone ret = null;
  +	TimeZone tz = null;
   
   	Tag t = findAncestorWithClass(fromTag, TimeZoneSupport.class);
   	if (t != null) {
   	    // use time zone from parent <timeZone> tag
   	    TimeZoneSupport parent = (TimeZoneSupport) t;
  -	    ret = parent.getTimeZone();
  +	    tz = parent.getTimeZone();
   	} else {
  -	    // get time zone from scoped attribute
  -	    ret = (TimeZone) Util.findAttribute(pc, TIMEZONE);
  -	    if (ret == null) {
  -		String tz = (String) pc.findAttribute(TIMEZONE);
  -		if (tz == null) {
  -		    tz = pc.getServletContext().getInitParameter(TIMEZONE);
  -		}
  -		if (tz != null) {
  -		    ret = TimeZone.getTimeZone(tz);
  +	    // get time zone from config variable or context init param
  +	    Object obj = Config.find(pc, Config.FMT_TIMEZONE);
  +	    if (obj != null) {
  +		if (obj instanceof TimeZone) {
  +		    tz = (TimeZone) obj;
  +		} else {
  +		    tz = TimeZone.getTimeZone((String) obj);
   		}
   	    }
   	}
   
  -	return ret;
  +	return tz;
       }
   }
  
  
  

--
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