public final Number parse(String text) throws TypeConversionException {
        if (text == null || "".equals(text)) {
            return null;
        }

        if (pattern == null) {
            
            try {
                return createNumber(text);
            }
            catch (NumberFormatException ex) {
                throw new TypeConversionException("Invalid " + getType().getSimpleName() +
                    " value '" + text + "'", ex);
            }
            
        }
        else {
            // create a DecimaFormat for parsing the number
            DecimalFormat df = format;
            if (df == null) {
                df = createDecimalFormat();
                df.setParseBigDecimal(true);
            }
            
            // parse the number using the DecimalFormat
            ParsePosition pp = new ParsePosition(0);
            Number number = df.parse(text, pp);
            if (pp.getErrorIndex() >= 0 || 
                pp.getIndex() != text.length() ||
                !(number instanceof BigDecimal))
            {
                throw new TypeConversionException("Number value '" + text + 
                    "' does not match pattern '" + pattern + "'");
            }
            
            try {
                // convert the BigDecimal to a number
                return createNumber((BigDecimal)number);
            }
            catch (ArithmeticException ex) {
                throw new TypeConversionException("Invalid " + getType().getSimpleName() + 
                    " value '" + text + "'");
            }
            
        }
    }