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: import org.mmbase.util.Casting;
13:
14: /**
15: * * DataType associated with {@link java.lang.Long}, NumberDataType, but provides getMin and getMax as long.
16: *
17: * @author Pierre van Rooden
18: * @author Michiel Meeuwissen
19: * @version $Id: LongDataType.java,v 1.10 2006/12/15 13:38:01 michiel Exp $
20: * @since MMBase-1.8
21: */
22: public class LongDataType extends NumberDataType<Long> {
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 LongDataType(String name, boolean primitive) {
29: super (name, primitive ? Long.TYPE : Long.class);
30: setMin(Long.valueOf(Long.MIN_VALUE), true);
31: minRestriction.setEnforceStrength(ENFORCE_ABSOLUTE);
32: setMax(Long.valueOf(Long.MAX_VALUE), true);
33: maxRestriction.setEnforceStrength(ENFORCE_ABSOLUTE);
34: }
35:
36: /**
37: * @return the minimum value as an <code>long</code>, or {@link Long#MIN_VALUE} if there is no minimum.
38: */
39: public long getMin() {
40: Long min = getMinRestriction().getValue();
41: return min == null ? Long.MIN_VALUE : Casting.toLong(min); // casting, mainly to anticipate dates
42: }
43:
44: /**
45: * @return the maximum value as an <code>long</code>, or {@link Long#MAX_VALUE} if there is no maximum.
46: */
47: public long getMax() {
48: Long max = getMaxRestriction().getValue();
49: return max == null ? Long.MAX_VALUE : Casting.toLong(max); // casting, mainly to anticipate dates
50: }
51:
52: }
|