KickJava   Java API By Example, From Geeks To Geeks.

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


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.Float}, as NumberDataType, but provides getMin and getMax as float.
14  *
15  * @author Pierre van Rooden
16  * @version $Id: FloatDataType.java,v 1.8 2006/04/29 19:41:09 michiel Exp $
17  * @since MMBase-1.8
18  */

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

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

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

43     public float getMax() {
44         Number JavaDoc max = (Number JavaDoc) getMaxRestriction().getValue();
45         return max == null ? Float.POSITIVE_INFINITY : max.floatValue();
46     }
47 }
48
Popular Tags