|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.core.AbstractDescriptor
org.mmbase.datatypes.BasicDataType<E>
org.mmbase.datatypes.ComparableDataType<E>
org.mmbase.datatypes.NumberDataType<BigDecimal>
org.mmbase.datatypes.DecimalDataType
public class DecimalDataType
DataType associated with 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.
| Nested Class Summary | |
|---|---|
class |
DecimalDataType.PrecisionRestriction
|
class |
DecimalDataType.ScaleRestriction
|
| Nested classes/interfaces inherited from class org.mmbase.datatypes.ComparableDataType |
|---|
ComparableDataType.MaxRestriction, ComparableDataType.MinRestriction |
| Nested classes/interfaces inherited from class org.mmbase.datatypes.BasicDataType |
|---|
BasicDataType.AbstractRestriction<D extends Serializable>, BasicDataType.DataTypeComparator<D>, BasicDataType.EnumerationRestriction, BasicDataType.RequiredRestriction, BasicDataType.RestrictedEnumerationIterator, BasicDataType.StaticAbstractRestriction<D extends Serializable>, BasicDataType.TypeRestriction, BasicDataType.UniqueRestriction |
| Nested classes/interfaces inherited from interface org.mmbase.datatypes.DataType |
|---|
DataType.Restriction<D extends Serializable> |
| Field Summary | |
|---|---|
protected AbstractLengthDataType.MinRestriction |
decimalMinRestriction
|
protected DecimalDataType.PrecisionRestriction |
precisionRestriction
|
protected DecimalDataType.ScaleRestriction |
scaleRestriction
|
| Fields inherited from class org.mmbase.datatypes.NumberDataType |
|---|
allowSpecialNumbers |
| Fields inherited from class org.mmbase.datatypes.ComparableDataType |
|---|
maxRestriction, minRestriction |
| Fields inherited from class org.mmbase.datatypes.BasicDataType |
|---|
DATATYPE_BUNDLE, defaultValue, enumerationRestriction, origin, requiredRestriction, typeRestriction, uniqueRestriction |
| Fields inherited from class org.mmbase.core.AbstractDescriptor |
|---|
description, guiName, key |
| Fields inherited from interface org.mmbase.datatypes.DataType |
|---|
ENFORCE_ABSOLUTE, ENFORCE_ALWAYS, ENFORCE_NEVER, ENFORCE_ONCHANGE, ENFORCE_ONCREATE, ENFORCE_ONVALIDATE, PROCESS_GET, PROCESS_SET, VALID, XMLNS |
| Constructor Summary | |
|---|---|
DecimalDataType(String name)
|
|
| Method Summary | |
|---|---|
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. |
BigDecimal |
first()
Returns a natural 'first' value. |
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)
|
| Methods inherited from class org.mmbase.datatypes.NumberDataType |
|---|
cast, castToValidate, setAllowSpecialNumbers |
| Methods inherited from class org.mmbase.datatypes.ComparableDataType |
|---|
clone, compare, getComparator, getDefaultValue, getEnforceStrength, getMaxRestriction, getMinRestriction, isMaxInclusive, isMinInclusive, setMax, setMin, toStringBuilder, toXml |
| Methods inherited from class org.mmbase.core.AbstractDescriptor |
|---|
getDefaultLocale, getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUIName |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.mmbase.datatypes.DataType |
|---|
cast, castAndValidate, castForSearch, castOrException, 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, validate |
| Methods inherited from interface org.mmbase.bridge.Descriptor |
|---|
getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Field Detail |
|---|
protected DecimalDataType.PrecisionRestriction precisionRestriction
protected AbstractLengthDataType.MinRestriction decimalMinRestriction
protected DecimalDataType.ScaleRestriction scaleRestriction
| Constructor Detail |
|---|
public DecimalDataType(String name)
| Method Detail |
|---|
public long getLength(Object o)
LengthDataType
getLength in interface LengthDataType<BigDecimal>public long getMinLength()
LengthDataType
getMinLength in interface LengthDataType<BigDecimal>int, or 0 if there is no minimum length.public DataType.Restriction<Long> getMinLengthRestriction()
LengthDataType
getMinLengthRestriction in interface LengthDataType<BigDecimal>DataType.Restrictionpublic void setMinLength(long value)
LengthDataType
setMinLength in interface LengthDataType<BigDecimal>value - the minimum length as an long, or 0 if there is no minimum length.public long getMaxLength()
LengthDataType
getMaxLength 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()
LengthDataType
getMaxLengthRestriction in interface LengthDataType<BigDecimal>DataType.Restrictionpublic void setMaxLength(long value)
LengthDataType
setMaxLength in interface LengthDataType<BigDecimal>value - see LengthDataType.getMaxLength()
protected Number toNumber(String s)
throws CastException
toNumber in class NumberDataType<BigDecimal>CastException
protected 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)
BasicDataType
inheritRestrictions in class ComparableDataType<BigDecimal>protected void cloneRestrictions(BasicDataType origin)
BasicDataType
cloneRestrictions in class ComparableDataType<BigDecimal>
protected Collection<LocalizedString> validateCastValue(Collection<LocalizedString> errors,
Object castValue,
Object value,
Node node,
Field field)
validateCastValue in class ComparableDataType<BigDecimal>public BigDecimal first()
ComparableDataType0
first in class ComparableDataType<BigDecimal>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||