org.mmbase.datatypes
Class NumberDataType<E extends Number & Comparable<E>>

java.lang.Object
  extended by org.mmbase.core.AbstractDescriptor
      extended by org.mmbase.datatypes.BasicDataType<E>
          extended by org.mmbase.datatypes.ComparableDataType<E>
              extended by org.mmbase.datatypes.NumberDataType<E>
All Implemented Interfaces:
Serializable, Cloneable, Comparable<DataType<E>>, Descriptor, DataType<E>, PublicCloneable<AbstractDescriptor>
Direct Known Subclasses:
DecimalDataType, DoubleDataType, FloatDataType, IntegerDataType, LongDataType

public abstract class NumberDataType<E extends Number & Comparable<E>>
extends ComparableDataType<E>

A DataType representing some kind of numeric value, like a floating point number or an integer number.

Since:
MMBase-1.8
Version:
$Id: NumberDataType.java 40244 2009-12-14 15:28:46Z michiel $
Author:
Pierre van Rooden
See Also:
Serialized Form

Nested Class Summary
 
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
(package private)  boolean 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
NumberDataType(String name, Class<E> classType)
          Constructor for Number field.
 
Method Summary
protected  E cast(Object value, Cloud cloud, Node node, Field field)
          Utility to avoid repetitive calling of getCloud
protected  Number castString(Object preCast, Cloud cloud)
           
protected  Object castToValidate(Object value, Node node, Field field)
          Before validating the value, the value will be 'cast', on default this will be to the 'correct' type, but it can be a more generic type sometimes.
 void setAllowSpecialNumbers(boolean sn)
           
protected  Number toNumber(String s)
           
 
Methods inherited from class org.mmbase.datatypes.ComparableDataType
clone, cloneRestrictions, compare, first, getComparator, getDefaultValue, getEnforceStrength, getMaxRestriction, getMinRestriction, inheritRestrictions, isMaxInclusive, isMinInclusive, setMax, setMin, toStringBuilder, toXml, validateCastValue
 
Methods inherited from class org.mmbase.datatypes.BasicDataType
addErrorDescription, addRestriction, addRestriction, addStyleClass, cast, castAndValidate, castForSearch, castOrException, 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, xmlValue
 
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.bridge.Descriptor
getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName
 

Field Detail

allowSpecialNumbers

boolean allowSpecialNumbers
Constructor Detail

NumberDataType

public NumberDataType(String name,
                      Class<E> classType)
Constructor for Number field.

Method Detail

setAllowSpecialNumbers

public void setAllowSpecialNumbers(boolean sn)
Since:
MMBase-1.9.2

toNumber

protected Number toNumber(String s)
                   throws CastException
Throws:
CastException
Since:
MMBase-1.9.2

castString

protected Number castString(Object preCast,
                            Cloud cloud)
                     throws CastException
Throws:
CastException

castToValidate

protected Object castToValidate(Object value,
                                Node node,
                                Field field)
                         throws CastException
Description copied from class: BasicDataType
Before validating the value, the value will be 'cast', on default this will be to the 'correct' type, but it can be a more generic type sometimes. E.g. for numbers this wil simply cast to Number.

Overrides:
castToValidate in class BasicDataType<E extends Number & Comparable<E>>
Throws:
CastException
Since:
MMBase-1.9

cast

protected E cast(Object value,
                 Cloud cloud,
                 Node node,
                 Field field)
                                        throws CastException
Description copied from class: BasicDataType
Utility to avoid repetitive calling of getCloud

Overrides:
cast in class BasicDataType<E extends Number & Comparable<E>>
Throws:
CastException


MMBase 2.0-SNAPSHOT - null