01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.datatypes;
11:
12: /**
13: * DataType associated with {@link java.lang.Double}, as NumberDataType, but provides getMin and getMax as double.
14: *
15: * @author Pierre van Rooden
16: * @author Michiel Meeuwissen
17: * @version $Id: DoubleDataType.java,v 1.9 2007/08/28 10:05:04 michiel Exp $
18: * @since MMBase-1.8
19: */
20:
21: public class DoubleDataType extends NumberDataType<Double> {
22:
23: private static final long serialVersionUID = 1L; // increase this if object serialization changes (which we shouldn't do!)
24:
25: /**
26: * @param primitive indicate if a primitive type should be used
27: */
28: public DoubleDataType(String name, boolean primitive) {
29: super (name, primitive ? Double.TYPE : Double.class);
30: setMin(Double.valueOf(-1 * Double.MAX_VALUE), true);
31: setMax(Double.valueOf(Double.MAX_VALUE), true);
32: }
33:
34: /**
35: * @return the minimum value as a <code>double</code>, or {@link Double#NEGATIVE_INFINITY} if there is no minimum.
36: */
37: public double getMin() {
38: Number min = getMinRestriction().getValue();
39: return min == null ? Double.NEGATIVE_INFINITY : min
40: .doubleValue();
41: }
42:
43: /**
44: * @return the maximum value as a <code>double</code>, or {@link Double#POSITIVE_INFINITY} if there is no maximum.
45: */
46: public double getMax() {
47: Number max = getMaxRestriction().getValue();
48: return max == null ? Double.POSITIVE_INFINITY : max
49: .doubleValue();
50: }
51:
52: }
|