[Mmil-commits] r75 - trunk/src/fr/loria/talaris/mmil

alexandredenis at users.gforge.inria.fr alexandredenis at users.gforge.inria.fr
Mar 14 Déc 19:30:52 CET 2010


Author: alexandredenis
Date: 2010-12-14 19:30:51 +0100 (Tue, 14 Dec 2010)
New Revision: 75

Modified:
   trunk/src/fr/loria/talaris/mmil/DefaultMMILEntity.java
   trunk/src/fr/loria/talaris/mmil/DefaultMMILRelation.java
Log:
Added index in toString

Modified: trunk/src/fr/loria/talaris/mmil/DefaultMMILEntity.java
===================================================================
--- trunk/src/fr/loria/talaris/mmil/DefaultMMILEntity.java	2010-12-14 15:55:13 UTC (rev 74)
+++ trunk/src/fr/loria/talaris/mmil/DefaultMMILEntity.java	2010-12-14 18:30:51 UTC (rev 75)
@@ -8,19 +8,21 @@
  */
 public abstract class DefaultMMILEntity implements MMILEntity
 {
-	protected int index = -1;					// -1 is unset
+	protected int index = -1; // -1 is unset
 	protected String id = "";
 	protected MMILComponent component = null;
 	protected List<MMILFeature> features = new ArrayList<MMILFeature>();
-	
+
+
 	/**
 	 * Creates an empty default entity.
 	 */
 	public DefaultMMILEntity()
 	{
-	
+
 	}
-	
+
+
 	/**
 	 * Creates an empty default entity with given id.
 	 * @param id
@@ -29,21 +31,22 @@
 	{
 		this.id = id;
 	}
-	
+
+
 	/**
-	 * Copy constructor.
-	 * Creates a new DefaultMMILEntity from the given entity with the same features, in the same component.
+	 * Copy constructor. Creates a new DefaultMMILEntity from the given entity
+	 * with the same features, in the same component.
 	 * @param entity
 	 */
 	public DefaultMMILEntity(MMILEntity entity)
 	{
 		this(entity, entity.getComponent());
 	}
-	
-	
+
+
 	/**
-	 * Copy constructor.
-	 * Creates a new DefaultMMILEntity from the given entity with the same features, in another component.
+	 * Copy constructor. Creates a new DefaultMMILEntity from the given entity
+	 * with the same features, in another component.
 	 * @param entity
 	 */
 	public DefaultMMILEntity(MMILEntity entity, MMILComponent mmil)
@@ -55,32 +58,36 @@
 		for(MMILFeature feat : entity.getFeatures())
 			add(feat.copy());
 	}
-	
-	
+
+
+	@Override
 	public int getIndex()
 	{
 		return index;
 	}
 
+
+	@Override
 	public void setIndex(int index)
 	{
 		this.index = index;
 	}
 
-	
+
 	@Override
 	public void add(MMILFeature feature)
 	{
 		features.add(feature);
 	}
 
+
 	@Override
 	public MMILComponent getComponent()
 	{
 		return component;
 	}
 
-	
+
 	/**
 	 * Get the first found feature which has the given name.
 	 * @return null if none with the given name is found
@@ -94,6 +101,7 @@
 		return null;
 	}
 
+
 	/**
 	 * Gets all the features of this entity.
 	 * @return a COPY of the features list of this entity.
@@ -103,6 +111,7 @@
 		return new ArrayList<MMILFeature>(features);
 	}
 
+
 	@Override
 	public Collection<MMILFeature> getFeatures(MMILFeature feature)
 	{
@@ -112,7 +121,8 @@
 				feats.add(feat);
 		return feats;
 	}
-	
+
+
 	@Override
 	public Collection<MMILFeature> getFeaturesByName(String name)
 	{
@@ -123,12 +133,14 @@
 		return feats;
 	}
 
+
 	@Override
 	public String getId()
 	{
 		return id;
 	}
 
+
 	@Override
 	public Collection<MMILFeature> getModifiers()
 	{
@@ -139,6 +151,7 @@
 		return feats;
 	}
 
+
 	@Override
 	public Collection<String> getOuterNamespaces()
 	{
@@ -149,6 +162,7 @@
 		return ns;
 	}
 
+
 	@Override
 	public Collection<MMILRelation> getRelationalModifiers()
 	{
@@ -158,11 +172,10 @@
 	}
 
 
-	
 	@Override
 	public abstract String getType();
-	
 
+
 	@Override
 	public String getValueOf(String name)
 	{
@@ -172,7 +185,7 @@
 		return "";
 	}
 
-	
+
 	@Override
 	public Collection<String> getValuesOf(String name)
 	{
@@ -183,14 +196,14 @@
 		return values;
 	}
 
-	
+
 	@Override
 	public boolean hasComponent()
 	{
-		return component!=null;
+		return component != null;
 	}
 
-	
+
 	@Override
 	public boolean hasFeature(MMILFeature feature)
 	{
@@ -199,8 +212,8 @@
 				return true;
 		return false;
 	}
-	
-	
+
+
 	@Override
 	public boolean hasFeature(String name)
 	{
@@ -209,7 +222,9 @@
 				return true;
 		return false;
 	}
-	
+
+
+	@Override
 	public boolean hasFeature(String name, String value)
 	{
 		for(MMILFeature feat : features)
@@ -217,22 +232,23 @@
 				return true;
 		return false;
 	}
-	
+
+
+	@Override
 	public boolean hasFeature(String namespace, String name, String value)
 	{
 		for(MMILFeature feat : features)
-			if (feat.getNamespace().matches(namespace) && 
-				feat.getName().matches(name) && 
-				feat.getValue().matches(value))
+			if (feat.getNamespace().matches(namespace) && feat.getName().matches(name)
+					&& feat.getValue().matches(value))
 				return true;
 		return false;
 	}
 
-	
+
 	@Override
 	public abstract boolean hasType();
-	
 
+
 	@Override
 	public void join(MMILEntity entity)
 	{
@@ -240,14 +256,14 @@
 
 	}
 
-	
+
 	@Override
 	public void remove(MMILFeature feature)
 	{
 		features.remove(feature);
 	}
 
-	
+
 	/**
 	 * Removes all the features that have the given name.
 	 * @param feature
@@ -258,7 +274,8 @@
 			if (it.next().getName().matches(name))
 				it.remove();
 	}
-	
+
+
 	/**
 	 * Removes all the features that have the given name and value.
 	 * @param feature
@@ -272,16 +289,15 @@
 				it.remove();
 		}
 	}
-	
-	
-	
+
+
 	@Override
 	public void removeAllFeatures()
 	{
 		features = new ArrayList<MMILFeature>();
 	}
 
-	
+
 	@Override
 	public void replace(MMILFeature feature)
 	{
@@ -291,7 +307,8 @@
 			if (feat.getName().equals(name))
 				feat.setValue(value);
 	}
-	
+
+
 	@Override
 	public void replaceFeature(String name, String value)
 	{
@@ -299,37 +316,37 @@
 			if (feat.getName().equals(name))
 				feat.setValue(value);
 	}
-	
-	
+
+
 	@Override
 	public void setValueOf(String name, String value)
 	{
 		if (!hasFeature(name, value))
 			addFeature(name, value);
 		else for(MMILFeature feat : features)
-				if (feat.getName().equals(name))
-					feat.setValue(value);
+			if (feat.getName().equals(name))
+				feat.setValue(value);
 	}
 
-	
+
 	@Override
 	public void setComponent(MMILComponent mmil)
 	{
 		component = mmil;
 	}
 
-	
+
 	@Override
 	public void setId(String id)
 	{
 		this.id = id;
 	}
 
-	
+
 	@Override
 	public abstract void setType(String type);
-	
 
+
 	@Override
 	public boolean subsumes(MMILEntity entity)
 	{
@@ -339,16 +356,17 @@
 		return true;
 	}
 
-	
+
 	/**
 	 * Compares the index.
 	 */
 	public int compareTo(MMILEntity entity)
 	{
-		return index-entity.getIndex();
+		return index - entity.getIndex();
 	}
-	
-	
+
+
+	@Override
 	public MMILEntity copy()
 	{
 		if (this instanceof MMILParticipant)
@@ -357,28 +375,35 @@
 			return new DefaultMMILEvent(this);
 		else return null;
 	}
-	
-	
+
+
 	@Override
 	public boolean hasId()
 	{
 		return id != null && !id.equals("");
 	}
 
+
+	@Override
 	public String toString()
 	{
-		StringBuilder ret = new StringBuilder(getMMILType()).append(" "+id).append("\n");
+		StringBuilder ret = new StringBuilder();
+		if (index != -1)
+			ret.append(index + " ");
+		ret.append(getMMILType()).append(" " + id).append("\n");
 		for(MMILFeature feat : features)
 			ret.append(feat).append("\n");
 		return ret.toString();
 	}
 
+
 	@Override
 	public void addFeature(String namespace, String name, String value)
 	{
-		add(new DefaultMMILFeature(namespace, name, value));	
+		add(new DefaultMMILFeature(namespace, name, value));
 	}
 
+
 	@Override
 	public void addFeature(String name, String value)
 	{

Modified: trunk/src/fr/loria/talaris/mmil/DefaultMMILRelation.java
===================================================================
--- trunk/src/fr/loria/talaris/mmil/DefaultMMILRelation.java	2010-12-14 15:55:13 UTC (rev 74)
+++ trunk/src/fr/loria/talaris/mmil/DefaultMMILRelation.java	2010-12-14 18:30:51 UTC (rev 75)
@@ -74,13 +74,13 @@
 		this.index = rel.getIndex();
 	}
 	
-	
+	@Override
 	public int getIndex()
 	{
 		return index;
 	}
 
-
+	@Override
 	public void setIndex(int index)
 	{
 		this.index = index;
@@ -162,9 +162,9 @@
 		this.name = type;
 	}
 	
+	@Override
 	public String toString()
 	{
-		return name+" "+(source==null ? null : source.getId())+" "+(target==null ? null : target.getId());
+		return (name.equals("") ? "" : name)+" "+(source==null ? null : source.getId())+" "+(target==null ? null : target.getId());
 	}
-
 }




More information about the Mmil-commits mailing list