|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
A value in MMBase (such as the value of a field, or function parameter) is associated with a
'datatype'. A DataType is actually an elaborated wrapper arround a Class object, but besides
this basic type of the value, it also defines restrictions on the values, a default value,
Processors, and perhaps other properties (e.g. properties which describe indications for edit
tool implementations).
There are several extensions of DataType which normally add other kinds of restrictions which are
specific for certain classes of values. All implementations of DataType extend from BasicDataType, but they can sometimes implement different extensions of DataType at the same time
('multiple inheritance').
| Nested Class Summary | |
static interface |
DataType.Restriction
A restriction controls (one aspect of) the acceptable values of a DataType. |
| Field Summary | |
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 |
PROCESS_GET
|
static int |
PROCESS_SET
|
static Collection |
VALID
Returned by validate(java.lang.Object) if no errors: an empty (nonmodifiable) Collection. |
static String |
XMLNS
The XML Namespace to be used for creating datatype XML |
| Method Summary | |
Object |
cast(Object value,
Node node,
Field field)
Tries to 'cast' an object for use with this parameter. |
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()
Returns a cloned instance of this datatype, inheriting all validation rules. |
Object |
clone(String name)
Returns a cloned instance of this datatype, inheriting all validation rules. |
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. |
CommitProcessor |
getCommitProcessor()
|
Object |
getDefaultValue()
Returns the default value of this data type. |
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. |
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. |
void |
inherit(BasicDataType origin)
Inherit properties and processors from the passed datatype. |
boolean |
isFinished()
|
boolean |
isRequired()
Returns whether this field is required (should have content). |
boolean |
isUnique()
Returns whether this field has a unique restriction. |
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. |
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. |
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 |
validate(Object value)
|
Collection |
validate(Object value,
Node node,
Field field)
Checks if the passed object obeys the restrictions defined for this type. |
| Methods inherited from interface org.mmbase.bridge.Descriptor |
getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName |
| Methods inherited from interface java.lang.Comparable |
compareTo |
| Field Detail |
public static final String XMLNS
public static final int PROCESS_GET
public static final int PROCESS_SET
public static final int ENFORCE_ABSOLUTE
DataType.Restriction.getEnforceStrength(). This means that the value
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'.
public static final int ENFORCE_ALWAYS
DataType.Restriction.getEnforceStrength(). This means that the value must be enforced always.
public static final int ENFORCE_ONCHANGE
DataType.Restriction.getEnforceStrength(). This means that the value must be enforced only if it was changed.
public static final int ENFORCE_ONCREATE
DataType.Restriction.getEnforceStrength(). This means that the value must be enforced only on creation.
public static final int ENFORCE_NEVER
DataType.Restriction.getEnforceStrength(). This means that the
value must be enforced never, so the restriction serves only as UI indication.
public static final Collection VALID
validate(java.lang.Object) if no errors: an empty (nonmodifiable) Collection.
| Method Detail |
public void inherit(BasicDataType origin)
public DataType getOrigin()
null
public String getBaseTypeIdentifier()
public int getBaseType()
Field.#getTypepublic Class getTypeAsClass()
public void checkType(Object value)
value - the value whose type (class) to check
IllegalArgumentException - if the type is not compatible
public Object 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.
public 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.
public Object getDefaultValue()
public void setDefaultValue(Object def)
public DataType rewrite(Object owner)
public boolean isFinished()
public void finish(Object owner)
public Collection validate(Object value)
value - the value to be validated
validate(Object, Node, Field)
public Collection validate(Object 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.
public boolean isRequired()
true if the field is requiredpublic DataType.Restriction getRequiredRestriction()
DataType.Restrictionpublic void setRequired(boolean required)
required - true if a value is required
InvalidStateException - if the datatype was finished (and thus can no longer be changed)public boolean isUnique()
true if the field is uniquepublic DataType.Restriction getUniqueRestriction()
DataType.Restrictionpublic void setUnique(boolean unique)
unique - true if a value is unique
InvalidStateException - if the datatype was finished (and thus can no longer be changed)
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.
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)
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.
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) valuepublic LocalizedEntryListFactory 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.public DataType.Restriction getEnumerationRestriction()
DataType.Restriction.
public CommitProcessor getCommitProcessor()
public void setCommitProcessor(CommitProcessor cp)
public Processor getProcessor(int action)
action - either PROCESS_GET, or PROCESS_SET
XXX What exactly would be against getGetProcesor(), getSetProcessor() ?
public Processor getProcessor(int action,
int processingType)
action - either PROCESS_GET, or PROCESS_SETprocessingType - the MMBase type defining the type of value to process
public void setProcessor(int action,
Processor processor)
action - either PROCESS_GET, or PROCESS_SET
public void setProcessor(int action,
Processor processor,
int processingType)
action - either PROCESS_GET, or PROCESS_SETprocessingType - the MMBase type defining the type of value to processpublic Object clone()
public Object clone(String name)
name - the new name of the copied datatype (can be null, in which case the name is not changed).public Element toXml()
public void toXml(Element element)
getOrigin(), to make one XML, fully describing the DataType).
The implementation of this method is unfinished!
element - a 'datatype' element.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||