diff --git a/Makefile b/Makefile index d157d77..b2ee930 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ run: make clean mkdir build/ && mkdir docs/ ${JAVAC} ${JAVAC_OPTIONS} ${SETTINGS} ${GRAPHICS} ${STORAGE} ${EXCEPTION} ${MAIN} - cd build && java fr.sae.JSonInspector.Main /home/bilal-linux/toFormat.json && cd .. + cd build && java fr.sae.JSonInspector.Main && cd .. clean: rm -rf build && rm -rf docs diff --git a/Rapport_SAE.pdf b/Rapport_SAE.pdf new file mode 100644 index 0000000..1b4fba7 Binary files /dev/null and b/Rapport_SAE.pdf differ diff --git a/build/fr/sae/JSonInspector/Exception/JsonSyntaxException.class b/build/fr/sae/JSonInspector/Exception/JsonSyntaxException.class new file mode 100644 index 0000000..46e313e Binary files /dev/null and b/build/fr/sae/JSonInspector/Exception/JsonSyntaxException.class differ diff --git a/build/fr/sae/JSonInspector/Graphics/ArrayObjectListener.class b/build/fr/sae/JSonInspector/Graphics/ArrayObjectListener.class new file mode 100644 index 0000000..9f64b19 Binary files /dev/null and b/build/fr/sae/JSonInspector/Graphics/ArrayObjectListener.class differ diff --git a/build/fr/sae/JSonInspector/Graphics/Frame.class b/build/fr/sae/JSonInspector/Graphics/Frame.class new file mode 100644 index 0000000..13bb1a7 Binary files /dev/null and b/build/fr/sae/JSonInspector/Graphics/Frame.class differ diff --git a/build/fr/sae/JSonInspector/Graphics/GraphicFile.class b/build/fr/sae/JSonInspector/Graphics/GraphicFile.class new file mode 100644 index 0000000..0e75b79 Binary files /dev/null and b/build/fr/sae/JSonInspector/Graphics/GraphicFile.class differ diff --git a/build/fr/sae/JSonInspector/Graphics/Line.class b/build/fr/sae/JSonInspector/Graphics/Line.class new file mode 100644 index 0000000..490d5bb Binary files /dev/null and b/build/fr/sae/JSonInspector/Graphics/Line.class differ diff --git a/build/fr/sae/JSonInspector/Graphics/MyJLabel.class b/build/fr/sae/JSonInspector/Graphics/MyJLabel.class new file mode 100644 index 0000000..c2bb386 Binary files /dev/null and b/build/fr/sae/JSonInspector/Graphics/MyJLabel.class differ diff --git a/build/fr/sae/JSonInspector/Graphics/MyJPanel.class b/build/fr/sae/JSonInspector/Graphics/MyJPanel.class new file mode 100644 index 0000000..c0f1727 Binary files /dev/null and b/build/fr/sae/JSonInspector/Graphics/MyJPanel.class differ diff --git a/build/fr/sae/JSonInspector/Main.class b/build/fr/sae/JSonInspector/Main.class new file mode 100644 index 0000000..8c98d40 Binary files /dev/null and b/build/fr/sae/JSonInspector/Main.class differ diff --git a/build/fr/sae/JSonInspector/Settings/Parameters.class b/build/fr/sae/JSonInspector/Settings/Parameters.class new file mode 100644 index 0000000..f70d776 Binary files /dev/null and b/build/fr/sae/JSonInspector/Settings/Parameters.class differ diff --git a/build/fr/sae/JSonInspector/Storage/Node.class b/build/fr/sae/JSonInspector/Storage/Node.class new file mode 100644 index 0000000..29b3981 Binary files /dev/null and b/build/fr/sae/JSonInspector/Storage/Node.class differ diff --git a/build/fr/sae/JSonInspector/Storage/Other.class b/build/fr/sae/JSonInspector/Storage/Other.class new file mode 100644 index 0000000..2345db5 Binary files /dev/null and b/build/fr/sae/JSonInspector/Storage/Other.class differ diff --git a/build/fr/sae/JSonInspector/Storage/Tree.class b/build/fr/sae/JSonInspector/Storage/Tree.class new file mode 100644 index 0000000..0ea4db4 Binary files /dev/null and b/build/fr/sae/JSonInspector/Storage/Tree.class differ diff --git a/build/fr/sae/JSonInspector/Storage/Type.class b/build/fr/sae/JSonInspector/Storage/Type.class new file mode 100644 index 0000000..10ffa47 Binary files /dev/null and b/build/fr/sae/JSonInspector/Storage/Type.class differ diff --git a/build/fr/sae/JSonInspector/Storage/Value.class b/build/fr/sae/JSonInspector/Storage/Value.class new file mode 100644 index 0000000..f46d10e Binary files /dev/null and b/build/fr/sae/JSonInspector/Storage/Value.class differ diff --git a/src/fr/sae/JSonInspector/DisplayConsole.java b/src/fr/sae/JSonInspector/DisplayConsole.java deleted file mode 100644 index a45ae81..0000000 --- a/src/fr/sae/JSonInspector/DisplayConsole.java +++ /dev/null @@ -1,112 +0,0 @@ -package fr.sae.JSonInspector; - -import java.net.URL; -import java.io.InputStream; -import java.io.IOException; - -public class DisplayConsole { - private URL jsonFile; - - public DisplayConsole(URL jsonFile) { - this.jsonFile = jsonFile; - - if (this.Display() == null) { - System.out.println("[!] Probleme lors du formatage de : " + this.jsonFile.getFile()); - } else { - System.out.println(this.Display()); - } - } - - public String Display() { - try { - InputStream jsonReader = this.jsonFile.openStream(); - StringBuilder containerJsonFormatted = new StringBuilder(); - - int indentLevel = 0; - boolean currentlyInRecord = false; - - int cursor = jsonReader.read(); - - while (cursor != -1) { - char c = (char) cursor; - - switch (c) { - case '{': { - containerJsonFormatted.append(c); - - if (!currentlyInRecord) { - containerJsonFormatted.append("\n"); - indentLevel++; - this.addIndentation(containerJsonFormatted, indentLevel); - } - break; - } - case '[': { - containerJsonFormatted.append(c); - if (!currentlyInRecord) { - containerJsonFormatted.append("\n"); - indentLevel++; - this.addIndentation(containerJsonFormatted, indentLevel); - } - break; - } - case '"': { - currentlyInRecord = !currentlyInRecord; - containerJsonFormatted.append(c); - break; - } - case ':': { - containerJsonFormatted.append(c).append(" "); - break; - } - case ',': { - containerJsonFormatted.append(c); - if (!currentlyInRecord) { - containerJsonFormatted.append("\n"); - this.addIndentation(containerJsonFormatted, indentLevel); - } - break; - } - case ']': { - if (!currentlyInRecord) { - containerJsonFormatted.append("\n"); - indentLevel--; - this.addIndentation(containerJsonFormatted, indentLevel); - } - - containerJsonFormatted.append(c); - break; - } - case '}': { - if (!currentlyInRecord) { - containerJsonFormatted.append("\n"); - indentLevel--; - this.addIndentation(containerJsonFormatted, indentLevel); - } - containerJsonFormatted.append(c); - break; - } - - default: { - containerJsonFormatted.append(c); - break; - } - } - - cursor = jsonReader.read(); - } - - jsonReader.close(); - return containerJsonFormatted.toString(); - } catch (IOException e) { - System.out.println("[!] Fichier " + this.jsonFile.getFile() + " n'existe pas"); - return null; - } - } - - public void addIndentation(StringBuilder sb, int indentLevel) { - for (int i = 0; i < indentLevel; i++) { - sb.append("\t"); - } - } -} \ No newline at end of file diff --git a/src/fr/sae/JSonInspector/Main.java b/src/fr/sae/JSonInspector/Main.java index 5825dbf..7da8753 100644 --- a/src/fr/sae/JSonInspector/Main.java +++ b/src/fr/sae/JSonInspector/Main.java @@ -1,6 +1,9 @@ package fr.sae.JSonInspector; +import fr.sae.JSonInspector.Exception.JsonSyntaxException; import fr.sae.JSonInspector.Graphics.Frame; +import fr.sae.JSonInspector.Storage.Tree; + import java.io.*; import java.net.MalformedURLException; import java.net.URL; @@ -12,10 +15,15 @@ public class Main { } else { try { URL url = new File(args[0]).toURI().toURL(); - new DisplayConsole(url); + String toSend = getJsonInOneLine(url); + Tree receive = new Tree(toSend); + System.out.println(receive); } catch (MalformedURLException e) { System.err.println("[!] Chemin du fichier invalide"); System.exit(1); + } catch (JsonSyntaxException e) { + System.err.println("[!] Syntaxe du fichier JSON invalide"); + System.exit(1); } } }