org.mmbase.datatypes
Interface DataType.Restriction<D extends Serializable>

Type Parameters:
D - Type of Value describing the restriction
All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractLengthDataType.MaxRestriction, AbstractLengthDataType.MinRestriction, BasicDataType.AbstractRestriction, BasicDataType.EnumerationRestriction, BasicDataType.RequiredRestriction, BasicDataType.StaticAbstractRestriction, BasicDataType.TypeRestriction, BasicDataType.UniqueRestriction, BinaryDataType.MimeTypeRestriction, CaptchaDataType.CaptchaRestriction, CheckEqualityDataType.FieldRestriction, ComparableDataType.MaxRestriction, ComparableDataType.MinRestriction, DecimalDataType.PrecisionRestriction, DecimalDataType.ScaleRestriction, InternetAddressDataType.InternetAddressRestriction, ListDataType.ItemRestriction, NodeDataType.MustExistRestriction, StringDataType.PatternRestriction
Enclosing interface:
DataType<C>

public static interface DataType.Restriction<D extends Serializable>
extends Serializable

A restriction controls (one aspect of) the acceptable values of a DataType. A DataType generally has several restrictions.


Method Summary
 int getEnforceStrength()
          See DataType.ENFORCE_ALWAYS, DataType.ENFORCE_ONCHANGE, DataType.ENFORCE_NEVER.
 LocalizedString getErrorDescription()
          If the restriction does not hold, the following error description can be used.
 String getName()
           
 D getValue()
          A Value describing the restriction, so depending on the semantics of this restriction, it can have virtually every type (as long as it is Serializable)
 void setEnforceStrength(int v)
          Set enforce strength
 void setErrorDescription(LocalizedString errorDescription)
          Set error description for this restriction
 void setFixed(boolean fixed)
          If a restriction is 'fixed', the value and error-description cannot be changed any more.
 void setValue(D value)
          Set the Value describing the restriction
 boolean valid(Object value, Node node, Field field)
          This function should contain the actual logic of the restriction.
 

Method Detail

getName

String getName()
Returns:
Name of datatype

getValue

D getValue()
A Value describing the restriction, so depending on the semantics of this restriction, it can have virtually every type (as long as it is Serializable)

Returns:
A Value describing the restriction

setValue

void setValue(D value)
Set the Value describing the restriction

Parameters:
value - The instanc for the Value

getErrorDescription

LocalizedString getErrorDescription()
If the restriction does not hold, the following error description can be used. On default these descriptions are searched in a resource bundle based on the name of this restriction.

Returns:
error description

setErrorDescription

void setErrorDescription(LocalizedString errorDescription)
Set error description for this restriction

Parameters:
errorDescription - description of error

valid

boolean valid(Object value,
              Node node,
              Field field)
This function should contain the actual logic of the restriction. This does not consider the 'enforceStrength' (that is only used in the containing DataType implementation).

Parameters:
value - The value to check the restriction for
node - Some constrainst may need the Node.
field - Some constrainst may need the Field.
Returns:
Whether the supplied value is a valid value for this restriction.

setFixed

void setFixed(boolean fixed)
If a restriction is 'fixed', the value and error-description cannot be changed any more.

Parameters:
fixed -

getEnforceStrength

int getEnforceStrength()
See DataType.ENFORCE_ALWAYS, DataType.ENFORCE_ONCHANGE, DataType.ENFORCE_NEVER.

Returns:
enforce strength

setEnforceStrength

void setEnforceStrength(int v)
Set enforce strength

Parameters:
v - value of DataType.ENFORCE_ALWAYS, DataType.ENFORCE_ONCHANGE, DataType.ENFORCE_NEVER.


MMBase 2.0-SNAPSHOT - null