Update of /var/cvs/src/org/mmbase/datatypes In directory james.mmbase.org:/tmp/cvs-serv4451
Modified Files: DataType.java BasicDataType.java Log Message: Added castAndValidate, which boths casts and validates, which is usefull for code which has DataType<?> See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/datatypes Index: DataType.java =================================================================== RCS file: /var/cvs/src/org/mmbase/datatypes/DataType.java,v retrieving revision 1.73 retrieving revision 1.74 diff -u -b -r1.73 -r1.74 --- DataType.java 27 Apr 2009 17:15:45 -0000 1.73 +++ DataType.java 28 Apr 2009 08:44:00 -0000 1.74 @@ -33,7 +33,7 @@ * @author Pierre van Rooden * @author Michiel Meeuwissen * @since MMBase-1.8 - * @version $Id: DataType.java,v 1.73 2009/04/27 17:15:45 michiel Exp $ + * @version $Id: DataType.java,v 1.74 2009/04/28 08:44:00 michiel Exp $ * @param <C> Class this DataType */ @@ -228,6 +228,13 @@ public Collection<LocalizedString> validate(C value, Node node, Field field); /** + * Validates a value without knowing its type yet. + * + * @since MMBase-1.9.1 + */ + public Collection<LocalizedString> castAndValidate(Object value, Node node, Field field); + + /** * Returns whether this field is required (may not be <code>null</code>, or otherwise empty). * * @return <code>true</code> if the field is required Index: BasicDataType.java =================================================================== RCS file: /var/cvs/src/org/mmbase/datatypes/BasicDataType.java,v retrieving revision 1.108 retrieving revision 1.109 diff -u -b -r1.108 -r1.109 --- BasicDataType.java 27 Apr 2009 17:19:20 -0000 1.108 +++ BasicDataType.java 28 Apr 2009 08:44:00 -0000 1.109 @@ -40,7 +40,7 @@ * @author Pierre van Rooden * @author Michiel Meeuwissen * @since MMBase-1.8 - * @version $Id: BasicDataType.java,v 1.108 2009/04/27 17:19:20 michiel Exp $ + * @version $Id: BasicDataType.java,v 1.109 2009/04/28 08:44:00 michiel Exp $ */ public class BasicDataType<C> extends AbstractDescriptor implements DataType<C>, Comparable<DataType<C>>, Descriptor { @@ -566,6 +566,10 @@ return errors; } + public final Collection<LocalizedString> castAndValidate(final Object value, final Node node, final Field field) { + return validate(cast(value, node, field), node, field); + } + public int getEnforceStrength() { int enforceStrength = Math.max(typeRestriction.getEnforceStrength(), requiredRestriction.getEnforceStrength()); enforceStrength = Math.max(enforceStrength, enumerationRestriction.getEnforceStrength()); _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs