public class DecimalDataType extends NumberDataType<BigDecimal> implements LengthDataType<BigDecimal>
BigDecimal, a NumberDataType. Decimals are naturally
restricted on BigDecimal.precision() and BigDecimal.scale().
The precision of a decimal can be identified with its length, because it is simply the
number of stored digits. Therefore this class does, in contradication to other
NumberDataTypes implement LengthDataType. getPrecision() and getMaxLength() are synonymous though.
The precision and scale properties correspond with the xsd-tags xsd:precision and xsd:scale,
indicating maximal values for those concepts. They can be set with dt:precision
(dt:maxLength should work too) and dt:scale elements in datatypes-XML's.
The rounding mode is used, and must be relaxed (since it is default RoundingMode.UNNECESSARY), if the scale restriction is not enforced. In this case the values can
be rounded before validation and storage, but we need to know how precisely this must happen.| Modifier and Type | Class and Description |
|---|---|
class |
DecimalDataType.PrecisionRestriction |
class |
DecimalDataType.ScaleRestriction |
ComparableDataType.MaxRestriction, ComparableDataType.MinRestrictionBasicDataType.AbstractRestriction<D extends Serializable>, BasicDataType.DataTypeComparator<D>, BasicDataType.EnumerationRestriction, BasicDataType.RequiredRestriction, BasicDataType.RestrictedEnumerationIterator, BasicDataType.StaticAbstractRestriction<D extends Serializable>, BasicDataType.TypeRestriction, BasicDataType.UniqueRestrictionDataType.Restriction<D extends Serializable>| Modifier and Type | Field and Description |
|---|---|
protected AbstractLengthDataType.MinRestriction |
decimalMinRestriction |
protected DecimalDataType.PrecisionRestriction |
precisionRestriction |
protected DecimalDataType.ScaleRestriction |
scaleRestriction |
allowSpecialNumbersmaxRestriction, minRestrictionDATATYPE_BUNDLE, defaultValue, enumerationRestriction, origin, requiredRestriction, typeRestriction, uniqueRestrictiondescription, guiName, keyENFORCE_ABSOLUTE, ENFORCE_ALWAYS, ENFORCE_NEVER, ENFORCE_ONCHANGE, ENFORCE_ONCREATE, ENFORCE_ONVALIDATE, PROCESS_GET, PROCESS_SET, VALID, XMLNS| Constructor and Description |
|---|
DecimalDataType(String name) |
| Modifier and Type | Method and Description |
|---|---|
protected BigDecimal |
castString(Object preCast,
Cloud cloud) |
protected void |
cloneRestrictions(BasicDataType origin)
If a datatype is cloned, the restrictions of it (normally implemented as inner classes), must be reinstantiated.
|
long |
getLength(Object o)
In this method should be implemented how to calculate such a length for a certain value of
this datatype.
|
long |
getMaxLength()
Returns the maximum length of values for this datatype.
|
DataType.Restriction<Long> |
getMaxLengthRestriction()
Returns the 'maxLength' restriction, containing the value, errormessages, and fixed status of this attribute.
|
long |
getMinLength()
Returns the minimum length of values for this datatype.
|
DataType.Restriction<Long> |
getMinLengthRestriction()
Returns the 'minLength' restriction, containing the value, errormessages, and fixed status of this attribute.
|
int |
getPrecision()
The maximal value for
BigDecimal.precision(). |
DecimalDataType.PrecisionRestriction |
getPrecisionRestriction() |
RoundingMode |
getRoundingMode() |
int |
getScale()
The maximal value for
BigDecimal.scale(). |
DecimalDataType.ScaleRestriction |
getScaleRestriction() |
protected void |
inheritRestrictions(BasicDataType origin)
If a datatype inherits from another datatype all its restrictions inherit too.
|
void |
setMaxLength(long value)
Sets the maximum length of values for this datatype.
|
void |
setMinLength(long value)
Sets the minimum length of binary values for this datatype.
|
void |
setPrecision(int p) |
void |
setRoundingMode(String mode) |
protected Number |
toNumber(String s) |
protected Collection<LocalizedString> |
validateCastValue(Collection<LocalizedString> errors,
Object castValue,
Object value,
Node node,
Field field) |
cast, castToValidate, setAllowSpecialNumbersclone, compare, getComparator, getDefaultValue, getEnforceStrength, getMaxRestriction, getMinRestriction, isMaxInclusive, isMinInclusive, setMax, setMin, toStringBuilder, toXmladdErrorDescription, addRestriction, addRestriction, addStyleClass, cast, castAndValidate, castForSearch, castToPresent, checkType, clone, compareTo, edit, equals, finish, finish, getBaseType, getBaseTypeIdentifier, getCloud, getCloud, getCommitProcessor, getDefaultProcessor, getDefaultValue, getDeleteProcessor, getElement, getElement, getEnforceString, getEnumerationFactory, getEnumerationRestriction, getEnumerationValue, getEnumerationValues, getHandler, getHandlers, getOrigin, getProcessor, getProcessor, getProcessorWithoutDefault, getRequiredRestriction, getRestrictions, getStyleClasses, getTypeAsClass, getUniqueRestriction, hashCode, inherit, inheritProperties, isCorrectType, isFinished, isRequired, isUnique, preCast, preCast, preCast, rewrite, setCommitProcessor, setDefaultProcessor, setDefaultValue, setDeleteProcessor, setProcessor, setProcessor, setRequired, setUnique, setXml, toString, toXml, validate, validate, validateCastValueOrNull, validateRequired, xmlValuegetDefaultLocale, getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUINamefinalize, getClass, notify, notifyAll, wait, wait, waitcast, castAndValidate, castForSearch, checkType, clone, clone, finish, getBaseType, getBaseTypeIdentifier, getCommitProcessor, getDefaultValue, getDefaultValue, getDeleteProcessor, getEnforceStrength, getEnumerationFactory, getEnumerationRestriction, getEnumerationValue, getEnumerationValues, getHandler, getHandlers, getOrigin, getProcessor, getProcessor, getRequiredRestriction, getStyleClasses, getTypeAsClass, getUniqueRestriction, isFinished, isRequired, isUnique, preCast, rewrite, setCommitProcessor, setDefaultValue, setProcessor, setProcessor, setRequired, setUnique, toXml, toXml, validate, validategetDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUINamecompareToprotected DecimalDataType.PrecisionRestriction precisionRestriction
protected AbstractLengthDataType.MinRestriction decimalMinRestriction
protected DecimalDataType.ScaleRestriction scaleRestriction
public DecimalDataType(String name)
public long getLength(Object o)
LengthDataTypegetLength in interface LengthDataType<BigDecimal>public long getMinLength()
LengthDataTypegetMinLength in interface LengthDataType<BigDecimal>int, or 0 if there is no minimum length.public DataType.Restriction<Long> getMinLengthRestriction()
LengthDataTypegetMinLengthRestriction in interface LengthDataType<BigDecimal>DataType.Restrictionpublic void setMinLength(long value)
LengthDataTypesetMinLength in interface LengthDataType<BigDecimal>value - the minimum length as an long, or 0 if there is no minimum length.public long getMaxLength()
LengthDataTypegetMaxLength in interface LengthDataType<BigDecimal>long, or a very very big value
(Long.MAX_VALUE) if there is no maximum length.public DataType.Restriction<Long> getMaxLengthRestriction()
LengthDataTypegetMaxLengthRestriction in interface LengthDataType<BigDecimal>DataType.Restrictionpublic void setMaxLength(long value)
LengthDataTypesetMaxLength in interface LengthDataType<BigDecimal>value - see LengthDataType.getMaxLength()protected Number toNumber(String s) throws CastException
toNumber in class NumberDataType<BigDecimal>CastExceptionprotected BigDecimal castString(Object preCast, Cloud cloud) throws CastException
castString in class NumberDataType<BigDecimal>CastExceptionpublic RoundingMode getRoundingMode()
public void setRoundingMode(String mode)
public void setPrecision(int p)
getPrecision()public int getPrecision()
BigDecimal.precision().public int getScale()
BigDecimal.scale().public DecimalDataType.PrecisionRestriction getPrecisionRestriction()
public DecimalDataType.ScaleRestriction getScaleRestriction()
protected void inheritRestrictions(BasicDataType origin)
BasicDataTypeinheritRestrictions in class ComparableDataType<BigDecimal>protected void cloneRestrictions(BasicDataType origin)
BasicDataTypecloneRestrictions in class ComparableDataType<BigDecimal>protected Collection<LocalizedString> validateCastValue(Collection<LocalizedString> errors, Object castValue, Object value, Node node, Field field)
validateCastValue in class ComparableDataType<BigDecimal>MMBase 1.9-SNAPSHOT - ${javadoctimestamp}