org.mmbase.datatypes
Class BasicDataType.StaticAbstractRestriction<D extends Serializable>

java.lang.Object
  extended by org.mmbase.datatypes.BasicDataType.StaticAbstractRestriction<D>
All Implemented Interfaces:
Serializable, DataType.Restriction<D>
Direct Known Subclasses:
AbstractLengthDataType.MaxRestriction, AbstractLengthDataType.MinRestriction, BasicDataType.AbstractRestriction
Enclosing class:
BasicDataType<C>

protected abstract static class BasicDataType.StaticAbstractRestriction<D extends Serializable>
extends Object
implements DataType.Restriction<D>

A Restriction is represented by these kind of objects. When you override this class, take care of cloning of outer class! This class itself is not cloneable. Cloning is hard when you have inner classes. All restrictions extend from this. See article about inner classes, cloning in java

See Also:
Serialized Form

Field Summary
protected  BasicDataType.StaticAbstractRestriction<?> absoluteParent
          If a restriction has an 'absolute' parent restriction, then also that restriction must be valid (because it was 'absolute').
protected  int enforceStrength
           
protected  LocalizedString errorDescription
           
protected  boolean fixed
           
protected  String name
           
protected  BasicDataType<?> parent
           
protected  D value
           
 
Constructor Summary
protected BasicDataType.StaticAbstractRestriction(BasicDataType<?> parent, BasicDataType.StaticAbstractRestriction<?> source)
          Instantaties new restriction for a clone of the parent DataType.
protected BasicDataType.StaticAbstractRestriction(BasicDataType<?> parent, String name, D value)
           
 
Method Summary
protected  Collection<LocalizedString> addError(Collection<LocalizedString> errors, Object v, Node node, Field field)
          Utility method to add a new error message to the errors collection, based on this Restriction.
protected  boolean enforce(Object v, Node node, Field field)
          Whether validate(java.util.Collection, java.lang.Object, org.mmbase.bridge.Node, org.mmbase.bridge.Field) must enforce this condition
 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.
protected  String getErrorDescriptionBundle()
           
 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)
protected  void inherit(BasicDataType.StaticAbstractRestriction<?> source)
           
protected  void inherit(BasicDataType.StaticAbstractRestriction<?> source, boolean cast)
           
 boolean isFixed()
           
 void setEnforceStrength(int e)
          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 v)
          Set the Value describing the restriction
protected abstract  boolean simpleValid(Object v, Node node, Field field)
           
 String toString()
           
 String toString(Node node, Field field)
           
 boolean valid(Object v, Node node, Field field)
          This function should contain the actual logic of the restriction.
protected  Collection<LocalizedString> validate(Collection<LocalizedString> errors, Object v, Node node, Field field)
          This method is called by BasicDataType.validate(Object, Node, Field) for each of its conditions.
protected  String valueString(Node node, Field field)
          If value of a a restriction depends on node, field, then you can override this
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected final String name

parent

protected final BasicDataType<?> parent

errorDescription

protected LocalizedString errorDescription

value

protected D extends Serializable value

fixed

protected boolean fixed

enforceStrength

protected int enforceStrength

absoluteParent

protected BasicDataType.StaticAbstractRestriction<?> absoluteParent
If a restriction has an 'absolute' parent restriction, then also that restriction must be valid (because it was 'absolute'). A restriction gets an absolute parent if its surrounding DataType is clone of DataType in which the same restriction is marked with DataType.ENFORCE_ABSOLUTE.

Constructor Detail

BasicDataType.StaticAbstractRestriction

protected BasicDataType.StaticAbstractRestriction(BasicDataType<?> parent,
                                                  BasicDataType.StaticAbstractRestriction<?> source)
Instantaties new restriction for a clone of the parent DataType. If the source restriction is 'absolute' it will remain to be enforced even if the clone gets a new value.


BasicDataType.StaticAbstractRestriction

protected BasicDataType.StaticAbstractRestriction(BasicDataType<?> parent,
                                                  String name,
                                                  D value)
Method Detail

getName

public String getName()
Specified by:
getName in interface DataType.Restriction<D extends Serializable>
Returns:
Name of datatype

getValue

public D getValue()
Description copied from interface: DataType.Restriction
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)

Specified by:
getValue in interface DataType.Restriction<D extends Serializable>
Returns:
A Value describing the restriction

setValue

public void setValue(D v)
Description copied from interface: DataType.Restriction
Set the Value describing the restriction

Specified by:
setValue in interface DataType.Restriction<D extends Serializable>
Parameters:
v - The instanc for the Value

getErrorDescriptionBundle

protected String getErrorDescriptionBundle()
Since:
MMBase-1.9.3

getErrorDescription

public LocalizedString getErrorDescription()
Description copied from interface: DataType.Restriction
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.

Specified by:
getErrorDescription in interface DataType.Restriction<D extends Serializable>
Returns:
error description

setErrorDescription

public void setErrorDescription(LocalizedString errorDescription)
Description copied from interface: DataType.Restriction
Set error description for this restriction

Specified by:
setErrorDescription in interface DataType.Restriction<D extends Serializable>
Parameters:
errorDescription - description of error

isFixed

public boolean isFixed()

setFixed

public void setFixed(boolean fixed)
Description copied from interface: DataType.Restriction
If a restriction is 'fixed', the value and error-description cannot be changed any more.

Specified by:
setFixed in interface DataType.Restriction<D extends Serializable>

addError

protected final Collection<LocalizedString> addError(Collection<LocalizedString> errors,
                                                     Object v,
                                                     Node node,
                                                     Field field)
Utility method to add a new error message to the errors collection, based on this Restriction. If this error-collection is unmodifiable (VALID), it is replaced with a new empty one first.


valueString

protected String valueString(Node node,
                             Field field)
If value of a a restriction depends on node, field, then you can override this


enforce

protected final boolean enforce(Object v,
                                Node node,
                                Field field)
Whether validate(java.util.Collection, java.lang.Object, org.mmbase.bridge.Node, org.mmbase.bridge.Field) must enforce this condition


validate

protected Collection<LocalizedString> validate(Collection<LocalizedString> errors,
                                               Object v,
                                               Node node,
                                               Field field)
This method is called by BasicDataType.validate(Object, Node, Field) for each of its conditions.


valid

public final boolean valid(Object v,
                           Node node,
                           Field field)
Description copied from interface: DataType.Restriction
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).

Specified by:
valid in interface DataType.Restriction<D extends Serializable>
Parameters:
v - 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.

simpleValid

protected abstract boolean simpleValid(Object v,
                                       Node node,
                                       Field field)

inherit

protected final void inherit(BasicDataType.StaticAbstractRestriction<?> source,
                             boolean cast)

inherit

protected final void inherit(BasicDataType.StaticAbstractRestriction<?> source)

getEnforceStrength

public int getEnforceStrength()
Description copied from interface: DataType.Restriction
See DataType.ENFORCE_ALWAYS, DataType.ENFORCE_ONCHANGE, DataType.ENFORCE_NEVER.

Specified by:
getEnforceStrength in interface DataType.Restriction<D extends Serializable>
Returns:
enforce strength

setEnforceStrength

public void setEnforceStrength(int e)
Description copied from interface: DataType.Restriction
Set enforce strength

Specified by:
setEnforceStrength in interface DataType.Restriction<D extends Serializable>
Parameters:
e - value of DataType.ENFORCE_ALWAYS, DataType.ENFORCE_ONCHANGE, DataType.ENFORCE_NEVER.

toString

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

toString

public final String toString(Node node,
                             Field field)


MMBase 2.0-SNAPSHOT - null