From eb2e882736f43a9a6a987e0797d52068f824e547 Mon Sep 17 00:00:00 2001
From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr>
Date: Sun, 2 Jul 2017 21:15:54 +0200
Subject: [PATCH] Update on XML generation

---
 src/main/java/tmltranslator/TMLActivity.java  |  9 +++
 src/main/java/tmltranslator/TMLAttribute.java | 69 ++++++++++---------
 src/main/java/tmltranslator/TMLTask.java      |  9 +++
 3 files changed, 55 insertions(+), 32 deletions(-)

diff --git a/src/main/java/tmltranslator/TMLActivity.java b/src/main/java/tmltranslator/TMLActivity.java
index fe10080597..b71a29d91a 100755
--- a/src/main/java/tmltranslator/TMLActivity.java
+++ b/src/main/java/tmltranslator/TMLActivity.java
@@ -562,4 +562,13 @@ public class TMLActivity extends TMLElement {
             removeEmptyInfiniteLoop();
         }
     }
+
+    public String toXML() {
+	String s = new String("<ACTIVITY first=\"" + elements.indexOf(first) + "\">\n");
+	for(TMLActivityElement elt: elements) {
+	}
+	return s;
+    }
+
+    
 }
diff --git a/src/main/java/tmltranslator/TMLAttribute.java b/src/main/java/tmltranslator/TMLAttribute.java
index d6a1e01ee8..d019bb842a 100755
--- a/src/main/java/tmltranslator/TMLAttribute.java
+++ b/src/main/java/tmltranslator/TMLAttribute.java
@@ -1,27 +1,27 @@
 /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
- * 
+ *
  * ludovic.apvrille AT enst.fr
  * andrea.enrici AT enst.fr
- * 
+ *
  * This software is a computer program whose purpose is to allow the
  * edition of TURTLE analysis, design and deployment diagrams, to
  * allow the generation of RT-LOTOS or Java code from this diagram,
  * and at last to allow the analysis of formal validation traces
  * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
  * from INRIA Rhone-Alpes.
- * 
+ *
  * This software is governed by the CeCILL  license under French law and
  * abiding by the rules of distribution of free software.  You can  use,
  * modify and/ or redistribute the software under the terms of the CeCILL
  * license as circulated by CEA, CNRS and INRIA at the following URL
  * "http://www.cecill.info".
- * 
+ *
  * As a counterpart to the access to the source code and  rights to copy,
  * modify and redistribute granted by the license, users are provided only
  * with a limited warranty  and the software's author,  the holder of the
  * economic rights,  and the successive licensors  have only  limited
  * liability.
- * 
+ *
  * In this respect, the user's attention is drawn to the risks associated
  * with loading,  using,  modifying and/or developing or reproducing the
  * software by the user in light of its specific status of free software,
@@ -32,7 +32,7 @@
  * requirements in conditions enabling the security of their systems and/or
  * data to be ensured and,  more generally, to use and operate it in the
  * same conditions as regards security.
- * 
+ *
  * The fact that you are presently reading this means that you have had
  * knowledge of the CeCILL license and that you accept its terms.
  */
@@ -140,30 +140,35 @@ public class TMLAttribute extends DIPLOElement {
     }
 
     @Override public boolean equals( Object o )        {
-			if( !(o instanceof TMLAttribute ) )	{
-				return false;
-			}
-			else	{
-				TMLAttribute attr = (TMLAttribute)o;
-				return ( name.equals( attr.getName() ) && ( type.equals( attr.getType()) ) );
-			}
-      //return ( (name.equals( _other.getName() )) && ( initialValue.equals( _other.getInitialValue() )) && (type.equals( _other.getType() )) );
-    }
-
-		@Override public int hashCode()	{
-			int result = 17;
-			if( name == null )	{
-				result = 31 * result;
-			}
-			else	{
-				result = 31 * result + name.hashCode();
-			}
-			if( type == null )	{
-				result = 31 * result;
-			}
-			else	{
-				result = 31 * result + type.hashCode();
-			}
-			return result;
-		}
+        if( !(o instanceof TMLAttribute ) )     {
+            return false;
+        }
+        else    {
+            TMLAttribute attr = (TMLAttribute)o;
+            return ( name.equals( attr.getName() ) && ( type.equals( attr.getType()) ) );
+        }
+        //return ( (name.equals( _other.getName() )) && ( initialValue.equals( _other.getInitialValue() )) && (type.equals( _other.getType() )) );
+    }
+
+    @Override public int hashCode()     {
+        int result = 17;
+        if( name == null )      {
+            result = 31 * result;
+        }
+        else    {
+            result = 31 * result + name.hashCode();
+        }
+        if( type == null )      {
+            result = 31 * result;
+        }
+        else    {
+            result = 31 * result + type.hashCode();
+        }
+        return result;
+    }
+
+    public String toXML() {
+	String s = "<ATTRIBUTE type=\"" + type.getType() + "\" name=\"" + name + "\" initialValue=\"" + initialValue + "\"/>\n";
+	return s;
+    }
 }//End of class
diff --git a/src/main/java/tmltranslator/TMLTask.java b/src/main/java/tmltranslator/TMLTask.java
index 67d8cbd368..f81e4c00ad 100755
--- a/src/main/java/tmltranslator/TMLTask.java
+++ b/src/main/java/tmltranslator/TMLTask.java
@@ -378,4 +378,13 @@ public class TMLTask extends TMLElement {
     public void removeEmptyInfiniteLoop() {
     	activity.removeEmptyInfiniteLoop();
     }
+
+    public String toXML() {
+	String s = new String("<TASK name=\"" + name + "\" priority=\"" + priority + "\" >\n");
+	for(TMLAttribute attr: attributes) {
+	    s += attr.toXML();
+	}
+	s += "</TASK>\n";
+	return s;
+    }
 }
-- 
GitLab