Skip to content

Commit

Permalink
#37 \n non souhaité
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelFOURQUET committed Mar 12, 2013
1 parent a8f82b7 commit 88f4630
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 26 deletions.
37 changes: 24 additions & 13 deletions projet/src/main/java/xmltojson/jsonWriter/ToJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ public Map toJson(Element element) {
// i : compteur elem courant
int i = 0;
for (Element children : childrens) {
if (children.getName().equals("answer")) {
System.out.println("Debug");
// Point arret debug
}
// if (children.getName().equals("answer")) {
// System.out.println("Debug");
// // Point arret debug
// }

if (!isDone.contains(children.getName())) { //non traité si deja fait
//CARE les fils identiques a gerer en Array doivent se suivre.
Expand All @@ -130,6 +130,7 @@ public Map toJson(Element element) {
courante.put(children.getName(), toJson(children));
} else {
String text = children.getValue();
text = text.replaceAll("[\n]+", "");//*************
if (!text.equals("")) {
courante.put(children.getName(), text);
} else { courante.put(children.getName(), null); }
Expand All @@ -140,6 +141,7 @@ public Map toJson(Element element) {
}
} else {
String text = element.getValue();
text = text.replaceAll("[\n]+", "");//*************
if (!text.equals("")) {
courante.put(element.getName(), text);
} else { courante.put(element.getName(), null); }
Expand Down Expand Up @@ -180,6 +182,7 @@ public Map toJsonContenu(Element element) {
courante.put(children.getName(), toJson(children));
} else {
String text = children.getValue();
text = text.replaceAll("[\n]+", "");//*************
if (!text.equals("")) {
courante.put(children.getName(), text);
} else { courante.put(children.getName(), null); }
Expand All @@ -188,6 +191,7 @@ public Map toJsonContenu(Element element) {
}
} else {
String text = element.getValue();
text = text.replaceAll("[\n]+", "");//*****************
if (!text.equals("")) {
courante.put(text, null);
} //else { courante.put(element.getName(), null); }
Expand Down Expand Up @@ -282,17 +286,24 @@ public boolean addAttributes(Element e) {
* @param args arguments du main
*/
public static void main(String[] args) {
ToJson tj = new ToJson("src/test/resources/USE_TrueFalse_AUTOGEN.json");
tj.toJson("src/test/resources/USE_TrueFalse_RSC.xml");

ToJson tj2 = new ToJson("src/test/resources/USE_exemple_AUTOGEN.json");
tj2.toJson("src/test/resources/USE_Exemple_RSC.xml");

ToJson tj3 = new ToJson("src/test/resources/USE_TestLimite_AUTOGEN.json");
tj3.toJson("src/test/resources/USE_TestLimite_RSC.xml");
// ToJson tj = new ToJson("src/test/resources/USE_TrueFalse_AUTOGEN.json");
// tj.toJson("src/test/resources/USE_TrueFalse_RSC.xml");
//
// ToJson tj2 = new ToJson("src/test/resources/USE_exemple_AUTOGEN.json");
// tj2.toJson("src/test/resources/USE_Exemple_RSC.xml");
//
// ToJson tj3 = new ToJson("src/test/resources/USE_TestLimite_AUTOGEN.json");
// tj3.toJson("src/test/resources/USE_TestLimite_RSC.xml");
//
ToJson tj4 = new ToJson("src/test/resources/USE_XmlWriterTest_AUTOGEN.json");
tj4.toJson("src/test/resources/USE_XmlWriterTest_RSC.xml");
tj4.toJson("src/test/resources/USE_XmlWriterTest_RSC.xml");
// String s = new String("\nTest\n");
// System.out.println(s);
// //s.replace("\\n", "");
// //s.trim();
// //s = s.replace(/[\n]/gi, "" );
// s = s.replaceAll("[\n]+", "");
// System.out.println(s);
}

}
6 changes: 3 additions & 3 deletions projet/src/test/resources/USE_XmlWriterTest_AUTOGEN.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"answer": [
{
"fraction": "-100",
"text": "\nUne architecture MVC\n ",
"feedback": {"text": "\nUne application non distribuée peut implémentée MVC.\n "}
"text": "Une architecture MVC ",
"feedback": {"text": "Une application non distribuée peut implémentée MVC. "}
},
{
"fraction": "100",
"text": "\nUne architecture N tiers ou N vaut 3\n "
"text": "Une architecture N tiers ou N vaut 3 "
}
]
}}}
20 changes: 10 additions & 10 deletions projet/src/test/resources/USE_exemple_AUTOGEN.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@
"answer": [
{
"fraction": "-100",
"text": "\nUne architecture MVC\n ",
"text": "Une architecture MVC ",
"feedback": {"text": "\nUne application non distribuée peut implémentée MVC.\n "}
},
{
"fraction": "100",
"text": "\nUne architecture N tiers ou N vaut 3\n ",
"text": "Une architecture N tiers ou N vaut 3 ",
"feedback": {"text": "\n\n "}
}
]
Expand Down Expand Up @@ -214,22 +214,22 @@
"answer": [
{
"fraction": "0",
"text": "\nUne architecture N-tiers est uniquement une architecture à base de Web Services\n ",
"text": "Une architecture N-tiers est uniquement une architecture à base de Web Services ",
"feedback": {"text": "\nUne architecture distribuée peut reposer par exemple sur RMI\n "}
},
{
"fraction": "33.333",
"text": "\nUne architecture client serveur est une architecture N-tiers\n ",
"text": "Une architecture client serveur est une architecture N-tiers ",
"feedback": {"text": "\n\n "}
},
{
"fraction": "33.333",
"text": "\nUne architecture N-tiers correspond à une architecture d'application distribuée sur plusieurs noeuds physiques\n ",
"text": "Une architecture N-tiers correspond à une architecture d'application distribuée sur plusieurs noeuds physiques ",
"feedback": {"text": "\n\n "}
},
{
"fraction": "33.333",
"text": "\nUne application web est une application reposant sur une architecture N Tiers\n ",
"text": "Une application web est une application reposant sur une architecture N Tiers ",
"feedback": {"text": "\n\n "}
}
]
Expand Down Expand Up @@ -271,12 +271,12 @@
"answer": [
{
"fraction": "100",
"text": "\nModel View Controller\n ",
"text": "Model View Controller ",
"feedback": {"text": "\n\n "}
},
{
"fraction": "100",
"text": "\nModèle vue contrôleur\n ",
"text": "Modèle vue contrôleur ",
"feedback": {"text": "\n\n "}
}
]
Expand All @@ -298,12 +298,12 @@
"answer": [
{
"fraction": "100",
"text": "\nSimula 66\n ",
"text": "Simula 66 ",
"feedback": {"text": "\nParfait !\n "}
},
{
"fraction": "75",
"text": "\nSimula\n ",
"text": "Simula ",
"feedback": {"text": "\nOui, plus précisément Simula 66\n "}
}
]
Expand Down

0 comments on commit 88f4630

Please sign in to comment.