[Mmil-commits] r21 - trunk/src/fr/loria/led/mmil

alexandredenis at users.gforge.inria.fr alexandredenis at users.gforge.inria.fr
Mar 3 Oct 12:55:27 CEST 2006


Author: alexandredenis
Date: 2006-10-03 10:55:26 +0000 (Tue, 03 Oct 2006)
New Revision: 21

Modified:
   trunk/src/fr/loria/led/mmil/MMILEntity.java
Log:


Modified: trunk/src/fr/loria/led/mmil/MMILEntity.java
===================================================================
--- trunk/src/fr/loria/led/mmil/MMILEntity.java	2006-10-03 10:47:53 UTC (rev 20)
+++ trunk/src/fr/loria/led/mmil/MMILEntity.java	2006-10-03 10:55:26 UTC (rev 21)
@@ -255,11 +255,14 @@
     */
     public MMILEntity unify(MMILEntity entity)
     {
+        if (!getMMILType().equals(entity.getMMILType()))
+            return null;
+
         MMILEntity ret = entity instanceof MMILParticipant ? new MMILParticipant() : new MMILEvent();
         for(MMILFeature feat : features)
         {
             List<String> values = entity.getValuesOf(feat.getName());
-            if (values.isEmpty() || values.contains(feat.getValue()))
+            if (values.isEmpty() || containsIgnoreCase(values, feat.getValue()))
             {
                 if (!ret.hasFeature(feat.getNamespace(), feat.getName(), feat.getValue()))
                     ret.add(feat);
@@ -269,7 +272,7 @@
         for(MMILFeature feat : entity.getFeatures())
         {
             List<String> values = getValuesOf(feat.getName());
-            if (values.isEmpty() || values.contains(feat.getValue()))
+            if (values.isEmpty() || containsIgnoreCase(values, feat.getValue()))
             {
                 if (!ret.hasFeature(feat.getNamespace(), feat.getName(), feat.getValue()))
                     ret.add(feat);
@@ -279,8 +282,17 @@
         return ret;         
     }
 
+    /**
+        Tests if a list of strings contains a given string without case.
+    */
+    private boolean containsIgnoreCase(List<String> list, String str)
+    {
+        for(String s : list)
+            if (s.equalsIgnoreCase(str))
+                return true;
+        return false;
+    }
 
-
 //////// TESTS 
 
     /**






Plus d'informations sur la liste de diffusion Mmil-commits