1 10 package org.mmbase.datatypes; 11 import org.mmbase.util.Casting; 12 13 20 public class IntegerDataType extends NumberDataType { 21 private static final long serialVersionUID = 1L; 23 26 public IntegerDataType(String name, boolean primitive) { 27 super(name, primitive ? Integer.TYPE : Integer .class); 28 setMin(new Integer (Integer.MIN_VALUE), true); 29 minRestriction.setEnforceStrength(ENFORCE_ABSOLUTE); 30 setMax(new Integer (Integer.MAX_VALUE), true); 31 maxRestriction.setEnforceStrength(ENFORCE_ABSOLUTE); 32 } 33 34 protected void inheritRestrictions(BasicDataType origin) { 35 super.inheritRestrictions(origin); 36 if (origin instanceof BooleanDataType) { 37 setMin(new Integer (0), true); 38 setMax(new Integer (1), true); 39 } 40 } 41 42 43 46 public int getMin() { 47 Object min = getMinRestriction().getValue(); 48 return min == null ? Integer.MIN_VALUE : Casting.toInt(min); 49 } 50 51 54 public int getMax() { 55 Object max = getMaxRestriction().getValue(); 56 return max == null ? Integer.MAX_VALUE : Casting.toInt(max); 57 } 58 59 } 60 | Popular Tags |