Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 41859 invoked from network); 18 Jan 2003 06:35:35 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 18 Jan 2003 06:35:35 -0000 Received: (qmail 27329 invoked by uid 97); 18 Jan 2003 06:37:03 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 27313 invoked by uid 97); 18 Jan 2003 06:37:02 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 27302 invoked by uid 97); 18 Jan 2003 06:37:02 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 18 Jan 2003 06:35:27 -0000 Message-ID: <20030118063527.92711.qmail@icarus.apache.org> From: dion@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/jelly/jelly-tags/fmt project.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N dion 2003/01/17 22:35:27 Modified: jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt FmtTagLibrary.java jelly/jelly-tags/fmt/src/test/org/apache/commons/jelly/tags/fmt suite.jelly jelly/jelly-tags/fmt project.xml Added: jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt SetBundleTag.java TimeZoneTag.java FormatDateTag.java SetTimeZoneTag.java Log: Applying patches and tags provided by Willie Vu Revision Changes Path 1.2 +10 -10 jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/FmtTagLibrary.java Index: FmtTagLibrary.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/FmtTagLibrary.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FmtTagLibrary.java 16 Jan 2003 16:21:46 -0000 1.1 +++ FmtTagLibrary.java 18 Jan 2003 06:35:27 -0000 1.2 @@ -1,7 +1,7 @@ /* - * $Header$ - * $Revision$ - * $Date$ + * /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/FmtTagLibrary.java,v 1.1 2003/01/16 16:21:46 jstrachan Exp + * 1.1 + * 2003/01/16 16:21:46 * * ==================================================================== * @@ -58,6 +58,7 @@ * . * * $Id$ + * */ package org.apache.commons.jelly.tags.fmt; @@ -68,14 +69,9 @@ * @author Willie Vu * @version $Revision$ * - * @task implement <fmt:setBundle> - * @task implement <fmt:timeZone> - * @task implement <fmt:setTimeZone> * @task implement <fmt:formatNumber> * @task implement <fmt:parseNumber> - * @task implement <fmt:formatDate> * @task implement <fmt:parseDate> - * @task implement <fmt:timeZone> * @task decide how to support <fmt:requestEncoding> */ public class FmtTagLibrary extends TagLibrary { @@ -83,9 +79,13 @@ /** Creates a new instance of FmtTagLibrary */ public FmtTagLibrary() { registerTag("bundle", BundleTag.class); + registerTag("formatDate", FormatDateTag.class); registerTag("message", MessageTag.class); registerTag("param", ParamTag.class); + registerTag("setBundle", SetBundleTag.class); registerTag("setLocale", SetLocaleTag.class); + registerTag("setTimeZone", SetTimeZoneTag.class); + registerTag("timeZone", TimeZoneTag.class); } } 1.1 jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/SetBundleTag.java Index: SetBundleTag.java =================================================================== /* * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/SetBundleTag.java,v 1.1 2003/01/18 06:35:27 dion Exp $ * $Revision: 1.1 $ * $Date: 2003/01/18 06:35:27 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2002 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", "Commons", 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 * . * * $Id: SetBundleTag.java,v 1.1 2003/01/18 06:35:27 dion Exp $ */ package org.apache.commons.jelly.tags.fmt; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.expression.Expression; import java.util.Locale; /** * Support for tag handlers for <setLocale>, the bundle setting * tag in JSTL. * @author Willie Vu * @version $Revision: 1.1 $ * */ public class SetBundleTag extends TagSupport { private String var; private Expression basename; private String scope; /** Creates a new instance of SetBundleTag */ public SetBundleTag() { } /** * Evaluates this tag after all the tags properties have been initialized. * */ public void doTag(XMLOutput output) throws Exception { Object basenameInput = null; if (this.basename != null) { basenameInput = this.basename.evaluate(context); } LocalizationContext locCtxt = BundleTag.getLocalizationContext( context, (String) basenameInput); String varname = (var != null) ? var : Config.FMT_LOCALIZATION_CONTEXT; if (scope != null) { context.setVariable(varname, scope, locCtxt); } else { context.setVariable(varname, locCtxt); } } public void setVar(String var) { this.var = var; } public void setBasename(Expression basename) { this.basename = basename; } public void setScope(String scope) { this.scope = scope; } } 1.1 jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/TimeZoneTag.java Index: TimeZoneTag.java =================================================================== /* * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/TimeZoneTag.java,v 1.1 2003/01/18 06:35:27 dion Exp $ * $Revision: 1.1 $ * $Date: 2003/01/18 06:35:27 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2002 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", "Commons", 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 * . * * $Id: TimeZoneTag.java,v 1.1 2003/01/18 06:35:27 dion Exp $ */ package org.apache.commons.jelly.tags.fmt; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.expression.Expression; import java.util.Enumeration; import java.util.Locale; import java.util.ResourceBundle; import java.util.MissingResourceException; import java.util.TimeZone; /** * Support for tag handlers for <timeZone>, the time zone loading * tag in JSTL. * * @author Willie Vu * @version $Revision: 1.1 $ * * @task decide how to implement setResponseLocale */ public class TimeZoneTag extends TagSupport { private TimeZone timeZone; private Expression value; // 'value' attribute //********************************************************************* // Constructor and initialization public TimeZoneTag() { } //********************************************************************* // Collaboration with subtags public TimeZone getTimeZone() { return timeZone; } //********************************************************************* // Tag logic /** * Evaluates this tag after all the tags properties have been initialized. * */ public void doTag(XMLOutput output) throws Exception { Object valueInput = null; if (this.value != null) { valueInput = this.value.evaluate(context); } if (valueInput == null) { timeZone = TimeZone.getTimeZone("GMT"); } else if (valueInput instanceof String) { if (((String) valueInput).trim().equals("")) { timeZone = TimeZone.getTimeZone("GMT"); } else { timeZone = TimeZone.getTimeZone((String) valueInput); } } else { timeZone = (TimeZone) valueInput; } invokeBody(output); } //********************************************************************* // Package-scoped utility methods /* * Determines and returns the time zone to be used by the given action. * *

If the given action is nested inside a <timeZone> action, * the time zone is taken from the enclosing <timeZone> action. * *

Otherwise, the time zone configuration setting * javax.servlet.jsp.jstl.core.Config.FMT_TIME_ZONE * is used. * * @param jc the page containing the action for which the * time zone needs to be determined * @param fromTag the action for which the time zone needs to be * determined * * @return the time zone, or null if the given action is not * nested inside a <timeZone> action and no time zone configuration * setting exists */ static TimeZone getTimeZone(JellyContext jc, Tag fromTag) { TimeZone tz = null; Tag t = findAncestorWithClass(fromTag, TimeZoneTag.class); if (t != null) { // use time zone from parent tag TimeZoneTag parent = (TimeZoneTag) t; tz = parent.getTimeZone(); } else { // get time zone from configuration setting Object obj = jc.getVariable(Config.FMT_TIME_ZONE); if (obj != null) { if (obj instanceof TimeZone) { tz = (TimeZone) obj; } else { tz = TimeZone.getTimeZone((String) obj); } } } return tz; } /** Setter for property value. * @param value New value of property value. * */ public void setValue(Expression value) { this.value = value; } } 1.1 jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/FormatDateTag.java Index: FormatDateTag.java =================================================================== /* * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/FormatDateTag.java,v 1.1 2003/01/18 06:35:27 dion Exp $ * $Revision: 1.1 $ * $Date: 2003/01/18 06:35:27 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2002 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", "Commons", 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 * . * * $Id: FormatDateTag.java,v 1.1 2003/01/18 06:35:27 dion Exp $ */ package org.apache.commons.jelly.tags.fmt; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.expression.Expression; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; /** * Support for tag handlers for <formatDate>, the date and time formatting * tag in JSTL. * @author Willie Vu * @version $Revision: 1.1 $ * @task i18n exception message */ public class FormatDateTag extends TagSupport { private static final String DEFAULT = "default"; private static final String SHORT = "short"; private static final String MEDIUM = "medium"; private static final String LONG = "long"; private static final String FULL = "full"; private static final String DATE = "date"; private static final String TIME = "time"; private static final String DATETIME = "both"; /** Holds value of property value. */ private Expression value; /** Holds value of property type. */ private Expression type; /** Holds value of property dataStyle. */ private Expression dateStyle; /** Holds value of property timeStyle. */ private Expression timeStyle; /** Holds value of property pattern. */ private Expression pattern; /** Holds value of property timeZone. */ private Expression timeZone; /** Holds value of property var. */ private String var; /** Holds value of property scope. */ private String scope; /** Evaluated type */ private String etype; /** Evaluated dateStyle */ private String edateStyle; /** Evaluated timeStyle */ private String etimeStyle; /** Creates a new instance of FormatDateTag */ public FormatDateTag() { } /** * Evaluates this tag after all the tags properties have been initialized. * */ public void doTag(XMLOutput output) throws Exception { if (scope != null && var == null) { throw new JellyException( "If 'scope' is specified, 'var' must be defined for this tag" ); } Object valueInput = null; if (this.value != null) { valueInput = this.value.evaluate(context); } Date date = null; if (valueInput != null && valueInput instanceof Date) { date = (Date) valueInput; } if (date == null && var != null) { if (scope != null) { context.removeVariable(var, scope); } else { context.removeVariable(var); } } etype = DATE; if (this.type != null) { etype = (String) this.type.evaluate(context); } edateStyle = DEFAULT; if (this.dateStyle != null) { edateStyle = (String) this.dateStyle.evaluate(context); } etimeStyle = DEFAULT; if (this.timeStyle != null) { etimeStyle = (String) this.timeStyle.evaluate(context); } String epattern = null; if (this.pattern != null) { epattern = (String) this.pattern.evaluate(context); } Object etimeZone = null; if (this.timeZone != null) { etimeZone = this.timeZone.evaluate(context); } // Create formatter Locale locale = SetLocaleTag.getFormattingLocale( context, this, true, DateFormat.getAvailableLocales()); String formatted = null; if (locale != null) { DateFormat formatter = createFormatter(locale); // Apply pattern, if present if (pattern != null) { try { ((SimpleDateFormat) formatter).applyPattern(epattern); } catch (ClassCastException cce) { formatter = new SimpleDateFormat(epattern, locale); } } // Set time zone TimeZone tz = null; if ((etimeZone instanceof String) && ((String) etimeZone).equals("")) { etimeZone = null; } if (etimeZone != null) { if (etimeZone instanceof String) { tz = TimeZone.getTimeZone((String) etimeZone); } else if (etimeZone instanceof TimeZone) { tz = (TimeZone) etimeZone; } else { throw new JellyException("Bad time zone"); } } else { tz = TimeZoneTag.getTimeZone(context, this); } if (tz != null) { formatter.setTimeZone(tz); } formatted = formatter.format(date); } else { // no formatting locale available, use Date.toString() formatted = date.toString(); } if (var != null) { if (scope != null) { context.setVariable(var, scope, formatted); } else { context.setVariable(var, formatted); } } else { // write the formatted output.write(formatted); } } /** Setter for property value. * @param value New value of property value. * */ public void setValue(Expression value) { this.value = value; } /** Setter for property type. * @param type New value of property type. * */ public void setType(Expression type) { this.type = type; } /** Setter for property dataStyle. * @param dataStyle New value of property dataStyle. * */ public void setDateStyle(Expression dateStyle) { this.dateStyle = dateStyle; } /** Setter for property timeStyle. * @param timeStyle New value of property timeStyle. * */ public void setTimeStyle(Expression timeStyle) { this.timeStyle = timeStyle; } /** Setter for property pattern. * @param pattern New value of property pattern. * */ public void setPattern(Expression pattern) { this.pattern = pattern; } /** Setter for property timeZone. * @param timeZone New value of property timeZone. * */ public void setTimeZone(Expression timeZone) { this.timeZone = timeZone; } /** Setter for property var. * @param var New value of property var. * */ public void setVar(String var) { this.var = var; } /** Setter for property scope. * @param scope New value of property scope. * */ public void setScope(String scope) { this.scope = scope; } //********************************************************************* // Private utility methods private DateFormat createFormatter(Locale loc) throws JellyException { DateFormat formatter = null; if ((etype == null) || DATE.equalsIgnoreCase(etype)) { formatter = DateFormat.getDateInstance( getStyle(edateStyle, "FORMAT_DATE_INVALID_DATE_STYLE"), loc); } else if (TIME.equalsIgnoreCase(etype)) { formatter = DateFormat.getTimeInstance( getStyle(etimeStyle, "FORMAT_DATE_INVALID_TIME_STYLE"), loc); } else if (DATETIME.equalsIgnoreCase(etype)) { formatter = DateFormat.getDateTimeInstance( getStyle(edateStyle, "FORMAT_DATE_INVALID_DATE_STYLE"), getStyle(etimeStyle, "FORMAT_DATE_INVALID_TIME_STYLE"), loc); } else { throw new JellyException("Date format invalue"); } return formatter; } /* * Converts the given string description of a formatting style for * dates and times to the corresponding java.util.DateFormat constant. * * @param style String description of formatting style for dates and times * @param errCode Error code to throw if given style is invalid * * @return java.util.DateFormat constant corresponding to given style * * @throws JellyException if the given style is invalid */ public static int getStyle(String style, String errCode) throws JellyException { int ret = DateFormat.DEFAULT; if (style != null) { if (DEFAULT.equalsIgnoreCase(style)) { ret = DateFormat.DEFAULT; } else if (SHORT.equalsIgnoreCase(style)) { ret = DateFormat.SHORT; } else if (MEDIUM.equalsIgnoreCase(style)) { ret = DateFormat.MEDIUM; } else if (LONG.equalsIgnoreCase(style)) { ret = DateFormat.LONG; } else if (FULL.equalsIgnoreCase(style)) { ret = DateFormat.FULL; } else { throw new JellyException("Invalid style " + errCode); } } return ret; } } 1.1 jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/SetTimeZoneTag.java Index: SetTimeZoneTag.java =================================================================== /* * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/java/org/apache/commons/jelly/tags/fmt/SetTimeZoneTag.java,v 1.1 2003/01/18 06:35:27 dion Exp $ * $Revision: 1.1 $ * $Date: 2003/01/18 06:35:27 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2002 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", "Commons", 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 * . * * $Id: SetTimeZoneTag.java,v 1.1 2003/01/18 06:35:27 dion Exp $ */ package org.apache.commons.jelly.tags.fmt; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.expression.Expression; import java.util.TimeZone; /** * Support for tag handlers for <setTimeZone>, the time zone setting * tag in JSTL. * @author Willie Vu * @version $Revision: 1.1 $ * */ public class SetTimeZoneTag extends TagSupport { private Expression value; private String var; private String scope; /** Creates a new instance of SetLocaleTag */ public SetTimeZoneTag() { } /** * Evaluates this tag after all the tags properties have been initialized. * */ public void doTag(XMLOutput output) throws Exception { TimeZone timeZone = null; Object valueInput = null; if (this.value != null) { valueInput = this.value.evaluate(context); } if (valueInput == null) { timeZone = TimeZone.getTimeZone("GMT"); } else if (valueInput instanceof String) { if (((String) valueInput).trim().equals("")) { timeZone = TimeZone.getTimeZone("GMT"); } else { timeZone = TimeZone.getTimeZone((String) valueInput); } } else { timeZone = (TimeZone) valueInput; } if (scope != null) { context.setVariable(Config.FMT_TIME_ZONE, scope, timeZone); } else { context.setVariable(Config.FMT_TIME_ZONE, timeZone); } } public void setValue(Expression value) { this.value = value; } public void setVar(String var) { this.var = var; } public void setScope(String scope) { this.scope = scope; } } 1.2 +77 -76 jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/test/org/apache/commons/jelly/tags/fmt/suite.jelly Index: suite.jelly =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/fmt/src/test/org/apache/commons/jelly/tags/fmt/suite.jelly,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- suite.jelly 16 Jan 2003 16:21:46 -0000 1.1 +++ suite.jelly 18 Jan 2003 06:35:27 -0000 1.2 @@ -1,76 +1,77 @@ - - - - - - - - ${keyvar} - invalid.key - - - i10n content is - key1: '${dummyKey1}' - key2: '${dummyKey2}' - keyInvalid: '${dummyKeyInvalid}' - - - - - - - - - - - ${keyvar} - - - - - i10n content is - key3: '${dummyKey3}' - - - - - - - - - key2 - invalid.key - - - i10n content is - key1: '${dummyKey1}' - key2: '${dummyKey2}' - keyInvalid: '${dummyKeyInvalid}' - - - - - - - - - - - key2 - invalid.key - - - i10n content is - key1: '${dummyKey1}' - key2: '${dummyKey2}' - keyInvalid: '${dummyKeyInvalid}' - - - - - - + + + + + + + + ${keyvar} + invalid.key + + + i10n content is + key1: '${dummyKey1}' + key2: '${dummyKey2}' + keyInvalid: '${dummyKeyInvalid}' + + + + + + + + + + + ${keyvar} + + + + + i10n content is + key3: '${dummyKey3}' + + + + + + + + + key2 + invalid.key + + + i10n content is + key1: '${dummyKey1}' + key2: '${dummyKey2}' + keyInvalid: '${dummyKeyInvalid}' + + + + + + + + + + + key2 + invalid.key + + + i10n content is + key1: '${dummyKey1}' + key2: '${dummyKey2}' + keyInvalid: '${dummyKeyInvalid}' + + + + + + 1.2 +9 -0 jakarta-commons-sandbox/jelly/jelly-tags/fmt/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/fmt/project.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- project.xml 16 Jan 2003 16:21:46 -0000 1.1 +++ project.xml 18 Jan 2003 06:35:27 -0000 1.2 @@ -60,6 +60,15 @@ 1.0-beta-4 + + commons-jelly+tags-beanshell + SNAPSHOT + + + + bsh + 1.2-b3 + -- To unsubscribe, e-mail: For additional commands, e-mail: