01: /*
02: * @(#)DoubleConverter.java 3/9/2005
03: *
04: * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
05: */
06: package com.jidesoft.converter;
07:
08: import java.text.NumberFormat;
09: import java.text.ParseException;
10:
11: /**
12: * Converter which converts Double to String and converts it back.
13: */
14: public class DoubleConverter extends NumberConverter {
15: public DoubleConverter() {
16: }
17:
18: public DoubleConverter(NumberFormat format) {
19: super (format);
20: }
21:
22: public Object fromString(String string, ConverterContext context) {
23: try {
24: return getNumberFormat().parse(string).doubleValue();
25: } catch (ParseException e) {
26: return null;
27: }
28: }
29:
30: public boolean supportFromString(String string,
31: ConverterContext context) {
32: return true;
33: }
34: }
|