Remote: jdoc + description + some fixes:
[jvcard.git] / src / be / nikiroo / jvcard / BaseClass.java
index 26863902e59c8ec1447bbc44b9e1006b60843b5e..df0fcf00de78f998ad87d03842dc4947f86a966a 100644 (file)
@@ -9,7 +9,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 
-import be.nikiroo.jvcard.tui.StringUtils;
+import be.nikiroo.jvcard.resources.StringUtils;
 
 /**
  * This class is basically a List with a parent and a "dirty" state check. It
@@ -155,17 +155,20 @@ public abstract class BaseClass<E extends BaseClass<?>> implements List<E> {
                Collections.sort(other, comparator);
 
                boolean equ = true;
-               while (mine.size() > 0 || other.size() > 0) {
-                       E here = (mine.size() > 0) ? mine.remove(0) : null;
-                       E there = (other.size() > 0) ? other.remove(0) : null;
+               E here = mine.size() > 0 ? mine.remove(0) : null;
+               E there = other.size() > 0 ? other.remove(0) : null;
 
-                       if (here == null || comparator.compare(here, there) > 0) {
+               while (here != null || there != null) {
+                       if (here == null
+                                       || (there != null && comparator.compare(here, there) > 0)) {
                                if (added != null)
                                        added.add(there);
+                               there = null;
                                equ = false;
                        } else if (there == null || comparator.compare(here, there) < 0) {
                                if (removed != null)
                                        removed.add(here);
+                               here = null;
                                equ = false;
                        } else {
                                // they represent the same item
@@ -176,7 +179,14 @@ public abstract class BaseClass<E extends BaseClass<?>> implements List<E> {
                                                to.add(there);
                                        equ = false;
                                }
+                               here = null;
+                               there = null;
                        }
+
+                       if (here == null && mine.size() > 0)
+                               here = mine.remove(0);
+                       if (there == null && other.size() > 0)
+                               there = other.remove(0);
                }
 
                return equ;
@@ -241,7 +251,14 @@ public abstract class BaseClass<E extends BaseClass<?>> implements List<E> {
 
        /**
         * Get the recursive state of the current object, i.e., its children. It
-        * represents the full state information about this object's children.
+        * represents the full state information about this object's children. It
+        * may not contains spaces nor new lines.
+        * 
+        * <p>
+        * Not that this state is <b>lossy</b>. You cannot retrieve the data from
+        * the state, it can only be used as an ID to check if thw data are
+        * identical.
+        * </p>
         * 
         * @return a {@link String} representing the current content state of this
         *         object, i.e., its children included
@@ -285,7 +302,14 @@ public abstract class BaseClass<E extends BaseClass<?>> implements List<E> {
        /**
         * Get the state of the current object, children <b>not included</b>. It
         * represents the full state information about this object, but do not check
-        * its children (see {@link BaseClass#getContentState()} for that).
+        * its children (see {@link BaseClass#getContentState()} for that). It may
+        * not contains spaces nor new lines.
+        * 
+        * <p>
+        * Not that this state is <b>lossy</b>. You cannot retrieve the data from
+        * the state, it can only be used as an ID to check if thw data are
+        * identical.
+        * </p>
         * 
         * @return a {@link String} representing the current state of this object,
         *         children not included