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

FloatValueTag

public class FloatValueTag 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.1

Fields Summary
private float
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 = toFloat(stringValue, pattern);
        }
        else if (param != null) {
            String paramValue = getParameter(param);
            value = toFloat(paramValue, pattern);
        }
        else if (name != null) {
            value = getFloat(name, property, pattern);
        }
        ValueTagParent parent = 
            (ValueTagParent) findAncestorWithClass(this, ValueTagParent.class);
        if (parent == null) {
            throw new JspException("The sqlFloatValue action is not " +
                "enclosed by a supported action type");
        }
        parent.addValue(new FloatValue(value));
        return EVAL_PAGE;
    
private floatgetFloat(java.lang.String beanName, java.lang.String propertyName, java.lang.String pattern)

        float floatValue;
        Object bean = getBean(beanName);
        Method readMethod = getPropertyReadMethod(bean, propertyName);
        Class returnType = readMethod.getReturnType();
        Object value = getValue(bean, readMethod, propertyName);
        
        if (Float.TYPE.isAssignableFrom(returnType)) {
            floatValue = ((Float) value).floatValue();
        }
        else if (String.class.isAssignableFrom(returnType)) {
            floatValue = toFloat((String) value, pattern);
        }
        else {
            throw new JspException("Read method for the " + propertyName +
                " property in the bean named " + beanName + " is not of type " +
                " String or float");
        }
        return floatValue;
    
public voidsetValue(float value)
Sets the value property.

        this.value = value;
    
private floattoFloat(java.lang.String stringValue, java.lang.String pattern)

        float floatValue;
        try {
            Number number = StringFormat.toNumber(stringValue, pattern);
            floatValue = number.floatValue();
        }
        catch (ParseException e) {
            throw new JspException(stringValue + " can not be converted to " +
                " a float using pattern: " + pattern + ". Message: " +
                e.getMessage());
        }
        return floatValue;