01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.calyxo.forms.convert;
17:
18: import java.text.ParseException;
19:
20: /**
21: * Double converter.
22: *
23: * @author Christoph Beck
24: * @author Oliver Stuhr
25: */
26: public class DoubleConverter extends NumberConverter {
27:
28: /**
29: * Default constructor.
30: */
31: public DoubleConverter() {
32: super ();
33: }
34:
35: public Double getDefault() {
36: return (Double) getParsedNullOrEmpty();
37: }
38:
39: public void setDefault(Double value) {
40: setParsedNullOrEmpty(value);
41: }
42:
43: /**
44: * Format method.
45: */
46: public String format(Object value) {
47: return super .format((Double) value);
48: }
49:
50: /**
51: * Parse method.
52: */
53: public Object parse(String value) throws ParseException {
54: Number d = (Number) super .parse(value);
55: if (d == null || d instanceof Double)
56: return d;
57: return new Double(d.doubleValue());
58: }
59: }
|