org.mmbase.datatypes
Class BasicDataType<C>

java.lang.Object
  extended by org.mmbase.core.AbstractDescriptor
      extended by org.mmbase.datatypes.BasicDataType<C>
All Implemented Interfaces:
Serializable, Cloneable, Comparable<DataType<C>>, Descriptor, DataType<C>, PublicCloneable<AbstractDescriptor>
Direct Known Subclasses:
AbstractLengthDataType, BooleanDataType, ComparableDataType, NodeDataType

public class BasicDataType<C>
extends AbstractDescriptor
implements DataType<C>, Comparable<DataType<C>>, Descriptor

Every DataType extends this one. It's extensions can however implement several extensions of the DataType interface (e.g. some datatypes (at least StringDataType) are both LengthDataType and ComparableDataType, and some are only one (BinaryDataType, NumberDataType). In other words, this arrangement is like this, because java does not support Multipible inheritance.

Since:
MMBase-1.8
Version:
$Id: BasicDataType.java 41943 2010-04-16 17:18:19Z michiel $
Author:
Pierre van Rooden, Michiel Meeuwissen
See Also:
Serialized Form

Nested Class Summary
protected  class BasicDataType.AbstractRestriction<D extends Serializable>
          Abstract inner class Restriction.
protected static class BasicDataType.DataTypeComparator<D>
           
protected  class BasicDataType.EnumerationRestriction
           
protected  class BasicDataType.RequiredRestriction
           
protected  class BasicDataType.RestrictedEnumerationIterator
          Iterates over the collection provided by the EnumerationRestriction, but skips the values which are invalid because of the other restrictions on this DataType.
protected static class BasicDataType.StaticAbstractRestriction<D extends Serializable>
          A Restriction is represented by these kind of objects.
protected  class BasicDataType.TypeRestriction
           
protected  class BasicDataType.UniqueRestriction
           
 
Nested classes/interfaces inherited from interface org.mmbase.datatypes.DataType
DataType.Restriction<D extends Serializable>
 
Field Summary
static String DATATYPE_BUNDLE
          The bundle used by datatype to determine default prompts for error messages when a validation fails.
protected  Object defaultValue
           
protected  BasicDataType.EnumerationRestriction enumerationRestriction
           
protected  BasicDataType<?> origin
          The datatype from which this datatype originally inherited it's properties.
protected  BasicDataType.RequiredRestriction requiredRestriction
           
protected  BasicDataType.TypeRestriction typeRestriction
           
protected  BasicDataType.UniqueRestriction 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
  BasicDataType(String name)
          Create a data type object of unspecified class type
protected BasicDataType(String name, Class<C> classType)
          Create a data type object
 
Method Summary
protected  Element addErrorDescription(Element el, DataType.Restriction<?> r)
           
protected  Element addRestriction(Element parent, String name, String path, DataType.Restriction<?> restriction)
           
protected  Element addRestriction(Element parent, String pattern, String name, String path, DataType.Restriction<?> restriction)
           
 void addStyleClass(String styleClass)
           
protected  C cast(Object value, Cloud cloud, Node node, Field field)
          Utility to avoid repetitive calling of getCloud
 C cast(Object value, Node node, Field field)
          Tries to 'cast' an object for use with this parameter.
 Collection<LocalizedString> castAndValidate(Object value, Node node, Field field)
          Validates a value without knowing its type yet.
 Object castForSearch(Object value, Node node, Field field)
          Sometimes the the representation of the value is a bit different in the database, or has a different type.
 C castOrException(Object value, Node node, Field field)
          Tries to 'cast' an object for use with this parameter.
protected  String castToPresent(Object value, Node node, Field field)
          If the value must be shown, e.g.
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 checkType(Object value)
          Checks if the passed object is of the correct class (compatible with the type of this data type), and throws an IllegalArgumentException if it doesn't.
 BasicDataType<C> clone()
          Returns a cloned instance of this datatype, inheriting all validation rules.
 BasicDataType<C> clone(String name)
          Returns a cloned instance of this datatype, inheriting all validation rules.
protected  void cloneRestrictions(BasicDataType<C> origin)
          If a datatype is cloned, the restrictions of it (normally implemented as inner classes), must be reinstantiated.
 int compareTo(DataType<C> a)
           
protected  void edit()
           
 boolean equals(Object o)
          Whether data type equals to other data type.
 void finish()
           
 void finish(Object owner)
          Lock a dataType so it can be changed or altered.
 int getBaseType()
          Return the datatype's basic (MMBase) type (i.e., STRING, INTEGER, DATETIME) as definied in the Field interface Note that in some cases (i.e.
 String getBaseTypeIdentifier()
          Return an identifier for the basic type (i.e., 'string', 'int', 'datetime') supported by this datatype.
protected  Cloud getCloud(Cloud cloud)
          Returns a cloud object if argument is null.
protected  Cloud getCloud(Node node, Field field)
           
 CommitProcessor getCommitProcessor()
          Return the Commit processor of this datatype
 Comparator<C> getComparator()
           
 Processor getDefaultProcessor()
           
 C getDefaultValue()
          Returns the default value of this data type.
 C getDefaultValue(Locale locale, Cloud cloud, Field field)
          Returns the (locale dependent) default value of this data type,
 CommitProcessor getDeleteProcessor()
          Return the Delete processor of this datatype
protected  Element getElement(Element parent, String name, String path)
           
protected  Element getElement(Element parent, String pattern, String name, String path)
           
 int getEnforceStrength()
          The maximum enforce strength of all restrictions on this datatype.
protected  String getEnforceString(int enforce)
           
 LocalizedEntryListFactory<C> getEnumerationFactory()
          
 DataType.Restriction<LocalizedEntryListFactory<C>> getEnumerationRestriction()
          The enumeration for this datatype as a DataType.Restriction.
 String getEnumerationValue(Locale locale, Cloud cloud, Node node, Field field, Object key)
          Returns a (gui) value from a list of restricted enumerated values, or null if no enumeration restrictions apply or the value cannot be found.
 Iterator<Map.Entry<C,String>> getEnumerationValues(Locale locale, Cloud cloud, Node node, Field field)
          Returns an iterator over all possible values for this datatype, as Map.Entrys, or null if no enumeration restrictions apply.
 Handler<?> getHandler(String mimeType)
          Returns a handler for given mimetype for this DataType.
 Map<String,Handler<?>> getHandlers()
           
 BasicDataType<?> getOrigin()
          Return the DataType from which this one inherited, or null
 Processor getProcessor(int action)
          Returns the default processor for this action
 Processor getProcessor(int action, int processingType)
          Returns the processor for this action and processing type
 Processor getProcessorWithoutDefault(int action, int processingType)
           
 DataType.Restriction<Boolean> getRequiredRestriction()
          Returns the 'required' restriction, containing the value, error messages, and fixed status of this attribute.
 Collection<DataType.Restriction<?>> getRestrictions()
           
 String[] getStyleClasses()
           
 Class<C> getTypeAsClass()
          Returns the type of values that this data type accepts.
 DataType.Restriction<Boolean> getUniqueRestriction()
          Returns the 'unique' restriction, containing the value, error messages, and fixed status of this attribute.
 int hashCode()
           
 void inherit(BasicDataType<C> origin)
          Calls both inheritProperties(org.mmbase.datatypes.BasicDataType) and inheritRestrictions(org.mmbase.datatypes.BasicDataType).
protected  void inheritProperties(BasicDataType<C> origin)
          Properties are members of the datatype that can easily be copied/clones.
protected  void inheritRestrictions(BasicDataType<C> origin)
          If a datatype inherits from another datatype all its restrictions inherit too.
protected  boolean isCorrectType(Object value)
          Checks if the passed object is of the correct class (compatible with the type of this DataType), and throws an IllegalArgumentException if it doesn't.
 boolean isFinished()
          Is datatype locked
 boolean isRequired()
          Returns whether this field is required (may not be null, or otherwise empty).
 boolean isUnique()
          Returns whether this field has a unique restriction.
protected
<D> D
preCast(D value, Cloud cloud, Node node, Field field)
          This method implements 'precasting', which can be seen as a kind of datatype specific casting.
<D> D
preCast(D value, Node node, Field field)
          Before actually 'cast' an object to the right type, it may undergo some conversion by the datatype, e.g.
 Object preCast(Object value, Cloud cloud)
          This method is as yet unused, but can be anticipated
 DataType<C> rewrite(Object owner)
          Unlock a DataType so it can be changed or altered.
 void setCommitProcessor(CommitProcessor cp)
          Set the Commit processor of this datatype
 void setDefaultProcessor(Processor dp)
           
 void setDefaultValue(Object def)
          Set the default value for this DataType
 void setDeleteProcessor(CommitProcessor cp)
           
 void setProcessor(int action, Processor processor)
          Sets the processor for this action
 void setProcessor(int action, Processor processor, int processingType)
          Sets the processor for this action
 void setRequired(boolean required)
          Sets whether the data type requires a value, which means that it may not remain unfilled.
 void setUnique(boolean unique)
          Sets whether the data type requires a value.
 void setXml(Element element)
           
 String toString()
           
protected  StringBuilder toStringBuilder()
           
 Element toXml()
          Returns a DOM element describing this DataType.
 void toXml(Element parent)
          Fills this datatype in another XML (for example in the xml of DataType.getOrigin(), to make one XML, fully describing the DataType).
 Collection<LocalizedString> validate(C value)
          
 Collection<LocalizedString> validate(C value, Node node, Field field)
          Checks if the passed object obeys the restrictions defined for this type.
protected  Collection<LocalizedString> validateCastValue(Collection<LocalizedString> errors, Object castValue, Object value, Node node, Field field)
           
protected  Collection<LocalizedString> validateCastValueOrNull(Collection<LocalizedString> errors, Object castValue, Object value, Node node, Field field)
           
protected  Collection<LocalizedString> validateRequired(Collection<LocalizedString> errors, Object castValue, Object value, Node node, Field field)
           
protected  void xmlValue(Element el, Object value)
           
 
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

DATATYPE_BUNDLE

public static final String DATATYPE_BUNDLE
The bundle used by datatype to determine default prompts for error messages when a validation fails.

See Also:
Constant Field Values

requiredRestriction

protected BasicDataType.RequiredRestriction requiredRestriction

uniqueRestriction

protected BasicDataType.UniqueRestriction uniqueRestriction

typeRestriction

protected BasicDataType.TypeRestriction typeRestriction

enumerationRestriction

protected BasicDataType.EnumerationRestriction enumerationRestriction

origin

protected BasicDataType<?> origin
The datatype from which this datatype originally inherited it's properties.


defaultValue

protected Object defaultValue
Constructor Detail

BasicDataType

public BasicDataType(String name)
Create a data type object of unspecified class type

Parameters:
name - the name of the data types

BasicDataType

protected BasicDataType(String name,
                        Class<C> classType)
Create a data type object

Parameters:
name - the name of the data type
classType - the class of the data type's possible value
Method Detail

getBaseTypeIdentifier

public String getBaseTypeIdentifier()
Description copied from interface: DataType
Return an identifier for the basic type (i.e., 'string', 'int', 'datetime') supported by this datatype.

Specified by:
getBaseTypeIdentifier in interface DataType<C>
Returns:
identifier for the basic type

getBaseType

public int getBaseType()
Description copied from interface: DataType
Return the datatype's basic (MMBase) type (i.e., STRING, INTEGER, DATETIME) as definied in the Field interface Note that in some cases (i.e. with older clouds) this may differ from the basic type of the datatype's field, which defines in what format the data is stored.

Specified by:
getBaseType in interface DataType<C>
Returns:
identifier of the basic type
See Also:
Field.getType()

inherit

public final void inherit(BasicDataType<C> origin)
Calls both inheritProperties(org.mmbase.datatypes.BasicDataType) and inheritRestrictions(org.mmbase.datatypes.BasicDataType).

Parameters:
origin - inherit properties and restrictions from this DataType

inheritProperties

protected void inheritProperties(BasicDataType<C> origin)
Properties are members of the datatype that can easily be copied/clones.


cloneRestrictions

protected void cloneRestrictions(BasicDataType<C> origin)
If a datatype is cloned, the restrictions of it (normally implemented as inner classes), must be reinstantiated.


inheritRestrictions

protected void inheritRestrictions(BasicDataType<C> origin)
If a datatype inherits from another datatype all its restrictions inherit too.


getOrigin

public BasicDataType<?> getOrigin()
Return the DataType from which this one inherited, or null

Specified by:
getOrigin in interface DataType<C>
Returns:
inherited DataType

getTypeAsClass

public Class<C> getTypeAsClass()
Returns the type of values that this data type accepts.

Specified by:
getTypeAsClass in interface DataType<C>
Returns:
the type as a Class

isCorrectType

protected boolean isCorrectType(Object value)
Checks if the passed object is of the correct class (compatible with the type of this DataType), and throws an IllegalArgumentException if it doesn't.

Parameters:
value - teh value whose type (class) to check
Throws:
IllegalArgumentException - if the type is not compatible

checkType

public void checkType(Object value)
Checks if the passed object is of the correct class (compatible with the type of this data type), and throws an IllegalArgumentException if it doesn't.

Specified by:
checkType in interface DataType<C>
Parameters:
value - the value whose type (class) to check

preCast

public final <D> D preCast(D value,
                           Node node,
                           Field field)
Before actually 'cast' an object to the right type, it may undergo some conversion by the datatype, e.g. enumerations may get resolved (enumerations have the feature that they can e.g. resolve java-constants to their values). This does not guarantee that the value has the 'proper' type, but only that it now can be cast to the right type without further problems. (Casting.toType(Class, Object) should do). preCast should not change the actual type of value. It is e.g. used in the Node#setStringValue, and the processor may expect a String there. Tries to determin cloud by node and field if possible and wraps preCast(Object, Cloud, Node, Field).

Specified by:
preCast in interface DataType<C>
Parameters:
value - The value to be filled in a value with this DataType.
node - Sometimes a node might be needed.
field - Sometimes a (or 'the') field might be needed.
Returns:
converted value to be able to cast to the DataType of the field

preCast

public final Object preCast(Object value,
                            Cloud cloud)
This method is as yet unused, but can be anticipated


preCast

protected <D> D preCast(D value,
                        Cloud cloud,
                        Node node,
                        Field field)
This method implements 'precasting', which can be seen as a kind of datatype specific casting. It should anticipate that every argument can be null. It should not change the actual type of the value.


cast

public final C cast(Object value,
                    Node node,
                    Field field)
Tries to 'cast' an object for use with this parameter. E.g. if value is a String, but this parameter is of type Integer, then the string can be parsed to Integer. No need to override this. It is garantueed by javadoc that cast should work out of preCast using Casting.toType. So that is what this final implementation is doing. Override cast(Object, Cloud, Node, Field)

Specified by:
cast in interface DataType<C>
Parameters:
value - The value to be filled in a value with this DataType.
node - Sometimes a node might be needed.
field - Sometimes a (or 'the') field might be needed.
Returns:
casted object of Class of this DataType

castOrException

public final C castOrException(Object value,
                               Node node,
                               Field field)
                        throws CastException
Description copied from interface: DataType
Tries to 'cast' an object for use with this parameter. E.g. if value is a String, but this parameter is of type Integer, then the string can be parsed to Integer. This method may thow CastException if such casting is not feasible. E.g. most strings cannot be reasonably casted to numbers. The method DataType.cast(java.lang.Object, org.mmbase.bridge.Node, org.mmbase.bridge.Field) will return -1. This one will trow exception.

Specified by:
castOrException in interface DataType<C>
Parameters:
value - The value to be filled in a value with this DataType.
node - Sometimes a node might be needed.
field - Sometimes a (or 'the') field might be needed.
Returns:
casted object of Class of this DataType
Throws:
CastException
Since:
MMBase-2.0

cast

protected C cast(Object value,
                 Cloud cloud,
                 Node node,
                 Field field)
          throws CastException
Utility to avoid repetitive calling of getCloud

Throws:
CastException

getCloud

protected final Cloud getCloud(Node node,
                               Field field)

getCloud

protected Cloud getCloud(Cloud cloud)
Returns a cloud object if argument is null. Otherwise the argument.

Since:
MMBase-1.8.6

castToValidate

protected Object castToValidate(Object value,
                                Node node,
                                Field field)
                         throws CastException
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.

Throws:
CastException

castToPresent

protected String castToPresent(Object value,
                               Node node,
                               Field field)
If the value must be shown, e.g. in error message, it passed through this method.

Since:
MMBase-1.9.1

getDefaultValue

public final C getDefaultValue()
Returns the default value of this data type.

Specified by:
getDefaultValue in interface DataType<C>
Returns:
the default value

getDefaultValue

public C getDefaultValue(Locale locale,
                         Cloud cloud,
                         Field field)
Returns the (locale dependent) default value of this data type,

Specified by:
getDefaultValue in interface DataType<C>

setDefaultValue

public void setDefaultValue(Object def)
Set the default value for this DataType

Specified by:
setDefaultValue in interface DataType<C>
Parameters:
def - default value

getElement

protected Element getElement(Element parent,
                             String name,
                             String path)

getElement

protected Element getElement(Element parent,
                             String pattern,
                             String name,
                             String path)

getEnforceString

protected String getEnforceString(int enforce)

addRestriction

protected Element addRestriction(Element parent,
                                 String name,
                                 String path,
                                 DataType.Restriction<?> restriction)

addRestriction

protected Element addRestriction(Element parent,
                                 String pattern,
                                 String name,
                                 String path,
                                 DataType.Restriction<?> restriction)

addErrorDescription

protected Element addErrorDescription(Element el,
                                      DataType.Restriction<?> r)

isFinished

public boolean isFinished()
Description copied from interface: DataType
Is datatype locked

Specified by:
isFinished in interface DataType<C>
Returns:
true when datatype is locked

finish

public void finish()
See Also:
finish()

finish

public void finish(Object owner)
Lock a dataType so it can be changed or altered.

Specified by:
finish in interface DataType<C>
Parameters:
owner - the object to finish datatypes with

rewrite

public DataType<C> rewrite(Object owner)
Unlock a DataType so it can be changed or altered.

Specified by:
rewrite in interface DataType<C>
Parameters:
owner - the object to finish datatypes with
Returns:
unlocked DataType

edit

protected void edit()
Javadoc:

validate

public final Collection<LocalizedString> validate(C value)

Specified by:
validate in interface DataType<C>
Parameters:
value - the value to be validated
Returns:
The error message(s) if the value is not compatible. An empty collection if valid.
See Also:
DataType.validate(Object, Node, Field)

validate

public final Collection<LocalizedString> validate(C value,
                                                  Node node,
                                                  Field field)
Description copied from interface: DataType
Checks if the passed object obeys the restrictions defined for this type.

Specified by:
validate in interface DataType<C>
Parameters:
value - the value to validate
node - the node for which the datatype is checked. If not null, and the datatype is determined as unique, than uniquness is checked for this value using the passed field.
field - the field for which the datatype is checked.
Returns:
The error message(s) if the value is not compatible. An empty collection (DataType.VALID)if the value is valid.

castAndValidate

public final Collection<LocalizedString> castAndValidate(Object value,
                                                         Node node,
                                                         Field field)
Description copied from interface: DataType
Validates a value without knowing its type yet.

Specified by:
castAndValidate in interface DataType<C>

getEnforceStrength

public int getEnforceStrength()
Description copied from interface: DataType
The maximum enforce strength of all restrictions on this datatype. See DataType.ENFORCE_ALWAYS, DataType.ENFORCE_ONCHANGE, DataType.ENFORCE_NEVER.

Specified by:
getEnforceStrength in interface DataType<C>
Returns:
maximum enforce strength

validateCastValue

protected Collection<LocalizedString> validateCastValue(Collection<LocalizedString> errors,
                                                        Object castValue,
                                                        Object value,
                                                        Node node,
                                                        Field field)

validateCastValueOrNull

protected Collection<LocalizedString> validateCastValueOrNull(Collection<LocalizedString> errors,
                                                              Object castValue,
                                                              Object value,
                                                              Node node,
                                                              Field field)
Since:
MMBase-1.8.4

validateRequired

protected Collection<LocalizedString> validateRequired(Collection<LocalizedString> errors,
                                                       Object castValue,
                                                       Object value,
                                                       Node node,
                                                       Field field)
Since:
MMBase-1.9.1

castForSearch

public Object castForSearch(Object value,
                            Node node,
                            Field field)
Description copied from interface: DataType
Sometimes the the representation of the value is a bit different in the database, or has a different type. So when constraining a search on the value, casting is done by this. This may default to DataType.cast(Object, Node, Field).

Specified by:
castForSearch in interface DataType<C>
Since:
MMBase-1.9.1

toStringBuilder

protected StringBuilder toStringBuilder()

toString

public final String toString()
Overrides:
toString in class AbstractDescriptor

clone

public final BasicDataType<C> clone()
Returns a cloned instance of this datatype, inheriting all validation rules. Unlike the original datatype though, the cloned copy is declared unfinished even if the original was finished. This means that the cloned datatype can be changed. This method is final, override clone(String) in stead.

Specified by:
clone in interface DataType<C>
Specified by:
clone in interface PublicCloneable<AbstractDescriptor>
Overrides:
clone in class AbstractDescriptor
Returns:
cloned instance

clone

public BasicDataType<C> clone(String name)
Returns a cloned instance of this datatype, inheriting all validation rules. Similar to calling clone(), but changes the data type name if one is provided. Besides super.clone, it calls inheritProperties(BasicDataType) and cloneRestrictions(BasicDataType). A clone is not finished. See isFinished().

Specified by:
clone in interface DataType<C>
Overrides:
clone in class AbstractDescriptor
Parameters:
name - the new name of the copied datatype (can be null, in which case the name is not changed).
Returns:
cloned DataType

toXml

public Element toXml()
Description copied from interface: DataType
Returns a DOM element describing this DataType.

Specified by:
toXml in interface DataType<C>
Returns:
a DOM element describing this DataType.

setXml

public void setXml(Element element)

xmlValue

protected void xmlValue(Element el,
                        Object value)

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<C>
Parameters:
parent - a 'datatype' element.

getHandler

public Handler<?> getHandler(String mimeType)
Description copied from interface: DataType
Returns a handler for given mimetype for this DataType. The handler can be used to produce UI for values of this datatype.

Specified by:
getHandler in interface DataType<C>

getHandlers

public Map<String,Handler<?>> getHandlers()
Specified by:
getHandlers in interface DataType<C>

getRestrictions

public Collection<DataType.Restriction<?>> getRestrictions()

compareTo

public int compareTo(DataType<C> a)
Specified by:
compareTo in interface Comparable<DataType<C>>

equals

public boolean equals(Object o)
Whether data type equals to other data type. Only key and type are consided. DefaultValue and required properties are only 'utilities'.

Overrides:
equals in class Object
Returns:
true if o is a DataType of which key and type equal to this' key and type.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isRequired

public boolean isRequired()
Returns whether this field is required (may not be null, or otherwise empty).

Specified by:
isRequired in interface DataType<C>
Returns:
true if the field is required

getRequiredRestriction

public DataType.Restriction<Boolean> getRequiredRestriction()
Returns the 'required' restriction, containing the value, error messages, and fixed status of this attribute.

Specified by:
getRequiredRestriction in interface DataType<C>
Returns:
the restriction as a DataType.Restriction

setRequired

public void setRequired(boolean required)
Sets whether the data type requires a value, which means that it may not remain unfilled.

Specified by:
setRequired in interface DataType<C>
Parameters:
required - true if a value is required

isUnique

public boolean isUnique()
Returns whether this field has a unique restriction. Uniqueness is generally achieved through association of the datatype with one or more sets of fields. This is notably different from other datatype properties. Note that the MMBase core does not generally enforce uniqueness, but the storage layer might.

Specified by:
isUnique in interface DataType<C>
Returns:
true if the field is unique

getUniqueRestriction

public DataType.Restriction<Boolean> getUniqueRestriction()
Returns the 'unique' restriction, containing the value, error messages, and fixed status of this attribute.

Specified by:
getUniqueRestriction in interface DataType<C>
Returns:
the restriction as a DataType.Restriction

setUnique

public void setUnique(boolean unique)
Sets whether the data type requires a value.

Specified by:
setUnique in interface DataType<C>
Parameters:
unique - true if a value is unique

getEnumerationValue

public String getEnumerationValue(Locale locale,
                                  Cloud cloud,
                                  Node node,
                                  Field field,
                                  Object key)
Returns a (gui) value from a list of restricted enumerated values, or null if no enumeration restrictions apply or the value cannot be found.

Specified by:
getEnumerationValue in interface DataType<C>
Parameters:
locale - for which to produce
cloud - Possibly the possible values depend on a cloud (security)
node - Possibly the possible values depend on an actual node (this may be, and in the default implementation is, ignored)
field - Possibly the possible values depend on an actual field (this may be, and in the default implementation is, ignored)
key - the key for which to look up the (gui) value
Returns:
a (gui) value from a list of restricted enumerated values

getEnumerationValues

public Iterator<Map.Entry<C,String>> getEnumerationValues(Locale locale,
                                                          Cloud cloud,
                                                          Node node,
                                                          Field field)
Returns an iterator over all possible values for this datatype, as Map.Entrys, or null if no enumeration restrictions apply. Every Map entry contains as key the 'value' for this datatype and as value it contains the description for this value in the given locale. This Iterator skips all entries which are impossible because of other restrictions on this datatype.

Specified by:
getEnumerationValues in interface DataType<C>
Parameters:
locale - for which to produce
cloud - Possibly the possible values depend on a cloud (security)
node - Possibly the possible values depend on an actual node (this may be, and in the default implementation is, ignored)
field - Possibly the possible values depend on an actual field (this may be, and in the default implementation is, ignored)
Returns:
iterator over all possible values for this datatype

getEnumerationFactory

public LocalizedEntryListFactory<C> getEnumerationFactory()

Specified by:
getEnumerationFactory in interface DataType<C>
Returns:
the LocalizedEntryListFactory which will be used to produce the result of DataType.getEnumerationValues(java.util.Locale, org.mmbase.bridge.Cloud, org.mmbase.bridge.Node, org.mmbase.bridge.Field). Never null. This can be used to add more possible values.

getEnumerationRestriction

public DataType.Restriction<LocalizedEntryListFactory<C>> getEnumerationRestriction()
The enumeration for this datatype as a DataType.Restriction.

Specified by:
getEnumerationRestriction in interface DataType<C>
Returns:
enumeration for this datatype

getDefaultProcessor

public Processor getDefaultProcessor()

setDefaultProcessor

public void setDefaultProcessor(Processor dp)

getCommitProcessor

public CommitProcessor getCommitProcessor()
Description copied from interface: DataType
Return the Commit processor of this datatype

Specified by:
getCommitProcessor in interface DataType<C>
Returns:
Commit processor

setCommitProcessor

public void setCommitProcessor(CommitProcessor cp)
Description copied from interface: DataType
Set the Commit processor of this datatype

Specified by:
setCommitProcessor in interface DataType<C>
Parameters:
cp - Commit processor

getDeleteProcessor

public CommitProcessor getDeleteProcessor()
Description copied from interface: DataType
Return the Delete processor of this datatype

Specified by:
getDeleteProcessor in interface DataType<C>
Returns:
A commitprocessor that will be called if the Node is deleted.

setDeleteProcessor

public void setDeleteProcessor(CommitProcessor cp)

getProcessor

public Processor getProcessor(int action)
Returns the default processor for this action

Specified by:
getProcessor in interface DataType<C>
Parameters:
action - either DataType.PROCESS_GET, or DataType.PROCESS_SET XXX What exactly would be against getGetProcesor(), getSetProcessor() ?
Returns:
the default processor for this action

getProcessor

public Processor getProcessor(int action,
                              int processingType)
Returns the processor for this action and processing type

Specified by:
getProcessor in interface DataType<C>
Parameters:
action - either DataType.PROCESS_GET, or DataType.PROCESS_SET
processingType - the MMBase type defining the type of value to process
Returns:
the processor for this action and processing type

getProcessorWithoutDefault

public Processor getProcessorWithoutDefault(int action,
                                            int processingType)

setProcessor

public void setProcessor(int action,
                         Processor processor)
Sets the processor for this action

Specified by:
setProcessor in interface DataType<C>
Parameters:
action - either DataType.PROCESS_GET, or DataType.PROCESS_SET
processor - the processor for this action

setProcessor

public void setProcessor(int action,
                         Processor processor,
                         int processingType)
Sets the processor for this action

Specified by:
setProcessor in interface DataType<C>
Parameters:
action - either DataType.PROCESS_GET, or DataType.PROCESS_SET
processor - the processor for this action and processing type
processingType - the MMBase type defining the type of value to process

getStyleClasses

public String[] getStyleClasses()
Specified by:
getStyleClasses in interface DataType<C>

addStyleClass

public void addStyleClass(String styleClass)

getComparator

public Comparator<C> getComparator()
Since:
MMBase-1.9.2


MMBase 2.0-SNAPSHOT - null