Example usage for java.lang Number floatValue

List of usage examples for java.lang Number floatValue

Introduction

In this page you can find the example usage for java.lang Number floatValue.

Prototype

public abstract float floatValue();

Source Link

Document

Returns the value of the specified number as a float .

Usage

From source file:org.pentaho.reporting.engine.classic.wizard.WizardProcessor.java

protected void setupDefaultPadding(final Band band, final Element detailElement) {
    final Object maybePaddingTop = band.getAttribute(AttributeNames.Wizard.NAMESPACE,
            AttributeNames.Wizard.PADDING_TOP);
    final Object maybePaddingLeft = band.getAttribute(AttributeNames.Wizard.NAMESPACE,
            AttributeNames.Wizard.PADDING_LEFT);
    final Object maybePaddingBottom = band.getAttribute(AttributeNames.Wizard.NAMESPACE,
            AttributeNames.Wizard.PADDING_BOTTOM);
    final Object maybePaddingRight = band.getAttribute(AttributeNames.Wizard.NAMESPACE,
            AttributeNames.Wizard.PADDING_RIGHT);

    if (maybePaddingTop instanceof Number == false || maybePaddingLeft instanceof Number == false
            || maybePaddingBottom instanceof Number == false || maybePaddingRight instanceof Number == false) {
        return;//from  w w  w  .j ava2s  .c  o  m
    }

    final Number paddingTop = (Number) maybePaddingTop;
    final Number paddingLeft = (Number) maybePaddingLeft;
    final Number paddingBottom = (Number) maybePaddingBottom;
    final Number paddingRight = (Number) maybePaddingRight;

    final ElementStyleSheet styleSheet = detailElement.getStyle();
    styleSheet.setStyleProperty(ElementStyleKeys.PADDING_TOP, new Float(paddingTop.floatValue()));
    styleSheet.setStyleProperty(ElementStyleKeys.PADDING_LEFT, new Float(paddingLeft.floatValue()));
    styleSheet.setStyleProperty(ElementStyleKeys.PADDING_BOTTOM, new Float(paddingBottom.floatValue()));
    styleSheet.setStyleProperty(ElementStyleKeys.PADDING_RIGHT, new Float(paddingRight.floatValue()));
}

From source file:net.paoding.rose.jade.statement.UpdateQuerier.java

private Object executeSingle(StatementRuntime runtime, Class<?> returnType) {
    Number result;
    DataAccess dataAccess = dataAccessProvider.getDataAccess(//
            runtime.getMetaData(), runtime.getProperties());
    if (returnGeneratedKeys) {
        ArrayList<Number> keys = new ArrayList<Number>(1);
        KeyHolder generatedKeyHolder = new GeneratedKeyHolder(keys);
        dataAccess.update(runtime.getSQL(), runtime.getArgs(), generatedKeyHolder);
        if (keys.size() > 0) {
            result = generatedKeyHolder.getKey();
        } else {/*  w w  w  .  j  a  v a2  s.c  om*/
            result = null;
        }
    } else {
        result = new Integer(dataAccess.update(runtime.getSQL(), runtime.getArgs(), null));
    }
    //
    if (result == null || returnType == void.class) {
        return null;
    }
    if (returnType == result.getClass()) {
        return result;
    }

    // ?
    if (returnType == Integer.class) {
        return result.intValue();
    } else if (returnType == Long.class) {
        return result.longValue();
    } else if (returnType == Boolean.class) {
        return result.intValue() > 0 ? Boolean.TRUE : Boolean.FALSE;
    } else if (returnType == Double.class) {
        return result.doubleValue();
    } else if (returnType == Float.class) {
        return result.floatValue();
    } else if (Number.class.isAssignableFrom(returnType)) {
        return result;
    } else {
        throw new DataRetrievalFailureException("The generated key is not of a supported numeric type. "
                + "Unable to cast [" + result.getClass().getName() + "] to [" + Number.class.getName() + "]");
    }
}

From source file:com.sinosoft.one.data.jade.statement.UpdateQuerier.java

private Object executeSingle(StatementRuntime runtime, Class<?> returnType) {
    // DAOIdentity?1/20
    if (returnType == Identity.class) {
        if (new Random().nextInt(20) == 1) {
            new IllegalArgumentException(
                    "message by zhiliang.wang: change the deprecated Identity to @ReturnGeneratedKeys please: "
                            + runtime.getMetaData()).printStackTrace();
        }//from  w w  w  .  j a  v a 2 s .  co  m
    }
    Number result;
    DataAccess dataAccess = new DataAccessImpl(em);
    if (returnGeneratedKeys) {
        //ArrayList<Number> keys = new ArrayList<Number>(1);
        List<Map<String, Object>> keys = new ArrayList<Map<String, Object>>();
        KeyHolder generatedKeyHolder = new GeneratedKeyHolder(keys);
        dataAccess.update(runtime.getSQL(), runtime.getArgs(), generatedKeyHolder);
        if (keys.size() > 0) {
            result = generatedKeyHolder.getKey();
        } else {
            result = null;
        }
    } else {
        result = new Integer(dataAccess.update(runtime.getSQL(), runtime.getArgs(), null));
    }
    //
    if (result == null || returnType == void.class) {
        return null;
    }
    if (returnType == result.getClass()) {
        return result;
    }

    // ?
    if (returnType == Integer.class) {
        return result.intValue();
    } else if (returnType == Long.class) {
        return result.longValue();
    } else if (returnType == Boolean.class) {
        return result.intValue() > 0 ? Boolean.TRUE : Boolean.FALSE;
    } else if (returnType == Double.class) {
        return result.doubleValue();
    } else if (returnType == Float.class) {
        return result.floatValue();
    } else if (returnType == Identity.class) {
        return new Identity((Number) result);
    } else if (Number.class.isAssignableFrom(returnType)) {
        return result;
    } else {
        throw new DataRetrievalFailureException("The generated key is not of a supported numeric type. "
                + "Unable to cast [" + result.getClass().getName() + "] to [" + Number.class.getName() + "]");
    }
}

From source file:com.gzj.tulip.jade.statement.UpdateQuerier.java

private Object executeSingle(StatementRuntime runtime) {
    Number result;
    DataAccess dataAccess = dataAccessFactory.getDataAccess(//
            runtime.getMetaData(), runtime.getAttributes());
    if (returnGeneratedKeys.shouldReturnGerneratedKeys(runtime)) {
        ArrayList<Map<String, Object>> keys = new ArrayList<Map<String, Object>>(1);
        KeyHolder generatedKeyHolder = new GeneratedKeyHolder(keys);
        dataAccess.update(runtime.getSQL(), runtime.getArgs(), generatedKeyHolder);
        if (keys.size() > 0) {
            result = generatedKeyHolder.getKey();
        } else {//from ww w .  j a va2 s . c o  m
            result = null;
        }
    } else {
        result = new Integer(dataAccess.update(runtime.getSQL(), runtime.getArgs(), null));
    }
    //
    if (result == null || returnType == void.class) {
        return null;
    }
    if (returnType == result.getClass()) {
        return result;
    }
    // ?
    if (returnType == Integer.class) {
        return result.intValue();
    } else if (returnType == Long.class) {
        return result.longValue();
    } else if (returnType == Boolean.class) {
        return result.intValue() > 0 ? Boolean.TRUE : Boolean.FALSE;
    } else if (returnType == Double.class) {
        return result.doubleValue();
    } else if (returnType == Float.class) {
        return result.floatValue();
    } else if (returnType == Number.class) {
        return result;
    } else if (returnType == String.class || returnType == CharSequence.class) {
        return String.valueOf(result);
    } else {
        throw new DataRetrievalFailureException(
                "The generated key is not of a supported numeric type: " + returnType.getName());
    }
}

From source file:org.crazydog.util.spring.NumberUtils.java

/**
 * Convert the given number into an instance of the given target class.
 *
 * @param number      the number to convert
 * @param targetClass the target class to convert to
 * @return the converted number//from ww w .  j  a  v a 2s. co  m
 * @throws IllegalArgumentException if the target class is not supported
 *                                  (i.e. not a standard Number subclass as included in the JDK)
 * @see Byte
 * @see Short
 * @see Integer
 * @see Long
 * @see BigInteger
 * @see Float
 * @see Double
 * @see BigDecimal
 */
@SuppressWarnings("unchecked")
public static <T extends Number> T convertNumberToTargetClass(Number number, Class<T> targetClass)
        throws IllegalArgumentException {

    org.springframework.util.Assert.notNull(number, "Number must not be null");
    org.springframework.util.Assert.notNull(targetClass, "Target class must not be null");

    if (targetClass.isInstance(number)) {
        return (T) number;
    } else if (Byte.class == targetClass) {
        long value = number.longValue();
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Byte(number.byteValue());
    } else if (Short.class == targetClass) {
        long value = number.longValue();
        if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Short(number.shortValue());
    } else if (Integer.class == targetClass) {
        long value = number.longValue();
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Integer(number.intValue());
    } else if (Long.class == targetClass) {
        BigInteger bigInt = null;
        if (number instanceof BigInteger) {
            bigInt = (BigInteger) number;
        } else if (number instanceof BigDecimal) {
            bigInt = ((BigDecimal) number).toBigInteger();
        }
        // Effectively analogous to JDK 8's BigInteger.longValueExact()
        if (bigInt != null && (bigInt.compareTo(LONG_MIN) < 0 || bigInt.compareTo(LONG_MAX) > 0)) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Long(number.longValue());
    } else if (BigInteger.class == targetClass) {
        if (number instanceof BigDecimal) {
            // do not lose precision - use BigDecimal's own conversion
            return (T) ((BigDecimal) number).toBigInteger();
        } else {
            // original value is not a Big* number - use standard long conversion
            return (T) BigInteger.valueOf(number.longValue());
        }
    } else if (Float.class == targetClass) {
        return (T) new Float(number.floatValue());
    } else if (Double.class == targetClass) {
        return (T) new Double(number.doubleValue());
    } else if (BigDecimal.class == targetClass) {
        // always use BigDecimal(String) here to avoid unpredictability of BigDecimal(double)
        // (see BigDecimal javadoc for details)
        return (T) new BigDecimal(number.toString());
    } else {
        throw new IllegalArgumentException("Could not convert number [" + number + "] of type ["
                + number.getClass().getName() + "] to unknown target class [" + targetClass.getName() + "]");
    }
}

From source file:net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.java

@Override
public boolean start(JRStyledText styledText) {
    if (!measureSimpleTexts) {
        return false;
    }//  w w  w . j  a v a2 s .c  o m

    List<Run> runs = styledText.getRuns();
    if (runs.size() != 1) {
        // multiple styles
        return false;
    }

    wholeText = styledText.getText();
    if (wholeText.indexOf('\t') >= 0) {
        // supporting tabs is more difficult because we'd need
        // measureParagraphFragment to include the white space advance.
        return false;
    }

    Run run = styledText.getRuns().get(0);
    if (run.attributes.get(TextAttribute.SUPERSCRIPT) != null) {
        // not handling this case, see JRStyledText.getAwtAttributedString
        return false;
    }

    AwtFontAttribute fontAttribute = AwtFontAttribute.fromAttributes(run.attributes);
    Number size = (Number) run.attributes.get(TextAttribute.SIZE);
    if (!fontAttribute.hasAttribute() || size == null) {
        // this should not happen, but still checking
        return false;
    }

    int style = 0;
    Number posture = (Number) run.attributes.get(TextAttribute.POSTURE);
    if (posture != null && !TextAttribute.POSTURE_REGULAR.equals(posture)) {
        if (TextAttribute.POSTURE_OBLIQUE.equals(posture)) {
            style |= Font.ITALIC;
        } else {
            // non standard posture
            return false;
        }
    }

    Number weight = (Number) run.attributes.get(TextAttribute.WEIGHT);
    if (weight != null && !TextAttribute.WEIGHT_REGULAR.equals(weight)) {
        if (TextAttribute.WEIGHT_BOLD.equals(weight)) {
            style |= Font.BOLD;
        } else {
            // non standard weight
            return false;
        }
    }

    fontKey = new FontKey(fontAttribute, size.floatValue(), style, styledText.getLocale());
    createFontInfo(run.attributes);

    return true;
}

From source file:org.cloudgraph.hbase.results.ResultsAggregator.java

private void aggregate(FunctionPath funcPath, PlasmaDataGraph existing, PlasmaDataGraph graph) {
    DataType scalarType = funcPath.getFunc().getName().getScalarDatatype(funcPath.getDataType());

    PlasmaDataObject existingEndpoint = null;
    PlasmaDataObject newEndpoint = null;
    if (funcPath.getPath().size() == 0) {
        existingEndpoint = (PlasmaDataObject) existing.getRootObject();
        newEndpoint = (PlasmaDataObject) graph.getRootObject();
    } else {//from   ww w . j a v a  2 s . c o m
        existingEndpoint = (PlasmaDataObject) existing.getRootObject()
                .getDataObject(funcPath.getPath().toString());
        newEndpoint = (PlasmaDataObject) graph.getRootObject().getDataObject(funcPath.getPath().toString());
    }

    Number existingFuncValue = (Number) existingEndpoint.get(funcPath.getFunc().getName(),
            funcPath.getProperty());
    if (funcPath.getFunc().getName().ordinal() == FunctionName.COUNT.ordinal()) {
        Long newCount = existingFuncValue.longValue() + 1;
        if (newCount > 0) {
            existingEndpoint.set(funcPath.getFunc().getName(), funcPath.getProperty(), newCount);
        } else { // overflow
            log.warn("aggregate " + funcPath.getFunc().getName() + " overflow for target type " + scalarType
                    + " - truncating aggregate");
        }
    } else {
        if (newEndpoint.isSet(funcPath.getProperty())) {
            Object newValue = newEndpoint.get(funcPath.getProperty());
            Number newScalarValue = (Number) DataConverter.INSTANCE.convert(scalarType,
                    funcPath.getProperty().getType(), newValue);
            switch (funcPath.getFunc().getName()) {
            case AVG: // Note; computing a sum until all values accumulated
                switch (scalarType) {
                case Double:
                    Double avg = existingFuncValue != null
                            ? existingFuncValue.doubleValue() + newScalarValue.doubleValue()
                            : newScalarValue.doubleValue();
                    existingEndpoint.set(funcPath.getFunc().getName(), funcPath.getProperty(), avg);
                    break;
                case Float:
                    Float floatAvg = existingFuncValue != null
                            ? existingFuncValue.floatValue() + newScalarValue.floatValue()
                            : newScalarValue.floatValue();
                    existingEndpoint.set(funcPath.getFunc().getName(), funcPath.getProperty(), floatAvg);
                    break;
                default:
                    throw new IllegalArgumentException("illsgal datatype (" + scalarType
                            + ") conversion for function, " + funcPath.getFunc().getName());
                }
                break;
            case MAX:

                if (existingFuncValue == null || Double.valueOf(newScalarValue.doubleValue())
                        .compareTo(existingFuncValue.doubleValue()) > 0)
                    existingEndpoint.set(funcPath.getFunc().getName(), funcPath.getProperty(), newScalarValue);
                break;
            case MIN:
                if (existingFuncValue == null || Double.valueOf(newScalarValue.doubleValue())
                        .compareTo(existingFuncValue.doubleValue()) < 0)
                    existingEndpoint.set(funcPath.getFunc().getName(), funcPath.getProperty(), newScalarValue);
                break;
            case SUM:
                switch (scalarType) {
                case Double:
                    Double doubleSum = existingFuncValue != null
                            ? existingFuncValue.doubleValue() + newScalarValue.doubleValue()
                            : newScalarValue.doubleValue();
                    if (!doubleSum.isInfinite()) {
                        existingEndpoint.set(funcPath.getFunc().getName(), funcPath.getProperty(), doubleSum);
                    } else { // overflow
                        log.warn("aggregate " + funcPath.getFunc().getName() + " overflow for target type "
                                + scalarType + " - truncating aggregate");
                    }
                    break;
                case Long:
                    Long longSum = existingFuncValue != null
                            ? existingFuncValue.longValue() + newScalarValue.longValue()
                            : newScalarValue.longValue();
                    if (longSum > 0) {
                        existingEndpoint.set(funcPath.getFunc().getName(), funcPath.getProperty(), longSum);
                    } else { // overflow
                        log.warn("aggregate " + funcPath.getFunc().getName() + " overflow for target type "
                                + scalarType + " - truncating aggregate");
                    }
                    break;
                default:
                    throw new IllegalArgumentException("illegal datatype (" + scalarType
                            + ") conversion for function, " + funcPath.getFunc().getName());
                }
                break;
            default:
                throw new GraphServiceException(
                        "unimplemented aggregate function, " + funcPath.getFunc().getName());
            }
        } else if (!funcPath.getProperty().isNullable())
            log.warn("expected value for non-nullable property, " + funcPath.getProperty());
    }

}

From source file:net.sf.jasperreports.engine.export.HtmlExporter.java

public String toSizeUnit(float size) {
    Number number = toZoom(size);
    if (number.intValue() == number.floatValue()) {
        number = number.intValue();/*from   w  ww .j a v a 2s  .c  om*/
    }

    return String.valueOf(number) + getCurrentItemConfiguration().getSizeUnit().getName();
}

From source file:org.structr.core.entity.AbstractNode.java

private Object convert(Object value, Class type) {

    Object convertedObject = null;

    if (type.equals(String.class)) {

        // strings can be returned immediately
        return value.toString();

    } else if (value instanceof Number) {

        Number number = (Number) value;

        if (type.equals(Integer.class) || type.equals(Integer.TYPE)) {
            return number.intValue();

        } else if (type.equals(Long.class) || type.equals(Long.TYPE)) {
            return number.longValue();

        } else if (type.equals(Double.class) || type.equals(Double.TYPE)) {
            return number.doubleValue();

        } else if (type.equals(Float.class) || type.equals(Float.TYPE)) {
            return number.floatValue();

        } else if (type.equals(Short.class) || type.equals(Integer.TYPE)) {
            return number.shortValue();

        } else if (type.equals(Byte.class) || type.equals(Byte.TYPE)) {
            return number.byteValue();

        }//from www  .j av a  2  s.c om

    } else if (value instanceof List) {

        return value;

    } else if (value instanceof Map) {
        return value;
    }

    // fallback
    try {

        Method valueOf = type.getMethod("valueOf", String.class);
        if (valueOf != null) {

            convertedObject = valueOf.invoke(null, value.toString());

        } else {

            logger.log(Level.WARNING, "Unable to find static valueOf method for type {0}", type);
        }

    } catch (Throwable t) {

        logger.log(Level.WARNING,
                "Unable to deserialize value {0} of type {1}, Class has no static valueOf method.",
                new Object[] { value, type });
    }

    return convertedObject;
}

From source file:com.swordlord.gozer.datatypeformat.DataTypeHelper.java

/**
 * Return compatible class for typedValue based on untypedValueClass 
 * //ww  w.jav  a2s  . co m
 * @param untypedValueClass
 * @param typedValue
 * @return
 */
public static Object fromDataType(Class<?> untypedValueClass, Object typedValue) {
    Log LOG = LogFactory.getLog(DataTypeHelper.class);

    if (typedValue == null) {
        return null;
    }

    if (untypedValueClass == null) {
        return typedValue;
    }

    if (ClassUtils.isAssignable(typedValue.getClass(), untypedValueClass)) {
        return typedValue;
    }

    String strTypedValue = null;
    boolean isStringTypedValue = typedValue instanceof String;

    Number numTypedValue = null;
    boolean isNumberTypedValue = typedValue instanceof Number;

    Boolean boolTypedValue = null;
    boolean isBooleanTypedValue = typedValue instanceof Boolean;

    Date dateTypedValue = null;
    boolean isDateTypedValue = typedValue instanceof Date;

    if (isStringTypedValue) {
        strTypedValue = (String) typedValue;
    }
    if (isNumberTypedValue) {
        numTypedValue = (Number) typedValue;
    }
    if (isBooleanTypedValue) {
        boolTypedValue = (Boolean) typedValue;
    }
    if (isDateTypedValue) {
        dateTypedValue = (Date) typedValue;
    }

    Object v = null;
    if (String.class.equals(untypedValueClass)) {
        v = ObjectUtils.toString(typedValue);
    } else if (BigDecimal.class.equals(untypedValueClass)) {
        if (isStringTypedValue) {
            v = NumberUtils.createBigDecimal(strTypedValue);
        } else if (isNumberTypedValue) {
            v = new BigDecimal(numTypedValue.doubleValue());
        } else if (isBooleanTypedValue) {
            v = new BigDecimal(BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        } else if (isDateTypedValue) {
            v = new BigDecimal(dateTypedValue.getTime());
        }
    } else if (Boolean.class.equals(untypedValueClass)) {
        if (isStringTypedValue) {
            v = BooleanUtils.toBooleanObject(strTypedValue);
        } else if (isNumberTypedValue) {
            v = BooleanUtils.toBooleanObject(numTypedValue.intValue());
        } else if (isDateTypedValue) {
            v = BooleanUtils.toBooleanObject((int) dateTypedValue.getTime());
        }
    } else if (Byte.class.equals(untypedValueClass)) {
        if (isStringTypedValue) {
            v = Byte.valueOf(strTypedValue);
        } else if (isNumberTypedValue) {
            v = new Byte(numTypedValue.byteValue());
        } else if (isBooleanTypedValue) {
            v = new Byte((byte) BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        } else if (isDateTypedValue) {
            v = new Byte((byte) dateTypedValue.getTime());
        }
    } else if (byte[].class.equals(untypedValueClass)) {
        if (isStringTypedValue) {
            v = strTypedValue.getBytes();
        }
    } else if (Double.class.equals(untypedValueClass)) {
        if (isStringTypedValue) {
            v = NumberUtils.createDouble(strTypedValue);
        } else if (isNumberTypedValue) {
            v = new Double(numTypedValue.doubleValue());
        } else if (isBooleanTypedValue) {
            v = new Double(BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        } else if (isDateTypedValue) {
            v = new Double(dateTypedValue.getTime());
        }
    } else if (Float.class.equals(untypedValueClass)) {
        if (isStringTypedValue) {
            v = NumberUtils.createFloat(strTypedValue);
        } else if (isNumberTypedValue) {
            v = new Float(numTypedValue.floatValue());
        } else if (isBooleanTypedValue) {
            v = new Float(BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        } else if (isDateTypedValue) {
            v = new Float(dateTypedValue.getTime());
        }
    } else if (Short.class.equals(untypedValueClass)) {
        if (isStringTypedValue) {
            v = NumberUtils.createInteger(strTypedValue);
        } else if (isNumberTypedValue) {
            v = new Integer(numTypedValue.intValue());
        } else if (isBooleanTypedValue) {
            v = BooleanUtils.toIntegerObject(boolTypedValue.booleanValue());
        } else if (isDateTypedValue) {
            v = new Integer((int) dateTypedValue.getTime());
        }
    } else if (Integer.class.equals(untypedValueClass)) {
        if (isStringTypedValue) {
            v = NumberUtils.createInteger(strTypedValue);
        } else if (isNumberTypedValue) {
            v = new Integer(numTypedValue.intValue());
        } else if (isBooleanTypedValue) {
            v = BooleanUtils.toIntegerObject(boolTypedValue.booleanValue());
        } else if (isDateTypedValue) {
            v = new Integer((int) dateTypedValue.getTime());
        }
    } else if (Long.class.equals(untypedValueClass)) {
        if (isStringTypedValue) {
            v = NumberUtils.createLong(strTypedValue);
        } else if (isNumberTypedValue) {
            v = new Long(numTypedValue.longValue());
        } else if (isBooleanTypedValue) {
            v = new Long(BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        } else if (isDateTypedValue) {
            v = new Long(dateTypedValue.getTime());
        }
    } else if (java.sql.Date.class.equals(untypedValueClass)) {
        if (isNumberTypedValue) {
            v = new java.sql.Date(numTypedValue.longValue());
        } else if (isDateTypedValue) {
            v = new java.sql.Date(dateTypedValue.getTime());
        }
    } else if (java.sql.Time.class.equals(untypedValueClass)) {
        if (isNumberTypedValue) {
            v = new java.sql.Time(numTypedValue.longValue());
        } else if (isDateTypedValue) {
            v = new java.sql.Time(dateTypedValue.getTime());
        }
    } else if (java.sql.Timestamp.class.equals(untypedValueClass)) {
        if (isNumberTypedValue) {
            v = new java.sql.Timestamp(numTypedValue.longValue());
        } else if (isDateTypedValue) {
            v = new java.sql.Timestamp(dateTypedValue.getTime());
        }
    } else if (Date.class.equals(untypedValueClass)) {
        if (isNumberTypedValue) {
            v = new Date(numTypedValue.longValue());
        } else if (isStringTypedValue) {
            try {
                v = DateFormat.getDateInstance().parse(strTypedValue);
            } catch (ParseException e) {
                LOG.error("Unable to parse the date : " + strTypedValue);
                LOG.debug(e.getMessage());
            }
        }
    }
    return v;
}