org.mmbase.datatypes
Class ComparableDataType

java.lang.Object
  extended byorg.mmbase.core.AbstractDescriptor
      extended byorg.mmbase.datatypes.BasicDataType
          extended byorg.mmbase.datatypes.ComparableDataType
All Implemented Interfaces:
Cloneable, Comparable, DataType, Descriptor, Serializable
Direct Known Subclasses:
DateTimeDataType, NumberDataType, StringDataType

public abstract class ComparableDataType
extends BasicDataType

Comparable datatypes have values which are Comparable, so can be ordered, and therefore can have a minimum and a maximum value.

Since:
MMBase-1.8
Version:
$Id: ComparableDataType.java,v 1.18 2006/06/19 15:56:23 pierre Exp $
Author:
Michiel Meeuwissen
See Also:
Serialized Form

Nested Class Summary
protected  class ComparableDataType.MaxRestriction
           
protected  class ComparableDataType.MinRestriction
           
 
Nested classes inherited from class org.mmbase.datatypes.BasicDataType
BasicDataType.AbstractRestriction, BasicDataType.EnumerationRestriction, BasicDataType.RequiredRestriction, BasicDataType.RestrictedEnumerationIterator, BasicDataType.StaticAbstractRestriction, BasicDataType.TypeRestriction, BasicDataType.UniqueRestriction
 
Nested classes inherited from class org.mmbase.datatypes.DataType
DataType.Restriction
 
Field Summary
protected  ComparableDataType.MaxRestriction maxRestriction
           
protected  ComparableDataType.MinRestriction minRestriction
           
 
Fields inherited from class org.mmbase.datatypes.BasicDataType
DATATYPE_BUNDLE, 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, PROCESS_GET, PROCESS_SET, VALID, XMLNS
 
Constructor Summary
protected ComparableDataType(String name, Class classType)
           
 
Method Summary
 Object clone(String name)
           Besides super.clone, it calls BasicDataType.inheritProperties(BasicDataType) and BasicDataType.cloneRestrictions(BasicDataType). A clone is not finished. See BasicDataType.isFinished(). Besides super.clone, it calls BasicDataType.inheritProperties(BasicDataType) and cloneRestrictions(BasicDataType).
protected  void cloneRestrictions(BasicDataType origin)
          If a datatype is cloned, the restrictions of it (normally implemented as inner classes), must be reinstantiated.
 Object getDefaultValue()
          Returns the default value of this data type.
 DataType.Restriction getMaxRestriction()
           
 DataType.Restriction getMinRestriction()
           
protected  void inheritRestrictions(BasicDataType origin)
          If a datatype inherits from another datatype all its restrictions inherit too.
 boolean isMaxInclusive()
          Returns whether the maximum value for this data type is inclusive or not.
 boolean isMinInclusive()
          Returns whether the minimum value for this data type is inclusive or not.
 void setMax(Comparable value, boolean inclusive)
          Sets the maximum Date value for this data type.
 void setMin(Comparable value, boolean inclusive)
          Sets the minimum Date value for this data type.
protected  StringBuffer toStringBuffer()
           
 void toXml(Element parent)
          Fills this datatype in another XML (for example in the xml of BasicDataType.getOrigin(), to make one XML, fully describing the DataType).
protected  Collection validateCastedValue(Collection errors, Object castedValue, Object value, Node node, Field field)
           
 
Methods inherited from class org.mmbase.datatypes.BasicDataType
cast, cast, castToValidate, checkType, clone, compareTo, edit, equals, finish, finish, getBaseType, getBaseTypeIdentifier, getCloud, getCommitProcessor, getElement, getElement, getEnumerationFactory, getEnumerationRestriction, getEnumerationValue, getEnumerationValues, getOrigin, getProcessor, getProcessor, getRequiredRestriction, getTypeAsClass, getUniqueRestriction, hashCode, inherit, inheritProperties, isCorrectType, isFinished, isRequired, isUnique, preCast, preCast, preCast, rewrite, setCommitProcessor, setDefaultValue, setProcessor, setProcessor, setRequired, setUnique, setXml, toString, toXml, validate, validate
 
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

minRestriction

protected ComparableDataType.MinRestriction minRestriction

maxRestriction

protected ComparableDataType.MaxRestriction maxRestriction
Constructor Detail

ComparableDataType

protected ComparableDataType(String name,
                             Class classType)
Method Detail

inheritRestrictions

protected void inheritRestrictions(BasicDataType origin)
Description copied from class: BasicDataType
If a datatype inherits from another datatype all its restrictions inherit too.

Overrides:
inheritRestrictions in class BasicDataType

cloneRestrictions

protected void cloneRestrictions(BasicDataType origin)
Description copied from class: BasicDataType
If a datatype is cloned, the restrictions of it (normally implemented as inner classes), must be reinstantiated.

Overrides:
cloneRestrictions in class BasicDataType

getMinRestriction

public DataType.Restriction getMinRestriction()

isMinInclusive

public boolean isMinInclusive()
Returns whether the minimum value for this data type is inclusive or not.

Returns:
true if the minimum value if inclusive, false if it is not, or if there is no minimum.

getMaxRestriction

public DataType.Restriction getMaxRestriction()

isMaxInclusive

public boolean isMaxInclusive()
Returns whether the maximum value for this data type is inclusive or not.

Returns:
true if the maximum value if inclusive, false if it is not, or if there is no minimum.

getDefaultValue

public final Object getDefaultValue()
Description copied from class: BasicDataType
Returns the default value of this data type.

Specified by:
getDefaultValue in interface DataType
Overrides:
getDefaultValue in class BasicDataType

setMin

public void setMin(Comparable value,
                   boolean inclusive)
Sets the minimum Date value for this data type.

Parameters:
value - the minimum as an Comparable (and Serializable), or null if there is no minimum.
inclusive - whether the minimum value is inclusive or not
Throws:
Class - Identifier: java.lang.UnsupportedOperationException if this data type is read-only (i.e. defined by MMBase)

setMax

public void setMax(Comparable value,
                   boolean inclusive)
Sets the maximum Date value for this data type.

Parameters:
value - the maximum as an Comparable (and Serializable), or null if there is no maximum.
inclusive - whether the maximum value is inclusive or not
Throws:
Class - Identifier: java.lang.UnsupportedOperationException if this data type is read-only (i.e. defined by MMBase)

toXml

public void toXml(Element parent)
Description copied from interface: DataType
Fills this datatype in another XML (for example in the xml of DataType.getOrigin(), to make one XML, fully describing the DataType). The implementation of this method is unfinished!

Specified by:
toXml in interface DataType
Overrides:
toXml in class BasicDataType

validateCastedValue

protected Collection validateCastedValue(Collection errors,
                                         Object castedValue,
                                         Object value,
                                         Node node,
                                         Field field)
Overrides:
validateCastedValue in class BasicDataType

clone

public Object clone(String name)
Description copied from class: BasicDataType
Besides super.clone, it calls BasicDataType.inheritProperties(BasicDataType) and BasicDataType.cloneRestrictions(BasicDataType). A clone is not finished. See BasicDataType.isFinished().

Specified by:
clone in interface DataType
Overrides:
clone in class BasicDataType

toStringBuffer

protected StringBuffer toStringBuffer()
Overrides:
toStringBuffer in class BasicDataType


MMBase build 1.8.1.20060716