org.jfree.formula.typing

Class DefaultTypeRegistry

Implemented Interfaces:
TypeRegistry

public class DefaultTypeRegistry
extends java.lang.Object
implements TypeRegistry

Creation-Date: 02.11.2006, 12:46:08
Author:
Thomas Morgner

Constructor Summary

DefaultTypeRegistry()

Method Summary

TypeValuePair
convertTo(Type targetType, TypeValuePair valuePair)
Checks, whether the target type would accept the specified value object and value type.
This method is called for auto conversion of fonction parameters using the conversion type declared by the function metadata.
Date
convertToDate(Type type1, Object value)
Converts the object of the given type into a date.
Boolean
convertToLogical(Type type1, Object value)
Converts the object of the given type into a boolean.
Number
convertToNumber(Type type1, Object value)
converts the object of the given type into a number.
NumberSequence
convertToNumberSequence(Type type, Object value)
String
convertToText(Type type1, Object value)
(This conversion is used by the operator implementations.)
ExtendedComparator
getComparator(Type type1, Type type2)
Returns an comparator for the given types.
protected NumberFormat
getDefaultNumberFormat()
Type
guessTypeOfObject(Object o)
void
initialize(Configuration configuration, FormulaContext formulaContext)
protected NumberFormat[]
loadNumberFormats()

Constructor Details

DefaultTypeRegistry

public DefaultTypeRegistry()

Method Details

convertTo

public TypeValuePair convertTo(Type targetType,
                               TypeValuePair valuePair)
            throws TypeConversionException
Checks, whether the target type would accept the specified value object and value type.
This method is called for auto conversion of fonction parameters using the conversion type declared by the function metadata.
Specified by:
convertTo in interface TypeRegistry
Parameters:
targetType -
valuePair -

convertToDate

public Date convertToDate(Type type1,
                          Object value)
            throws TypeConversionException
Converts the object of the given type into a date.
Specified by:
convertToDate in interface TypeRegistry
Parameters:
type1 -
value -
Returns:
The value as Date or null.

convertToLogical

public Boolean convertToLogical(Type type1,
                                Object value)
            throws TypeConversionException
Converts the object of the given type into a boolean.
Specified by:
convertToLogical in interface TypeRegistry
Parameters:
type1 -
value -
Returns:
The value as Boolean or null.

convertToNumber

public Number convertToNumber(Type type1,
                              Object value)
            throws TypeConversionException
converts the object of the given type into a number. If the object is not convertible, a NumberFormatException is thrown. If the given value is null or not parsable as number, return null.
Specified by:
convertToNumber in interface TypeRegistry
Parameters:
type1 -
value -
Returns:

convertToNumberSequence

public NumberSequence convertToNumberSequence(Type type,
                                              Object value)
            throws TypeConversionException
Specified by:
convertToNumberSequence in interface TypeRegistry

convertToText

public String convertToText(Type type1,
                            Object value)
            throws TypeConversionException
(This conversion is used by the operator implementations.)
Specified by:
convertToText in interface TypeRegistry
Parameters:
type1 -
value -
Returns:
the value as string or an empty string, if the value given is null.

getComparator

public ExtendedComparator getComparator(Type type1,
                                        Type type2)
Returns an comparator for the given types.
Specified by:
getComparator in interface TypeRegistry
Parameters:
type1 -
type2 -
Returns:

getDefaultNumberFormat

protected NumberFormat getDefaultNumberFormat()

guessTypeOfObject

public Type guessTypeOfObject(Object o)
Specified by:
guessTypeOfObject in interface TypeRegistry

initialize

public void initialize(Configuration configuration,
                       FormulaContext formulaContext)

loadNumberFormats

protected NumberFormat[] loadNumberFormats()