org.mmbase.datatypes
Class BasicDataType.StaticAbstractRestriction

java.lang.Object
  extended byorg.mmbase.datatypes.BasicDataType.StaticAbstractRestriction
All Implemented Interfaces:
DataType.Restriction, Serializable
Direct Known Subclasses:
BasicDataType.AbstractRestriction
Enclosing class:
BasicDataType

protected abstract static class BasicDataType.StaticAbstractRestriction
extends Object
implements DataType.Restriction

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  Serializable 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, Serializable value)
           
 
Method Summary
protected  Collection addError(Collection 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(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.
 String getName()
           
 Serializable 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)
           
 void setErrorDescription(LocalizedString errorDescription)
           
 void setFixed(boolean fixed)
          If a restriction is 'fixed', the value and error-description cannot be changed any more.
 void setValue(Serializable v)
           
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 validate(Collection 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 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,
                                                  Serializable value)
Method Detail

getName

public String getName()
Specified by:
getName in interface DataType.Restriction

getValue

public Serializable 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

setValue

public void setValue(Serializable v)
Specified by:
setValue in interface DataType.Restriction

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

setErrorDescription

public void setErrorDescription(LocalizedString errorDescription)
Specified by:
setErrorDescription in interface DataType.Restriction

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

addError

protected final Collection addError(Collection 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(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 validate(Collection 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
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

setEnforceStrength

public void setEnforceStrength(int e)
Specified by:
setEnforceStrength in interface DataType.Restriction

toString

public final String toString()

toString

public final String toString(Node node,
                             Field field)


MMBase build 1.8.1.20060716