$
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								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 | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								Rapport_SAE.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Rapport_SAE.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Exception/JsonSyntaxException.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Exception/JsonSyntaxException.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/ArrayObjectListener.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/ArrayObjectListener.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/Frame.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/Frame.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/GraphicFile.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/GraphicFile.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/Line.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/Line.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/MyJLabel.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/MyJLabel.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/MyJPanel.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Graphics/MyJPanel.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Main.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Main.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Settings/Parameters.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Settings/Parameters.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Node.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Node.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Other.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Other.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Tree.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Tree.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Type.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Type.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Value.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/fr/sae/JSonInspector/Storage/Value.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -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"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -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); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user