C - Class this DataTypepublic interface DataType<C> extends Descriptor, Comparable<DataType<C>>, Serializable
BasicDataType, but they can sometimes implement different extensions of DataType at the same time
('multiple inheritance').| Modifier and Type | Interface and Description |
|---|---|
static interface |
DataType.Restriction<D extends Serializable>
A restriction controls (one aspect of) the acceptable values of a DataType.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
ENFORCE_ABSOLUTE
Return value for
DataType.Restriction.getEnforceStrength(). |
static int |
ENFORCE_ALWAYS
Return value for
DataType.Restriction.getEnforceStrength(). |
static int |
ENFORCE_NEVER
Return value for
DataType.Restriction.getEnforceStrength(). |
static int |
ENFORCE_ONCHANGE
Return value for
DataType.Restriction.getEnforceStrength(). |
static int |
ENFORCE_ONCREATE
Return value for
DataType.Restriction.getEnforceStrength(). |
static int |
ENFORCE_ONVALIDATE
Return value for
DataType.Restriction.getEnforceStrength(). |
static int |
PROCESS_GET |
static int |
PROCESS_SET |
static Collection<LocalizedString> |
VALID
Returned by
validate(Object, Node, Field) if no errors: an empty (nonmodifiable)
Collection containing no error messages. |
static String |
XMLNS
The XML Namespace to be used for creating datatype XML
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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.
|
DataType<C> |
clone()
Returns a cloned instance of this datatype, inheriting all validation rules.
|
DataType<C> |
clone(String name)
Returns a cloned instance of this datatype, inheriting all validation rules.
|
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.
|
CommitProcessor |
getCommitProcessor()
Return the Commit processor of this datatype
|
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
|
int |
getEnforceStrength()
The maximum enforce strength of all restrictions on this datatype.
|
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() |
DataType<?> |
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
|
DataType.Restriction<Boolean> |
getRequiredRestriction()
Returns the 'required' restriction, containing the value, error messages, and fixed status of this attribute.
|
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.
|
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.
|
<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.
|
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 |
setDefaultValue(Object def)
Set the default value for this DataType
|
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.
|
Element |
toXml()
Returns a DOM element describing this DataType.
|
void |
toXml(Element element)
Fills this datatype in another XML (for example in the xml of
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.
|
getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUINamecompareTostatic final String XMLNS
static final int PROCESS_GET
static final int PROCESS_SET
static final int ENFORCE_ABSOLUTE
DataType.Restriction.getEnforceStrength(). This means that the value
restriction must be enforced always, and furthermore, that extensions (based on clone) cannot
loosen it. For example, the absolute maximum for any datatype backed by a integer is
Integer.MAX_VALUE, there is no way you can even store a bigger value in this, so this
restriction is 'absolute'.static final int ENFORCE_ALWAYS
DataType.Restriction.getEnforceStrength(). This means that a
restriction on a value must be enforced always.static final int ENFORCE_ONCHANGE
DataType.Restriction.getEnforceStrength(). This means that a
restriction on a value must be enforced only if it was changed.static final int ENFORCE_ONCREATE
DataType.Restriction.getEnforceStrength(). This means that ta
restriction on a value must be enforced only on creation.static final int ENFORCE_ONVALIDATE
DataType.Restriction.getEnforceStrength(). This means that the
restriction on a value must be enforced only on validation of the value. This means that it
has no influence of the validity of the node.static final int ENFORCE_NEVER
DataType.Restriction.getEnforceStrength(). This means that the
restriction on a value must be enforced never, so the restriction serves only as UI indication.static final Collection<LocalizedString> VALID
validate(Object, Node, Field) if no errors: an empty (nonmodifiable)
Collection containing no error messages.DataType<?> getOrigin()
nullString getBaseTypeIdentifier()
int getBaseType()
Field.getType()Class<C> getTypeAsClass()
void checkType(Object value)
value - the value whose type (class) to checkIllegalArgumentException - if the type is not compatibleC cast(Object value, Node node, Field field)
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.<D> D preCast(D value,
Node node,
Field field)
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.D - 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.Object castForSearch(Object value, Node node, Field field)
cast(Object, Node, Field).C getDefaultValue()
C getDefaultValue(Locale locale, Cloud cloud, Field field)
void setDefaultValue(Object def)
def - default valueDataType<C> rewrite(Object owner)
owner - the object to finish datatypes withboolean isFinished()
true when datatype is lockedvoid finish(Object owner)
owner - the object to finish datatypes withint getEnforceStrength()
ENFORCE_ALWAYS, ENFORCE_ONCHANGE, ENFORCE_NEVER.Collection<LocalizedString> validate(C value)
value - the value to be validatedvalidate(Object, Node, Field)Collection<LocalizedString> validate(C value, Node node, Field field)
value - the value to validatenode - 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.VALID)if the value is valid.Collection<LocalizedString> castAndValidate(Object value, Node node, Field field)
boolean isRequired()
null, or otherwise empty).true if the field is requiredDataType.Restriction<Boolean> getRequiredRestriction()
DataType.Restrictionvoid setRequired(boolean required)
required - true if a value is requiredIllegalStateException - if the datatype was finished (and thus can no longer be changed)boolean isUnique()
true if the field is uniqueDataType.Restriction<Boolean> getUniqueRestriction()
DataType.Restrictionvoid setUnique(boolean unique)
unique - true if a value is uniqueIllegalStateException - if the datatype was finished (and thus can no longer be changed)Iterator<Map.Entry<C,String>> getEnumerationValues(Locale locale, Cloud cloud, Node node, Field field)
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.locale - for which to producecloud - 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)String getEnumerationValue(Locale locale, Cloud cloud, Node node, Field field, Object key)
null if no enumeration restrictions apply or the value cannot be found.locale - for which to producecloud - 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) valueLocalizedEntryListFactory<C> getEnumerationFactory()
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.DataType.Restriction<LocalizedEntryListFactory<C>> getEnumerationRestriction()
DataType.Restriction.CommitProcessor getCommitProcessor()
void setCommitProcessor(CommitProcessor cp)
cp - Commit processorCommitProcessor getDeleteProcessor()
Processor getProcessor(int action)
action - either PROCESS_GET, or PROCESS_SET
XXX What exactly would be against getGetProcesor(), getSetProcessor() ?Processor getProcessor(int action, int processingType)
action - either PROCESS_GET, or PROCESS_SETprocessingType - the MMBase type defining the type of value to processvoid setProcessor(int action,
Processor processor)
action - either PROCESS_GET, or PROCESS_SETprocessor - the processor for this actionvoid setProcessor(int action,
Processor processor,
int processingType)
action - either PROCESS_GET, or PROCESS_SETprocessor - the processor for this action and processing typeprocessingType - the MMBase type defining the type of value to processDataType<C> clone()
DataType<C> clone(String name)
name - the new name of the copied datatype (can be null, in which case the name is not changed).Element toXml()
void toXml(Element element)
getOrigin(), to make one
XML, fully describing the DataType). The implementation of this method is
unfinished!element - a 'datatype' element.Handler<?> getHandler(String mimeType)
String[] getStyleClasses()
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}