|
||||||||||
| 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
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.
| Nested Class Summary | |
protected class |
BasicDataType.AbstractRestriction
Abstract inner class Restriction. |
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
A Restriction is represented by these kind of objects. |
protected class |
BasicDataType.TypeRestriction
|
protected class |
BasicDataType.UniqueRestriction
|
| Nested classes inherited from class org.mmbase.datatypes.DataType |
DataType.Restriction |
| Field Summary | |
static String |
DATATYPE_BUNDLE
The bundle used by datatype to determine default prompts for error messages when a validation fails. |
protected BasicDataType.EnumerationRestriction |
enumerationRestriction
|
protected DataType |
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, 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 classType)
Create a data type object |
| Method Summary | |
protected Object |
cast(Object value,
Cloud cloud,
Node node,
Field field)
Utility to avoid repetitive calling of getCloud |
Object |
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. |
protected Object |
castToValidate(Object value,
Node node,
Field field)
Before validating the value, the value will be 'casted', 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. |
Object |
clone()
This method is final, override clone(String) in stead. |
Object |
clone(String name)
Besides super.clone, it calls 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. |
int |
compareTo(Object o)
|
protected void |
edit()
|
boolean |
equals(Object o)
Whether data type equals to other data type. |
void |
finish()
|
void |
finish(Object owner)
|
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(Node node,
Field field)
|
CommitProcessor |
getCommitProcessor()
|
Object |
getDefaultValue()
Returns the default value of this data type. |
protected Element |
getElement(Element parent,
String name,
String path)
|
protected Element |
getElement(Element parent,
String pattern,
String name,
String path)
|
LocalizedEntryListFactory |
getEnumerationFactory()
|
DataType.Restriction |
getEnumerationRestriction()
The enumeration for this datatype as a DataType.Restriction. |
Object |
getEnumerationValue(Locale locale,
Cloud cloud,
Node node,
Field field,
Object key)
Returns a (gui) value from a list of retsricted enumerated values, or null if no enumeration restrictions apply or teh value cannot be found. |
Iterator |
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. |
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 |
getRequiredRestriction()
Returns the 'required' restriction, containing the value, errormessages, and fixed status of this attribute. |
Class |
getTypeAsClass()
Returns the type of values that this data type accepts. |
DataType.Restriction |
getUniqueRestriction()
Returns the 'unique' restriction, containing the value, error messages, and fixed status of this attribute. |
int |
hashCode()
|
void |
inherit(BasicDataType origin)
Inherit properties and processors from the passed datatype. Calls both inheritProperties(org.mmbase.datatypes.BasicDataType) and inheritRestrictions(org.mmbase.datatypes.BasicDataType). |
protected void |
inheritProperties(BasicDataType origin)
Properties are members of the datatype that can easily be copied/clones. |
protected void |
inheritRestrictions(BasicDataType 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()
|
boolean |
isRequired()
Returns whether this field is required (should have content). Note that the MMBase core does not generally enforce required fields to be filled - If not provided, a default value (generally an empty string or the integer value -1) is filled in by the system. |
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. |
Object |
preCast(Object value,
Cloud cloud)
This method is as yet unused, but can be anticipated |
protected Object |
preCast(Object value,
Cloud cloud,
Node node,
Field field)
This method implements 'precasting', which can be seen as a kind of datatype specific casting. |
Object |
preCast(Object 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 garantuee that the value has the 'proper' type, but only that it now can be casted to the right type without further problems. ( Casting.toType(java.lang.Class, java.lang.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). |
DataType |
rewrite(Object owner)
|
void |
setCommitProcessor(CommitProcessor cp)
|
void |
setDefaultValue(Object def)
|
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 StringBuffer |
toStringBuffer()
|
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 getOrigin(), to make one XML, fully describing the DataType). |
Collection |
validate(Object value)
|
Collection |
validate(Object value,
Node node,
Field field)
Checks if the passed object obeys the restrictions defined for this type. |
protected Collection |
validateCastedValue(Collection errors,
Object castedValue,
Object value,
Node node,
Field field)
|
| 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 |
public static final String DATATYPE_BUNDLE
protected BasicDataType.RequiredRestriction requiredRestriction
protected BasicDataType.UniqueRestriction uniqueRestriction
protected BasicDataType.TypeRestriction typeRestriction
protected BasicDataType.EnumerationRestriction enumerationRestriction
protected DataType origin
| Constructor Detail |
public BasicDataType(String name)
name - the name of the data type
s
protected BasicDataType(String name,
Class classType)
name - the name of the data typeclassType - the class of the data type's possible value| Method Detail |
public String getBaseTypeIdentifier()
DataType
getBaseTypeIdentifier in interface DataTypepublic int getBaseType()
DataType
getBaseType in interface DataTypeField.#getTypepublic final void inherit(BasicDataType origin)
inheritProperties(org.mmbase.datatypes.BasicDataType) and inheritRestrictions(org.mmbase.datatypes.BasicDataType).
inherit in interface DataTypeprotected void inheritProperties(BasicDataType origin)
protected void cloneRestrictions(BasicDataType origin)
protected void inheritRestrictions(BasicDataType origin)
public DataType getOrigin()
null
getOrigin in interface DataTypepublic Class getTypeAsClass()
getTypeAsClass in interface DataTypeprotected boolean isCorrectType(Object value)
value - teh value whose type (class) to check
IllegalArgumentException - if the type is not compatiblepublic void checkType(Object value)
checkType in interface DataTypevalue - the value whose type (class) to check
public final Object preCast(Object value,
Node node,
Field field)
Casting.toType(java.lang.Class, java.lang.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).
preCast in interface DataType
public final Object preCast(Object value,
Cloud cloud)
protected Object preCast(Object value,
Cloud cloud,
Node node,
Field field)
null. It should not
change the actual type of the value.
public final Object cast(Object value,
Node node,
Field field)
preCast(Object, Cloud, Node, Field)
cast in interface DataTypevalue - 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.
protected Object cast(Object value,
Cloud cloud,
Node node,
Field field)
throws CastException
CastException
protected final Cloud getCloud(Node node,
Field field)
protected Object castToValidate(Object value,
Node node,
Field field)
throws CastException
CastExceptionpublic Object getDefaultValue()
getDefaultValue in interface DataTypepublic void setDefaultValue(Object def)
setDefaultValue in interface DataType
protected Element getElement(Element parent,
String name,
String path)
protected Element getElement(Element parent,
String pattern,
String name,
String path)
public void toXml(Element parent)
DataTypeDataType.getOrigin(), to make one XML, fully describing the DataType).
The implementation of this method is unfinished!
toXml in interface DataTypeparent - a 'datatype' element.public boolean isFinished()
isFinished in interface DataTypepublic void finish()
public void finish(Object owner)
finish in interface DataTypepublic DataType rewrite(Object owner)
rewrite in interface DataTypeprotected void edit()
public final Collection validate(Object value)
validate in interface DataTypevalue - the value to be validated
DataType.validate(Object, Node, Field)
public final Collection validate(Object value,
Node node,
Field field)
DataType
validate in interface DataTypevalue - 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.
protected Collection validateCastedValue(Collection errors,
Object castedValue,
Object value,
Node node,
Field field)
protected StringBuffer toStringBuffer()
public final String toString()
toString in class AbstractDescriptorpublic final Object clone()
clone(String) in stead.
clone in interface DataTypeclone in class AbstractDescriptorpublic Object clone(String name)
inheritProperties(BasicDataType) and cloneRestrictions(BasicDataType). A clone is not finished. See isFinished().
clone in interface DataTypeclone in class AbstractDescriptorpublic Element toXml()
DataType
toXml in interface DataTypepublic void setXml(Element element)
public int compareTo(Object o)
compareTo in interface Comparablepublic boolean equals(Object o)
public int hashCode()
public boolean isRequired()
isRequired in interface DataTypetrue if the field is requiredpublic DataType.Restriction getRequiredRestriction()
getRequiredRestriction in interface DataTypeDataType.Restrictionpublic void setRequired(boolean required)
setRequired in interface DataTyperequired - true if a value is requiredpublic boolean isUnique()
isUnique in interface DataTypetrue if the field is uniquepublic DataType.Restriction getUniqueRestriction()
getUniqueRestriction in interface DataTypeDataType.Restrictionpublic void setUnique(boolean unique)
setUnique in interface DataTypeunique - true if a value is unique
public Object getEnumerationValue(Locale locale,
Cloud cloud,
Node node,
Field field,
Object key)
null if no enumeration restrictions apply or teh value cannot be found.
getEnumerationValue in interface DataTypelocale - 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) value
public Iterator 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.
getEnumerationValues in interface DataTypelocale - 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)public LocalizedEntryListFactory getEnumerationFactory()
getEnumerationFactory in interface DataTypeDataType.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.public DataType.Restriction getEnumerationRestriction()
DataType.Restriction.
getEnumerationRestriction in interface DataTypepublic CommitProcessor getCommitProcessor()
getCommitProcessor in interface DataTypepublic void setCommitProcessor(CommitProcessor cp)
setCommitProcessor in interface DataTypepublic Processor getProcessor(int action)
getProcessor in interface DataTypeaction - either DataType.PROCESS_GET, or DataType.PROCESS_SET
XXX What exactly would be against getGetProcesor(), getSetProcessor() ?
public Processor getProcessor(int action,
int processingType)
getProcessor in interface DataTypeaction - either DataType.PROCESS_GET, or DataType.PROCESS_SETprocessingType - the MMBase type defining the type of value to process
public void setProcessor(int action,
Processor processor)
setProcessor in interface DataTypeaction - either DataType.PROCESS_GET, or DataType.PROCESS_SET
public void setProcessor(int action,
Processor processor,
int processingType)
setProcessor in interface DataTypeaction - either DataType.PROCESS_GET, or DataType.PROCESS_SETprocessingType - the MMBase type defining the type of value to process
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||