KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.mmbase.util.Casting;
12
13 /**
14  * * DataType associated with {@link java.lang.Long}, NumberDataType, but provides getMin and getMax as long.
15  *
16  * @author Pierre van Rooden
17  * @author Michiel Meeuwissen
18  * @version $Id: LongDataType.java,v 1.9 2006/04/29 19:41:09 michiel Exp $
19  * @since MMBase-1.8
20  */

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

26     public LongDataType(String JavaDoc name, boolean primitive) {
27         super(name, primitive ? Long.TYPE : Long JavaDoc.class);
28         setMin(new Long JavaDoc(Long.MIN_VALUE), true);
29         minRestriction.setEnforceStrength(ENFORCE_ABSOLUTE);
30         setMax(new Long JavaDoc(Long.MAX_VALUE), true);
31         maxRestriction.setEnforceStrength(ENFORCE_ABSOLUTE);
32     }
33
34
35     /**
36      * @return the minimum value as an <code>long</code>, or {@link Long#MIN_VALUE} if there is no minimum.
37      */

38     public long getMin() {
39         Object JavaDoc min = getMinRestriction().getValue();
40         return min == null ? Long.MIN_VALUE : Casting.toLong(min); // casting, mainly to anticipate dates
41
}
42
43     /**
44      * @return the maximum value as an <code>long</code>, or {@link Long#MAX_VALUE} if there is no maximum.
45      */

46     public long getMax() {
47         Object JavaDoc max = getMaxRestriction().getValue();
48         return max == null ? Long.MAX_VALUE : Casting.toLong(max); // casting, mainly to anticipate dates
49
}
50
51 }
52
Popular Tags