[Mmil-commits] r29 - in trunk

alexandredenis at users.gforge.inria.fr alexandredenis at users.gforge.inria.fr
Mer 21 Fév 16:06:50 CET 2007


Author: alexandredenis
Date: 2007-02-21 16:06:47 +0100 (Wed, 21 Feb 2007)
New Revision: 29

Removed:
   trunk/src/fr/loria/led/mmil/objects/
Modified:
   trunk/etc/make/version
   trunk/src/fr/loria/led/mmil/MMILComponent.java
   trunk/src/fr/loria/led/mmil/MMILEntity.java
   trunk/src/fr/loria/led/mmil/MMILEvent.java
   trunk/src/fr/loria/led/mmil/MMILParticipant.java
Log:
The void methods of MMILEntity now return the modified entity.


Modified: trunk/etc/make/version
===================================================================
--- trunk/etc/make/version	2007-02-13 13:29:06 UTC (rev 28)
+++ trunk/etc/make/version	2007-02-21 15:06:47 UTC (rev 29)
@@ -1,5 +1,5 @@
 # kowey-generic build configurator
 
-version=0.1
-year=2006
+version=0.2
+year=2007
 

Modified: trunk/src/fr/loria/led/mmil/MMILComponent.java
===================================================================
--- trunk/src/fr/loria/led/mmil/MMILComponent.java	2007-02-13 13:29:06 UTC (rev 28)
+++ trunk/src/fr/loria/led/mmil/MMILComponent.java	2007-02-21 15:06:47 UTC (rev 29)
@@ -746,17 +746,15 @@
     /**
         Retrieve all the entities which are targets of a relationship whose source is the given entity.
         @param entity - an entity
-        @param relName - the name of a relation
-        @return the list of the entities (targets) connected to the given entity with a relation with given name.
+        @param relExpr - a regular expression matching the name of a relation
+        @return the list of the entities (targets) connected to the given entity with a relation that matches the given expression.
     */
-    public List<MMILEntity> getTargets(MMILEntity entity, String relName)
+    public List<MMILEntity> getTargets(MMILEntity entity, String relExpr)
     {
         List<MMILEntity> ret = new ArrayList<MMILEntity>();
-        
         for(MMILRelation r : relations)
-            if (r.getName().equals(relName) && r.getSource()==entity)
+            if (r.getName().matches(relExpr) && r.getSource()==entity)
                 ret.add(r.getTarget());
-        
         return ret;
     }
 
@@ -764,15 +762,15 @@
     /**
         Retrieve all the entities which are sources of a relationship whose target is the given entity.
         @param entity - an entity
-        @param relName - the name of a relation
-        @return the list of the entities (sources) connected to the given entity with a relation with given name.
+        @param relExpr - a regular expression matching the name of a relation
+        @return the list of the entities (sources) connected to the given entity with a relation that matches the given expression.
     */
-    public List<MMILEntity> getSources(MMILEntity entity, String relName)
+    public List<MMILEntity> getSources(MMILEntity entity, String relExpr)
     {
         List<MMILEntity> ret = new ArrayList<MMILEntity>();
         
         for(MMILRelation r : relations)
-            if (r.getName().equals(relName) && r.getTarget()==entity)
+            if (r.getName().matches(relExpr) && r.getTarget()==entity)
                 ret.add(r.getSource());
         
         return ret;
@@ -780,7 +778,7 @@
 
 
     /**
-        Get the event whose type is given.
+        Get the first event whose type is given.
         @param type - an evtType
         @return the found event or null if none is found
     */

Modified: trunk/src/fr/loria/led/mmil/MMILEntity.java
===================================================================
--- trunk/src/fr/loria/led/mmil/MMILEntity.java	2007-02-13 13:29:06 UTC (rev 28)
+++ trunk/src/fr/loria/led/mmil/MMILEntity.java	2007-02-21 15:06:47 UTC (rev 29)
@@ -13,7 +13,9 @@
     entity in the component and should be unique. The features are in the "mmil" namespace by default but features
     in other namespace (for a particular application) can also be added. In addition an entity can have sub-entities 
     (elements for a set or a sequence). The entity covers a linguistic expression given 
-    by left and right borns but as these borns are defined in terms of lexical units, they should used with caution.
+    by left and right borns but as these borns are defined in terms of lexical units, they should used with caution.<br/>
+    <b>Note</b>: to be convenient all the methods that modify the entity return the modified entity
+    
 */
 public abstract class MMILEntity implements Serializable, Comparable
 {
@@ -196,28 +198,46 @@
 	}
 
 
+
     /**
+        Tests if this entity subsumes by the features the given entity.
+        It is the case when this entity has all features of the given entity.
+    */
+    public boolean featureSubsumes(MMILEntity entity)
+    {
+        for(MMILFeature feat : entity.getFeatures())
+            if (!this.hasFeature(feat.getNamespace(), feat.getName(), feat.getValue()))
+                return false;
+        return true;
+    }
+
+    
+    /**
         Shift the left of the features in the sentence.
         It shifts all the index of the features of the entity.
         @param shift - a positive integer to move the left to the right, negative to move it to the left.
+        @return this modified entity
     */
-    public void shift(int shift)
+    public MMILEntity shift(int shift)
     {
         left+=shift;
         right+=shift;
         for(MMILFeature feat : features)
             feat.shift(shift);
+        return this;
     }
 
 
     /**
         Add all the features of the given entity to this entity and replace their value if they already exist.
         @param entity - any entity
+        @return this modified entity
     */
-    public void fusion(MMILEntity entity)
+    public MMILEntity fusion(MMILEntity entity)
     {
         for(MMILFeature feat : entity.getFeatures())
             replace(feat);
+        return this;
     }
 
 
@@ -236,10 +256,12 @@
 
 	/**
 		Sort the features by their index.
+        @return this modified entity
 	*/
-	public void sortFeatures()
+	public MMILEntity sortFeatures()
 	{
 		Collections.sort(features);	
+        return this;
 	}
 
     
@@ -373,10 +395,12 @@
 
     /**
         Set the id of this entity.
+        @return this modified entity
     */
-	public void setId(String id) 
+	public MMILEntity setId(String id) 
     {   
         this.id = id; 
+        return this;
     } 
 
     // deprecated
@@ -394,10 +418,12 @@
 
     /**
         Set the left born of this entity.
+        @return this modified entity
     */
-    public void setLeftIndex(int left) 
+    public MMILEntity setLeftIndex(int left) 
     { 
         this.left = left; 
+        return this;
     } 
 	
 
@@ -412,11 +438,12 @@
 
     /**
         Set the right born of this entity.
+        @return this modified entity
     */
-    public void setRightIndex(int right) 
+    public MMILEntity setRightIndex(int right) 
     { 
         this.right = right; 
-
+        return this;
     }
 
 
@@ -608,7 +635,10 @@
 	*/
 	public boolean hasFeature(String name)
 	{
-        return getFeature(name)!=null;
+        for(MMILFeature feat : features)
+            if (feat.getName().equalsIgnoreCase(name))
+                return true;
+        return false;
 	}
 
 
@@ -618,8 +648,8 @@
 	*/
 	public boolean hasFeature(String name, String value)
 	{
-        for(String val : getValuesOf(name))
-            if (val.equalsIgnoreCase(value))
+        for(MMILFeature feat : features)
+            if (feat.getName().equalsIgnoreCase(name) && feat.getValue().equalsIgnoreCase(value))
                 return true;
         return false;
 	}
@@ -690,10 +720,12 @@
 
     /**
         Remove all the features of this entity.
+        @return this modified entity
     */
-	public void removeAllFeatures()
+	public MMILEntity removeAllFeatures()
 	{
 		features = new ArrayList();
+        return this;
 	}
 
 
@@ -716,7 +748,7 @@
 	/**
 		Set the type of the entity (value of evtType or objType).
 	*/
-	public abstract void setType(String type);
+	public abstract MMILEntity setType(String type);
 
 
     /**
@@ -732,30 +764,36 @@
     /**
         Add a sub-entity to this entity.
         @deprecated Use add(MMILEntity) instead.
+        @return this modified entity
     */
-    public void addSubEntity(MMILEntity entity)
+    public MMILEntity addSubEntity(MMILEntity entity)
 	{
 	    subEntities.add(entity);
+        return this;
 	}
 
 
     /**
         Add a sub-entity to this entity.
         @param entity - any entity
+        @return this modified entity
     */
-	public void add(MMILEntity entity)
+	public MMILEntity add(MMILEntity entity)
 	{
 		addSubEntity(entity);
+        return this;
 	}
 
 
     /**
         Add a feature to this entity.
         @param feature - any feature
+        @return this modified entity
     */
-	public void add(MMILFeature feature)
+	public MMILEntity add(MMILFeature feature)
 	{
 		features.add(feature);
+        return this;
 	}
 
 
@@ -763,10 +801,12 @@
         Add a feature to this entity.
         @param name - the name of the feature
         @param value - the value of the feature
+        @return this modified entity
     */
-    public void addFeature(String name, String value)
+    public MMILEntity addFeature(String name, String value)
 	{
 		add(new MMILFeature(name, value));
+        return this;
 	}
 
 
@@ -775,10 +815,12 @@
         @param namespace - the namespace of the feature
         @param name - the name of the feature
         @param value - the value of the feature
+        @return this modified entity
     */
-    public void addFeature(String namespace, String name, String value)
+    public MMILEntity addFeature(String namespace, String name, String value)
 	{
 		add(new MMILFeature(namespace, name, value));
+        return this;
 	}
 
 
@@ -786,10 +828,12 @@
         Add a feature to this entity and replaces its value if it already exists.
         @param name - the name of the feature
         @param value - the value of the feature
+        @return this modified entity
     */
-    public void replaceFeature(String name, String value)
+    public MMILEntity replaceFeature(String name, String value)
     {
         replace(new MMILFeature(name, value));
+        return this;
     }
 
 
@@ -797,39 +841,45 @@
         Add a feature to this entity and replaces its value if it already exists.
         This method does not consider the namespace of the feature.
         @param feature - any feature already existing or not
+        @return this modified entity
 	*/
-	public void replace(MMILFeature feature)
+	public MMILEntity replace(MMILFeature feature)
 	{
 		for(MMILFeature feat : features)
 			if (feat.getName().equalsIgnoreCase(feature.getName()))
 			{
 				feat.setValue(feature.getValue());
-				return;
+				return this;
 			}
 
 		add(feature);
+        return this;
 	}
 
 
     /**
         Remove a feature of this entity.
         @param feature - any existing feature of this entity
+        @return this modified entity
     */
-	public void remove(MMILFeature feature)
+	public MMILEntity remove(MMILFeature feature)
 	{
 		features.remove(feature);
+        return this;
 	}
 
 
     /**
         Remove all the features which have the given name.
         @param name - a name of a feature
+        @return this modified entity
     */
-	public void remove(String name)
+	public MMILEntity remove(String name)
 	{
 		for(Iterator<MMILFeature> it = features.iterator(); it.hasNext();)
            	if (it.next().getName().equalsIgnoreCase(name))
 				it.remove();
+        return this;
 	}
 
     
@@ -837,8 +887,9 @@
         Remove all the features which have the given name and value.
         @param name a name of a feature
         @param value a value of a feature
+        @return this modified entity
     */
-	public void remove(String name, String value)
+	public MMILEntity remove(String name, String value)
 	{
 		for(Iterator<MMILFeature> it = features.iterator(); it.hasNext();)
         {
@@ -846,6 +897,7 @@
            	if (feat.getName().equalsIgnoreCase(name) && feat.getValue().equalsIgnoreCase(value))
 				it.remove();
         }
+        return this;
 	}
 
 
@@ -888,23 +940,28 @@
     /**
      * @return the fatherComponent
      */
-    public MMILComponent getFatherComponent() {
+    public MMILComponent getFatherComponent() 
+    {
         return fatherComponent;
     }
 
 
     /**
      * @param fatherComponent the fatherComponent to set
+        @return this modified entity
      */
-    public void setFatherComponent(MMILComponent fatherComponent) {
+    public MMILEntity setFatherComponent(MMILComponent fatherComponent) 
+    {
         if (fatherComponent.contains(this))
             this.fatherComponent = fatherComponent;
+        return this;
     } 
     
     /**
      * @return true if the MMILEntity is attached to its MMILComponent 
      */
-    public boolean isAttached() {
+    public boolean isAttached() 
+    {
         return (this.fatherComponent != null);
     }
 

Modified: trunk/src/fr/loria/led/mmil/MMILEvent.java
===================================================================
--- trunk/src/fr/loria/led/mmil/MMILEvent.java	2007-02-13 13:29:06 UTC (rev 28)
+++ trunk/src/fr/loria/led/mmil/MMILEvent.java	2007-02-21 15:06:47 UTC (rev 29)
@@ -116,8 +116,9 @@
         It replaces any existing value.
         @param evtType - the type of the event.
     */
-	public void setType(String evtType) 
+	public MMILEvent setType(String evtType) 
 	{ 
 		replace(new MMILFeature("evtType", evtType, getLeftIndex())); 
+        return this;
 	}
 }

Modified: trunk/src/fr/loria/led/mmil/MMILParticipant.java
===================================================================
--- trunk/src/fr/loria/led/mmil/MMILParticipant.java	2007-02-13 13:29:06 UTC (rev 28)
+++ trunk/src/fr/loria/led/mmil/MMILParticipant.java	2007-02-21 15:06:47 UTC (rev 29)
@@ -111,8 +111,9 @@
         It replaces any existing value.
         @param objType - the type of the participant.
     */
-	public void setType(String objType) 
+	public MMILParticipant setType(String objType) 
 	{ 
 		replace(new MMILFeature("objType", objType, getLeftIndex())); 
+        return this;
 	}
 }






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