package edu.stanford.rt.datatype; // Not yet implemented /** IntegerType defines the integer type. The name for this type is "IntegerType". It has the following attributes: min, max, base, and step. */ public class DecimalType extends SimpleType { private long min; private long max; private boolean minIncluded = true; private boolean maxIncluded = true; private long base; private long step; /** */ public DecimalType (String n, long mi, boolean mii, long ma, boolean mai, long b, long s) throws IllegalArgumentException { super(n); // Check to make sure that at least one value is legal if (mi > ma) { throw new IllegalArgumentException("IntegerType: min > max"); } if(b < mi || b > ma) { throw new IllegalArgumentException( "IntegerType: base in not within min and max"); } if (s <= 0) { throw new IllegalArgumentException("IntegerType: step <= 0"); } long x = (mi - rem) % s; if (x>0 && (mi + s-x)>ma) { throw new IllegalArgumentException( "IntegerType: First legal value is out of bound."); } min = mi; max = ma; minIncluded = mii; maxIncluded = mai; base = b; step = s; } public long getMin() { return min; } public long getMax() { return max; } public boolean isMinIncluded() { return minIncluded; } public boolean isMaxIncluded() { return maxIncluded; } public long getBase() { return base; } public long getStep() { return step; } public boolean isValidValue(DataValue v) { if (!(v instanceof DecimalValue)) { return false; } double l = ((DecimalValue)v).getValue(); if (l >= min && l<= max && ((l-remainder) % step == 0)) { return true; } return false; } }