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/rt/sql DateParamTag.java
Date Tue, 23 Apr 2002 17:41:55 GMT
luehe       02/04/23 10:41:55

  Modified:    standard/src/org/apache/taglibs/standard/resources
                        Resources.properties
               standard/src/org/apache/taglibs/standard/tag/common/sql
                        DateParamTagSupport.java
               standard/src/org/apache/taglibs/standard/tag/el/sql
                        DateParamTag.java
               standard/src/org/apache/taglibs/standard/tag/rt/sql
                        DateParamTag.java
  Log:
  Fixed 8414: setDateParam type attribute
  
  Revision  Changes    Path
  1.29      +3 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Resources.properties	22 Apr 2002 20:03:42 -0000	1.28
  +++ Resources.properties	23 Apr 2002 17:41:54 -0000	1.29
  @@ -211,6 +211,9 @@
   SQL_MAXROWS_INVALID=\
       'javax.servlet.jsp.jstl.sql.maxRows' configuration setting neither an Integer nor a
String
   
  +SQL_DATE_PARAM_INVALID_TYPE=\
  +    In <dateParam>, invalid 'type' attribute: "{0}"
  +
   # XML
   
   FOREACH_NOT_NODESET=\
  
  
  
  1.2       +37 -25    jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/DateParamTagSupport.java
  
  Index: DateParamTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/DateParamTagSupport.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DateParamTagSupport.java	14 Apr 2002 02:10:31 -0000	1.1
  +++ DateParamTagSupport.java	23 Apr 2002 17:41:55 -0000	1.2
  @@ -72,9 +72,21 @@
    */
   
   public abstract class DateParamTagSupport extends BodyTagSupport {
  -    protected java.util.Date value;
  +
  +    //*********************************************************************
  +    // Private constants
  +    
  +    private static final String TIMESTAMP_TYPE = "timestamp";
  +    private static final String TIME_TYPE = "time";
  +    private static final String DATE_TYPE = "date";
  +	
  +
  +    //*********************************************************************
  +    // Protected state
  +
       protected String type;
  -    protected Object rawValue;
  +    protected java.util.Date value;
  +
   
       //*********************************************************************
       // Constructor
  @@ -86,9 +98,10 @@
   
       private void init() {
           value = null;
  -        type = "TIMESTAMP";
  +        type = null;
       }
   
  +
       //*********************************************************************
       // Tag logic
   
  @@ -100,36 +113,35 @@
                   Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT"));
   	}
   
  -        if (rawValue != null) {
  -            value = getConvertedValue();
  +        if (value != null) {
  +            convertValue();
           }
   
   	parent.addSQLParameter(value);
   	return EVAL_PAGE;
       }
   
  +
       //*********************************************************************
       // Private utility methods
   
  -    private java.util.Date getConvertedValue() {
  -        if (type.equalsIgnoreCase("TIMESTAMP")) {
  -            if (!(rawValue instanceof java.sql.Timestamp)) {
  -                return new java.sql.Timestamp(
  -                    ((java.util.Date)rawValue).getTime());
  -            }
  -        }
  -        if (type.equalsIgnoreCase("TIME")) {
  -            if (!(rawValue instanceof java.sql.Time)) {
  -                return new java.sql.Time(
  -                    ((java.util.Date)rawValue).getTime());
  -            }
  -        }
  -        if (type.equalsIgnoreCase("DATE")) {
  -            if (!(rawValue instanceof java.sql.Date)) {
  -                return new java.sql.Date(
  -                    ((java.util.Date)rawValue).getTime());
  -            }
  -        }
  -        return (java.util.Date)rawValue;
  +    private void convertValue() throws JspException {
  +
  +	if ((type == null) || (type.equalsIgnoreCase(TIMESTAMP_TYPE))) {
  +	    if (!(value instanceof java.sql.Timestamp)) {
  +		value = new java.sql.Timestamp(value.getTime());
  +	    }
  +	} else if (type.equalsIgnoreCase(TIME_TYPE)) {
  +	    if (!(value instanceof java.sql.Time)) {
  +		value = new java.sql.Time(value.getTime());
  +	    }
  +	} else if (type.equalsIgnoreCase(DATE_TYPE)) {
  +	    if (!(value instanceof java.sql.Date)) {
  +		value = new java.sql.Date(value.getTime());
  +	    }
  +	} else {
  +	    throw new JspException(
  +                Resources.getMessage("SQL_DATE_PARAM_INVALID_TYPE", type));
  +	}
       }
   }
  
  
  
  1.2       +6 -6      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/DateParamTag.java
  
  Index: DateParamTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/DateParamTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DateParamTag.java	14 Apr 2002 02:10:31 -0000	1.1
  +++ DateParamTag.java	23 Apr 2002 17:41:55 -0000	1.2
  @@ -54,6 +54,7 @@
    */ 
   package org.apache.taglibs.standard.tag.el.sql;
   
  +import java.util.Date;
   import javax.servlet.jsp.*;
   import org.apache.taglibs.standard.lang.support.*;
   import org.apache.taglibs.standard.tag.common.sql.DateParamTagSupport;
  @@ -87,14 +88,13 @@
       // Evaluates expressions as necessary
       private void evaluateExpressions() throws JspException {
   	if (valueEL != null) {
  -	    rawValue = (Object) 
  -		ExpressionEvaluatorManager.evaluate("value", valueEL, 
  -		    Object.class, this, pageContext);
  +	    value = (Date) ExpressionEvaluatorManager.evaluate(
  +                "value", valueEL, Date.class, this, pageContext);
   	}
  +
   	if (typeEL != null) {
  -	    type = (String) 
  -		ExpressionEvaluatorManager.evaluate("type", typeEL, 
  -		    String.class, this, pageContext);
  +	    type = (String) ExpressionEvaluatorManager.evaluate(
  +                "type", typeEL, String.class, this, pageContext);
           }
       }
   
  
  
  
  1.2       +1 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/DateParamTag.java
  
  Index: DateParamTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/DateParamTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DateParamTag.java	14 Apr 2002 02:10:31 -0000	1.1
  +++ DateParamTag.java	23 Apr 2002 17:41:55 -0000	1.2
  @@ -67,7 +67,7 @@
   public class DateParamTag extends DateParamTagSupport {
       
       public void setValue(Date value) {
  -	this.rawValue = value;
  +	this.value = value;
       }
   
       public void setType(String type) {
  
  
  

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