Update of /var/cvs/src/org/mmbase/datatypes
In directory james.mmbase.org:/tmp/cvs-serv6032

Modified Files:
        BasicDataType.java ComparableDataType.java DataType.java 
        DataTypes.java DateTimeDataType.java 
Log Message:
some adjustments because of change to PublicCloneable


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/datatypes


Index: BasicDataType.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/BasicDataType.java,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -b -r1.96 -r1.97
--- BasicDataType.java  21 Aug 2008 14:59:52 -0000      1.96
+++ BasicDataType.java  27 Aug 2008 17:09:16 -0000      1.97
@@ -40,10 +40,10 @@
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
  * @since  MMBase-1.8
- * @version $Id: BasicDataType.java,v 1.96 2008/08/21 14:59:52 michiel Exp $
+ * @version $Id: BasicDataType.java,v 1.97 2008/08/27 17:09:16 michiel Exp $
  */
 
-public class BasicDataType<C> extends AbstractDescriptor implements 
DataType<C>, Cloneable, Comparable<DataType<C>>, Descriptor {
+public class BasicDataType<C> extends AbstractDescriptor implements 
DataType<C>, Comparable<DataType<C>>, Descriptor {
     /**
      * The bundle used by datatype to determine default prompts for error 
messages when a
      * validation fails.
@@ -593,7 +593,7 @@
      *
      * This method is final, override [EMAIL PROTECTED] #clone(String)} in 
stead.
      */
-    public final Object clone() {
+    @Override public final BasicDataType<C> clone() {
         return clone(null);
     }
 
@@ -603,8 +603,7 @@
      * Besides super.clone, it calls [EMAIL PROTECTED] 
#inheritProperties(BasicDataType)} and [EMAIL PROTECTED]
      * #cloneRestrictions(BasicDataType)}. A clone is not finished. See [EMAIL 
PROTECTED] #isFinished()}.
      */
-    public DataType clone(String name) {
-        try {
+    @Override public BasicDataType<C> clone(String name) {
             BasicDataType<C> clone = (BasicDataType<C>) super.clone(name);
             // reset owner if it was set, so this datatype can be changed
             clone.rewrite(clone.owner);
@@ -615,11 +614,6 @@
                 log.trace("Cloned " + this + " -> " + clone);
             }
             return clone;
-        } catch (CloneNotSupportedException cnse) {
-            // should not happen
-            log.error("Cannot clone this DataType: " + name);
-            throw new RuntimeException("Cannot clone this DataType: " + name, 
cnse);
-        }
     }
 
     public Element toXml() {


Index: ComparableDataType.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/ComparableDataType.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- ComparableDataType.java     9 Jun 2008 10:20:35 -0000       1.37
+++ ComparableDataType.java     27 Aug 2008 17:09:16 -0000      1.38
@@ -21,7 +21,7 @@
  * therefore can have a minimum and a maximum value.
  *
  * @author Michiel Meeuwissen
- * @version $Id: ComparableDataType.java,v 1.37 2008/06/09 10:20:35 michiel 
Exp $
+ * @version $Id: ComparableDataType.java,v 1.38 2008/08/27 17:09:16 michiel 
Exp $
  * @since MMBase-1.8
  */
 public abstract class ComparableDataType<E extends 
java.io.Serializable&Comparable<E>> extends BasicDataType<E> {
@@ -36,8 +36,8 @@
     protected ComparableDataType(String name, Class<E> classType) {
         super(name, classType);
     }
-    @Override
-    protected void inheritRestrictions(BasicDataType<E> origin) {
+    
+    @Override protected void inheritRestrictions(BasicDataType<E> origin) {
         super.inheritRestrictions(origin);
         if (origin instanceof ComparableDataType) {
             ComparableDataType<E> compOrigin = (ComparableDataType<E>) origin;
@@ -174,7 +174,7 @@
         return errors;
     }
 
-    public DataType<E> clone(String name) {
+    public ComparableDataType<E> clone(String name) {
         ComparableDataType<E> clone = (ComparableDataType<E>) 
super.clone(name);
         return clone;
     }


Index: DataType.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/DataType.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- DataType.java       15 Jul 2008 19:41:00 -0000      1.69
+++ DataType.java       27 Aug 2008 17:09:16 -0000      1.70
@@ -33,11 +33,11 @@
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
  * @since  MMBase-1.8
- * @version $Id: DataType.java,v 1.69 2008/07/15 19:41:00 michiel Exp $
+ * @version $Id: DataType.java,v 1.70 2008/08/27 17:09:16 michiel Exp $
  * @param <C> Class this DataType
  */
 
-public interface DataType<C> extends Descriptor, Cloneable, 
Comparable<DataType<C>>, Serializable {
+public interface DataType<C> extends Descriptor, Comparable<DataType<C>>, 
Serializable {
 
     /**
      * The XML Namespace to be used for creating datatype XML
@@ -50,35 +50,40 @@
 
     /**
      * Return value for [EMAIL PROTECTED] 
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'.
+     * restriction 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'.
      */
     static final int ENFORCE_ABSOLUTE  = Integer.MAX_VALUE;
 
     /**
-     * Return value for [EMAIL PROTECTED] 
DataType.Restriction#getEnforceStrength}. This means that the value must be 
enforced always.
+     * Return value for [EMAIL PROTECTED] 
DataType.Restriction#getEnforceStrength}. This means that a
+     * restriction on a value must be enforced always.
      */
     static final int ENFORCE_ALWAYS   = 100000;
 
     /**
-     * Return value for [EMAIL PROTECTED] 
DataType.Restriction#getEnforceStrength}. This means that the value must be 
enforced only if it was changed.
+     * Return value for [EMAIL PROTECTED] 
DataType.Restriction#getEnforceStrength}. This means that a
+     * restriction on a value must be enforced only if it was changed.
      */
     static final int ENFORCE_ONCHANGE = 10000;
 
     /**
-     * Return value for [EMAIL PROTECTED] 
DataType.Restriction#getEnforceStrength}. This means that the value must be 
enforced only on creation.
+     * Return value for [EMAIL PROTECTED] 
DataType.Restriction#getEnforceStrength}. This means that ta
+     * restriction on a value must be enforced only on creation.
      */
     static final int ENFORCE_ONCREATE = 1000;
 
     /**
      * Return value for [EMAIL PROTECTED] 
DataType.Restriction#getEnforceStrength}. This means that the
-     * value must be enforced never, so the restriction serves only as UI 
indication.
+     * restriction on a value must be enforced never, so the restriction 
serves only as UI indication.
      */
     static final int ENFORCE_NEVER    = 0;
 
     /**
-     * Returned by [EMAIL PROTECTED] #validate(Object, Node, Field)} if no 
errors: an empty (nonmodifiable) Collection.
+     * Returned by [EMAIL PROTECTED] #validate(Object, Node, Field)} if no 
errors: an empty (nonmodifiable)
+     * Collection containing no error messages.
      */
     public static final Collection<LocalizedString> VALID = 
Collections.emptyList();
 
@@ -206,7 +211,8 @@
      *        datatype is determined as unique, than uniquness is checked for 
this value using the passed field.
      * @param field the field for which the datatype is checked.
      *
-     * @return The error message(s) if the value is not compatible. An empty 
collection if the value is valid.
+     * @return The error message(s) if the value is not compatible. An empty 
collection ([EMAIL PROTECTED]
+     * DataType#VALID})if the value is valid.
      */
     public Collection<LocalizedString> validate(C value, Node node, Field 
field);
 
@@ -345,7 +351,7 @@
      * was finished. This means that the cloned datatype can be changed.
      * @return cloned instance
      */
-    public Object clone();
+    public DataType<C> clone();
 
     /**
      * Returns a cloned instance of this datatype, inheriting all validation 
rules.
@@ -364,14 +370,18 @@
     public org.w3c.dom.Element toXml();
 
     /**
-     * Fills this datatype in another XML (for example in the xml of [EMAIL 
PROTECTED] #getOrigin}, to make one XML, fully describing the DataType).
-     * The implementation of this method is <em>unfinished</em>!
+     * Fills this datatype in another XML (for example in the xml of [EMAIL 
PROTECTED] #getOrigin}, to make one
+     * XML, fully describing the DataType).  The implementation of this method 
is
+     * <em>unfinished</em>!
      * @todo EXPERIMENTAL
      * @param element a 'datatype' element.
      */
     public void toXml(org.w3c.dom.Element element);
 
     /**
+     * Returns a handler for given mimetype for this DataType. The handler can 
be used to produce UI
+     * for values of this datatype.
+     * @todo EXPERIMENTAL
      * @since MMBase-1.9.1
      */
     public Handler getHandler(String mimeType);
@@ -382,7 +392,8 @@
 
 
     /**
-     * A restriction controls (one aspect of) the acceptable values of a 
DataType. A DataType generally has several restrictions.
+     * A restriction controls (one aspect of) the acceptable values of a 
DataType. A DataType
+     * generally has several restrictions.
      * @param <D> Type of Value describing the restriction
      */
     public interface Restriction<D extends Serializable> extends Serializable {


Index: DataTypes.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/DataTypes.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- DataTypes.java      14 Aug 2008 16:16:02 -0000      1.29
+++ DataTypes.java      27 Aug 2008 17:09:16 -0000      1.30
@@ -39,7 +39,7 @@
  *</p>
  * @author Pierre van Rooden
  * @since  MMBase-1.8
- * @version $Id: DataTypes.java,v 1.29 2008/08/14 16:16:02 michiel Exp $
+ * @version $Id: DataTypes.java,v 1.30 2008/08/27 17:09:16 michiel Exp $
  */
 
 public class DataTypes {
@@ -78,16 +78,23 @@
 
     }
 
-
-    private static void readFailedDependencies(List<DependencyException> 
failed) {
+    /**
+     * Retry to read a datype which previously failed to read. It could 
succeed now, because other
+     * datatypes, on which it may depend, were defined in the mean time.
+     * @return The number of datatypes which were resolved after all.
+     */
+    private static int readFailedDependencies(List<DependencyException> 
failed) {
+        int resolved = 0;
         ListIterator<DependencyException> i = failed.listIterator();
         while(i.hasNext()) {
             DependencyException de = i.next();
             if (de.retry()) {
                 log.debug("Resolved " + de.getId() + " after all");
+                resolved++;
                 i.remove();
             }
         }
+        return resolved;
     }
 
     /**
@@ -118,12 +125,8 @@
                 log.error(e.getMessage(), e);
             }
         }
-        int previousFailedSize = -1;
-        while (failed.size() > 0 && failed.size() > previousFailedSize) {
-            previousFailedSize = failed.size();
-            log.debug(failed);
-            readFailedDependencies(failed);
-        }
+        while (readFailedDependencies(failed) > 0);
+
         if (failed.size() > 0) {
             log.error("Failed " + failed);
         }


Index: DateTimeDataType.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/datatypes/DateTimeDataType.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- DateTimeDataType.java       13 Aug 2008 07:48:24 -0000      1.39
+++ DateTimeDataType.java       27 Aug 2008 17:09:16 -0000      1.40
@@ -24,7 +24,7 @@
  *
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
- * @version $Id: DateTimeDataType.java,v 1.39 2008/08/13 07:48:24 michiel Exp $
+ * @version $Id: DateTimeDataType.java,v 1.40 2008/08/27 17:09:16 michiel Exp $
  * @since MMBase-1.8
  */
 public class DateTimeDataType extends ComparableDataType {
@@ -129,7 +129,7 @@
     }
 
 
-    public DataType clone(String name) {
+    public DateTimeDataType clone(String name) {
         DateTimeDataType clone = (DateTimeDataType) super.clone(name);
         clone.weakPattern = true;
         return clone;
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to