KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > datatypes > DoubleDataType


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

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.7 2006/04/29 19:41:09 michiel Exp $
18  * @since MMBase-1.8
19  */

20
21 public class DoubleDataType extends NumberDataType {
22
23     private static final long serialVersionUID = 1L; // increase this if object serialization changes (which we shouldn't do!)
24
/**
25      * @param primitive indicate if a primitive type should be used
26      */

27     public DoubleDataType(String JavaDoc name, boolean primitive) {
28         super(name, primitive ? Double.TYPE : Double JavaDoc.class);
29         setMin(new Double JavaDoc(Double.NEGATIVE_INFINITY), false);
30         setMax(new Double JavaDoc(Double.POSITIVE_INFINITY), false);
31     }
32
33     /**
34      * @return the minimum value as a <code>double</code>, or {@link Double#NEGATIVE_INFINITY} if there is no minimum.
35      */

36     public double getMin() {
37         Number JavaDoc min = (Number JavaDoc) getMinRestriction().getValue();
38         return min == null ? Double.NEGATIVE_INFINITY : min.doubleValue();
39     }
40
41     /**
42      * @return the maximum value as a <code>double</code>, or {@link Double#POSITIVE_INFINITY} if there is no maximum.
43      */

44     public double getMax() {
45         Number JavaDoc max = (Number JavaDoc) getMaxRestriction().getValue();
46         return max == null ? Double.POSITIVE_INFINITY : max.doubleValue();
47     }
48
49 }
50
Popular Tags