FileDocCategorySizeDatePackage
TimeValueTag.javaAPI DocExample3607Thu Jun 28 16:14:16 BST 2001com.ora.jsp.tags.sql.value

TimeValueTag

public class TimeValueTag extends ValueTag
This class is a custom action intended to be used in the body of a sqlQuery or an sqlUpdate action element. It adds the specified value to its parent's value list.
author
Hans Bergsten, Gefion software
version
1.0

Fields Summary
private Time
value
Constructors Summary
Methods Summary
public intdoEndTag()
Gets the value, specified by the value attribute, the stringValue attribute, the param attribute, or the name and property attributes, and adds it to the parent's value list. If the value is a String and a pattern attribute is specified, the String is converted into the appropriate type before being added to the parent's value list.

        if (stringValue != null) {
            value = toTime(stringValue, pattern);
        }
        else if (param != null) {
            String paramValue = getParameter(param);
            value = toTime(paramValue, pattern);
        }
        else if (name != null) {
            value = getTime(name, property, pattern);
        }
        ValueTagParent parent = 
            (ValueTagParent) findAncestorWithClass(this, ValueTagParent.class);
        if (parent == null) {
            throw new JspException("The sqlTimeValue action is not " +
                "enclosed by a supported action type");
        }
        parent.addValue(new TimeValue(value));
        return EVAL_PAGE;
    
private java.sql.TimegetTime(java.lang.String beanName, java.lang.String propertyName, java.lang.String pattern)

        Time timeValue = null;
        Object bean = getBean(beanName);
        Method readMethod = getPropertyReadMethod(bean, propertyName);
        Class returnType = readMethod.getReturnType();
        Object value = getValue(bean, readMethod, propertyName);
        
        if (Time.class.isAssignableFrom(returnType)) {
            timeValue = (Time) value;
        }
        else if (String.class.isAssignableFrom(returnType)) {
            timeValue = toTime((String) value, pattern);
        }
        else {
            throw new JspException("Read method for the " + propertyName +
                " property in the bean named " + beanName + " is not of type " +
                " String or Time");
        }
        return timeValue;
    
public voidrelease()
Releases all instance variables.

        value = null;
        super.release();
    
public voidsetValue(java.util.Date value)
Sets the value property.

        // Convert the java.util.Date to a java.sql.Time
        this.value = new Time(value.getTime());
    
private java.sql.TimetoTime(java.lang.String stringValue, java.lang.String pattern)

        Time timeValue = null;
        try {
            java.util.Date date = StringFormat.toDate(stringValue, pattern);
            timeValue = new Time(date.getTime());
        }
        catch (ParseException e) {
            throw new JspException(stringValue + " can not be converted to " +
                " a Time using pattern: " + pattern + ". Message: " +
                e.getMessage());
        }
        return timeValue;