From 068f0f3b50b79fff12c3df576a9e8bfb401144cb Mon Sep 17 00:00:00 2001 From: "pro.boooooo" Date: Sun, 15 Jan 2023 20:08:18 +0100 Subject: [PATCH] $ --- build/Console/DisplayConsole.class | Bin 2217 -> 0 bytes build/Core.class | Bin 841 -> 0 bytes build/Graphics/GraphicFile.class | Bin 3391 -> 0 bytes build/Graphics/GraphicsCore.class | Bin 5153 -> 0 bytes build/Graphics/Traitable.class | Bin 4634 -> 0 bytes build/Graphics/Type/Array.class | Bin 3764 -> 0 bytes build/Graphics/Type/Bool.class | Bin 1197 -> 0 bytes build/Graphics/Type/Chaine.class | Bin 1039 -> 0 bytes build/Graphics/Type/Entier.class | Bin 1063 -> 0 bytes build/Graphics/Type/Flottant.class | Bin 1066 -> 0 bytes build/Graphics/Type/Type.class | Bin 416 -> 0 bytes .../ArrayObjectListener.java | 74 +-- src/Console/DisplayConsole.java | 117 ---- src/Core.java | 24 - .../CoreJSONDescriptor.java | 0 src/{JsonInspector => }/Frame.java | 310 ++++----- src/{JsonInspector => }/GraphicFile.java | 568 ++++++++--------- src/Graphics/GraphicFile.java | 89 --- src/Graphics/GraphicsCore.java | 172 ----- src/Graphics/Traitable.java | 221 ------- src/Graphics/Type/Array.java | 114 ---- src/Graphics/Type/Bool.java | 47 -- src/Graphics/Type/Chaine.java | 43 -- src/Graphics/Type/Entier.java | 43 -- src/Graphics/Type/Flottant.java | 43 -- src/Graphics/Type/Type.java | 36 -- .../JsonSyntaxException.java | 18 +- src/{JsonInspector => }/Line.java | 184 +++--- src/{JsonInspector => }/Main.java | 0 src/{JsonInspector => }/MyJLabel.java | 36 +- src/{JsonInspector => }/MyJPanel.java | 48 +- src/{JsonInspector => }/Node.java | 230 +++---- src/{JsonInspector => }/Other.java | 32 +- src/{JsonInspector => }/Parameters.java | 40 +- src/{JsonInspector => }/Tree.java | 586 +++++++++--------- src/{JsonInspector => }/Type.java | 10 +- src/{JsonInspector => }/Value.java | 88 +-- toFormat.json | 2 +- 38 files changed, 1113 insertions(+), 2062 deletions(-) delete mode 100644 build/Console/DisplayConsole.class delete mode 100644 build/Core.class delete mode 100644 build/Graphics/GraphicFile.class delete mode 100644 build/Graphics/GraphicsCore.class delete mode 100644 build/Graphics/Traitable.class delete mode 100644 build/Graphics/Type/Array.class delete mode 100644 build/Graphics/Type/Bool.class delete mode 100644 build/Graphics/Type/Chaine.class delete mode 100644 build/Graphics/Type/Entier.class delete mode 100644 build/Graphics/Type/Flottant.class delete mode 100644 build/Graphics/Type/Type.class rename src/{JsonInspector => }/ArrayObjectListener.java (95%) delete mode 100644 src/Console/DisplayConsole.java delete mode 100644 src/Core.java rename src/{JsonInspector => }/CoreJSONDescriptor.java (100%) rename src/{JsonInspector => }/Frame.java (96%) rename src/{JsonInspector => }/GraphicFile.java (96%) delete mode 100644 src/Graphics/GraphicFile.java delete mode 100644 src/Graphics/GraphicsCore.java delete mode 100644 src/Graphics/Traitable.java delete mode 100644 src/Graphics/Type/Array.java delete mode 100644 src/Graphics/Type/Bool.java delete mode 100644 src/Graphics/Type/Chaine.java delete mode 100644 src/Graphics/Type/Entier.java delete mode 100644 src/Graphics/Type/Flottant.java delete mode 100644 src/Graphics/Type/Type.java rename src/{JsonInspector => }/JsonSyntaxException.java (96%) rename src/{JsonInspector => }/Line.java (95%) rename src/{JsonInspector => }/Main.java (100%) rename src/{JsonInspector => }/MyJLabel.java (95%) rename src/{JsonInspector => }/MyJPanel.java (96%) rename src/{JsonInspector => }/Node.java (95%) rename src/{JsonInspector => }/Other.java (92%) rename src/{JsonInspector => }/Parameters.java (97%) rename src/{JsonInspector => }/Tree.java (96%) rename src/{JsonInspector => }/Type.java (94%) rename src/{JsonInspector => }/Value.java (95%) diff --git a/build/Console/DisplayConsole.class b/build/Console/DisplayConsole.class deleted file mode 100644 index 4700b3c2719d47f2f966293f5d096de07c70bec1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2217 zcmaJ?Uu;uV82_EN>upQfO1EyXvC-jx{ew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EatUm4mDRKQdL~k8|aruZVlNbLW=`4TK|A9+X!9 zU1xW=a_9!RRzM?epapgX0$KbNF7X80NZ>v6<6_<3=6`_xuR+CIylnfqZlvY__hOZC F_qo3;8sfvWZeVM>yV;!@`6tFF z-+0D{HnB;6fIrH3r!7GuyUCroXU@I%%)Rsb&#xhX$9Sq?8uJ_r95*zCv8c?FhMUM~ z2qDk0oWL#I)^G-U>UJ8I z|4ua8ghV>Rb{OUg2WCrr5k^}$hel2MwsW|p0;g(HG(W!--h{8!+^*lW_G}fLsJgyY zR&hEq$WofB>jZAwGIs31Ym4KF%b<^v+peJk6?t99U6eTt9rv)IkWGe}a|yd&o0cbS z*WtLY;{hIWJkqH-PZ(yO`@%c2n}Kn*Q8E}-5Aq*#`_gXPfl!gpa%H0xxXzyIcZ8Id zpR0I69&M{M>!X&asOj^XuNy6^DXBo=@?J!xyZ`nDg%pZof@4X8kgc=(O?-wC)BKNV z5;HSNKIWRECjXM8s~)@jITw7 zkVl%Hmij^}X>?6`cw1-$9{KE-W%%4cC^`M<#p)~xC)BwqPA37Z+=_EVVL+X^0#;`=X;*?aC tEI}iy6PhACGg7=vnv3emklqavQ6V`yxJo}rT10TfwKS(x*9ZvV`d`@KwsQag diff --git a/build/Graphics/GraphicFile.class b/build/Graphics/GraphicFile.class deleted file mode 100644 index ef767ed3148f38524ed96d2f9af5d4d480b45195..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3391 zcmai1Yfu~475=V}bj7j=5XNM2V#|*0@UT(yvQv>bHpF1L0vuzT2uj*T+Q1sItFBfy zICWofA8DFC$(rhhBj*!Z9i#BJd)3rx?b>@F2&#LU^}?W~jn!TtYX}HON4# zK@T1h!vx19hb|$ClMygvIi@At3`3kU#i^V)^&SpOLLRn+0#1c+x(2P75yNZB9b{5floO32t)90-O%lQ3=OTxljXN#l4HTxwHS3r-#Jsz^Q>Va}(S^r2J|W|Ae3JINP1DZXWYn+OlV&Dg7sRJR__U1A;IkZ` zl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cjaWUJ>a1~qP)g@=ql;1y(t-_t81e-Vk2wbIl z5!(O)kJl(QOSn1JfJ^lwl*#rYb|{ikQ^d|;#jjKsam!V-7SUEjd!*xe#GT`njRovt z4vehGE9MK>&4?ZWBnzN9To&OFd2zCH66+-2VykLTZBwoHWQ@`4{%zDwnM-(Ztuxwe zs$IaXKFYDx@%<8R6Iq0n@EQ=Wog0m;goVp1iN4}}*hi{*4Y$&` z8GibRt|ztKNJZF*?dZS`+(EOu=<|3V+Ax524Abfub|H=3IEfg}(Al%N4UgbJU z8GEoyCte}V{(-dmH&W}HxQA6?AKQd`Sq%HxUL0U?bh94xu%oz-<#3Q)L@!%LAA6Oa z-#~)>1&7&R(a-*l0rn;a**|bU`xlO~YZ&r{aopF0VP6YID2oSto00PE#whNkEOdmf z<2ax)K2Z8I9xUaMc q!r5C#y>=ft^x+_WN52x$`Ws65w@{Fv=MA)fnAYCmj8o3|;r{@z4r{;w diff --git a/build/Graphics/GraphicsCore.class b/build/Graphics/GraphicsCore.class deleted file mode 100644 index 28de1b9b9eef69228a0b508e68b8b81a60b5d8dd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5153 zcma)A33yc175;CM$(sz1EF%a3fl(tQlZ1$(VnS&l1PEqAOdt@{(wEE&c`!3CzIh2t zZ7o*CrLDDYRjbxo_qHyTi6zx8cC~i3`@Y!L+P$@VYx|$~-eiVA{rK|b+#kjScC&n z>UFow-WSF_Q7GK4;ob-q<5~f?Xt*ze2Hao4V-E;;P{2cBJS^KE(D1X{$ zB7$}Jq+p-X@Tmwsjn4@9Yy_S7To|91@mT?1(C}OsU)1oWFuoi?556MUuL}5@fagWV z*9Ck-y!uUH`7Ht87VsUxeOG4R)9`%_KTwFS?O3;ZOV{Qd>v~rwI(GDRZtqZ-)wRnQ zH(HE6Zp&ILZDz8TooOR&qO-d*u_bW?ZD`1Fl39h>g){BMbQ$~XF_(ubTyw9x&N5TU zJm0-7**#WfXUoPeW6(^Iq;$+lDO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Xp2s0y0q+utGZke=*o=zJ!ld!E=%umpANcf26 z(V?vQC~F|dt514Y0v|u+QT!Iaqljp4VR20BQ%0X-Cv|tsbcrcDE31<37V@s$+dn266q#1o-J9)VCQkKjdw;=wl&zKBTt5|pF!P%ok)o=5Z*iVNJs{w74& z$9Q-x|8;0WJzDuxi(?Iy@>^3lM7+&IC@BuaUt_|2Z9~DG>k^kksTakLcw*gcc~ssN z3Ur0nhVsxZP%VFtv4!W}IrBG;sVo0@sD|SXh;#qpxF`5etBs=@emZlM{i({1SDZW0SuS+Xl8f z*oN6Gw#VBqq4p>Ze;sx6s9!)s0AsTlC%du0UNeuii|l(}#Z8`*O+@K*xY$A7 z`of-@=h3prZX|m{fxU4aw-nfCgJSmDm3TXIA@dOM^3V?%nI=ZL8LRjfZp6*_GcEoX zHsasR$UE4At4N3-+C?31uX>2#8^TA>1sWj{G@6KQ%473+L}IOTiP#o@Ud?%%KVQZ9R?eS? zmWUBbo^XszqRyMwaNh3E+vj3cb4xCE(J>I$6@15N#C1J!y#{;er9tde5U zigM90zr>Dk%NRb)zI@BJ@+}Wghz|o_^koG3C&VwIgLT$9n22r9jawk64RmNvovKu|4;H D<*1F= diff --git a/build/Graphics/Type/Bool.class b/build/Graphics/Type/Bool.class deleted file mode 100644 index 25036eba087b612c9ec6a63007d6bd672a52b59c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1197 zcmZuw+foxj5IwUYOtLH?2^Tepa#0M45bvmosZzweM5rPZ558@}8W-0j6*gFWieKQX zT7s4jet;jPp4nZSneH=ZdQSKJ`TOfPfOQmgjA1zn9k+DMARWaDGHRPutJ^wO zu@*s2r{|8uU5R@V_XWa7rqi(mCd&urk(qPMMm_hU*>o(kk!Q5lbee5}xF0n?y15PI zVQ92qH*B{kFq6LE=*phJ$VPLY%oAn1VQqCjRIT=|S#{_cuefII{cE%3?Ij)vNXI^O zOO`8;Ot1KS9oKepWx9D;v|`sArrT-rban_(D3{u1>z!RY%uFGN+jgT)0!aeJ>Qn9cYEAcHyL$C=Y*!Dgno2+4qfp?y zDCHj18KruHUTJpPHS3kFw2P|9nyQt71Rfd~N6f$@tV=vL@C0!K6UsbATq19vfMl(q@Cn$-$MY4 znI90D>Qe<1eGzYlX{?VaH z=#n3gXn{+(%$wAWDeeSkO?;tcm(eN&aD_wVsSvZcN~`d5oK-ZO`Ht}5k!uXiL0JWz z=d7R+LbacegXkqjub-o519T`E83d*oVq?$_W}pp1SL4qKT^xd*B031w`8NNBOSr)_ HHQf9U^(pOM diff --git a/build/Graphics/Type/Chaine.class b/build/Graphics/Type/Chaine.class deleted file mode 100644 index 929530c4e7a835b4518594a8e88a10bc5591060b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1039 zcmZuvZBNr+6g}-;x{kUxnJ=IMinw)3eTgxVWrmr?XZM`@{Q7-<0pJy0l%ZlxMG5y+Jixm6^{|W$JSw48=B2Gb zSI|-LSVG~%bOK94V{mMqn1*Az6JzLmwmaEkaXfXVo`hOdG(Y)9Uu0M+c5T=8dlH(h ztDWrw3Hko?ki6A_?OMCR$C2gjn#Kb=`&=<2<#9y?1D%MZs(FegV=4(<8OF;68d{^d=}RY)LMBdUYQ zm^5~8bZm{qn6DG6M4iSfY-!84(fJ^>3BYXfz~^j8x`YVo{Y4eQ6Xo_x|1PPKqTO zovRBU%iaeG8_BK5`r~CLJ;fTIn+ht1%#XVGLS-R|r^0*{HO4w`FGB=S*MC6LJ7gU~C}ISYfP^w8pQ_%5^NVRZuMPCh?S|&x}z|G0Zg46nWg>?Ivz93jAH3 z0$o;(vlGZ!XuI}?P%&g0 S`W;FZD(sCE-or|$boCFoD$6qf diff --git a/build/Graphics/Type/Entier.class b/build/Graphics/Type/Entier.class deleted file mode 100644 index 2e85271ff5cdb0a838d9894d90606e823dc4accd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1063 zcmZuvZBNrs7(KV!=r-!!VEBTFDB{*B^)-IjvP20Il0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i(>U?FGr>$q-${urD!8;-WUGd{&xbyN%O*Gd;!V+cQl6 xH?ub#F)$2hmw+>5IKvR2+rfx*PU-+-`n#C4`gvEsz~!-iMa-VO#"); - } - } -} \ No newline at end of file diff --git a/src/JsonInspector/CoreJSONDescriptor.java b/src/CoreJSONDescriptor.java similarity index 100% rename from src/JsonInspector/CoreJSONDescriptor.java rename to src/CoreJSONDescriptor.java diff --git a/src/JsonInspector/Frame.java b/src/Frame.java similarity index 96% rename from src/JsonInspector/Frame.java rename to src/Frame.java index cf203f0..978e180 100644 --- a/src/JsonInspector/Frame.java +++ b/src/Frame.java @@ -1,155 +1,155 @@ -package JsonInspector; - -import javax.swing.*; -import java.awt.*; -import java.io.FileNotFoundException; -import java.net.MalformedURLException; -import java.net.URL; - -public class Frame extends JFrame { - private static final Dimension DEFAULT_FRAME_SIZE = new Dimension(800, 600); - private static final Dimension MINIMUM_FRAME_SIZE = new Dimension(600, 500); - private final CardLayout cards = new CardLayout(); - private boolean showTab = true; - private JPanel secondCard; - private GraphicFile file; - private Tree tree; - - - public Frame() { - super("Inspecteur JSON"); - init(); - this.setVisible(true); - } - - - private void init() { - this.setSize(DEFAULT_FRAME_SIZE); - this.setDefaultCloseOperation(EXIT_ON_CLOSE); - this.setMinimumSize(MINIMUM_FRAME_SIZE); - this.setLayout(cards); - this.add(firstCard()); - //this.add(secondCard()); - cards.first(this.getContentPane()); - } - - - private JPanel firstCard() { - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - JTextField textField = new JTextField("file:C:\\Users\\Elève\\Desktop\\temp\\jason.json", 30); - JButton button = new JButton("Valider"); - button.addActionListener((event) -> validationAction(textField)); - JPanel panel = new JPanel(); - panel.setLayout(layout); - - gbc.insets = new Insets(10, 10, 10, 10); - gbc.gridx = 0; - gbc.gridy = 0; - JLabel label = new JLabel("URL :"); - label.setForeground(Parameters.DEFAULT_TEXT_COLOR); - panel.add(label, gbc); - - gbc.gridx = 1; - panel.add(textField, gbc); - - gbc.gridx = 0; - gbc.gridy = 1; - gbc.gridwidth = 2; - panel.add(button, gbc); - - panel.setBackground(Parameters.IHM_COLOR); - return panel; - } - - - private JPanel secondCard() { - file = new GraphicFile(this, tree); - return initSecondCard(file); - } - - - private JPanel secondCard(GraphicFile file) { - this.file = file; - return initSecondCard(file); - } - - - private JPanel initSecondCard(GraphicFile file) { - JButton unfoldButton = new JButton("Tout déplier"); - JButton retreatButton = new JButton("Tout replier"); - JButton backButton = new JButton("Retour"); - JPanel mainPanel = new JPanel(), southPanel = new JPanel(); - JScrollPane scroll = new JScrollPane(); - mainPanel.setLayout(new BorderLayout()); - - southPanel.setBackground(Parameters.IHM_COLOR); - southPanel.add(backButton); - backButton.addActionListener((event) -> backAction(mainPanel)); - southPanel.add(unfoldButton); - unfoldButton.addActionListener((event) -> unfoldAction()); - southPanel.add(retreatButton); - retreatButton.addActionListener((event) -> retreatAction()); - southPanel.add(new JButton("convertir en PHP")); - - mainPanel.add(file); - mainPanel.add(southPanel, BorderLayout.SOUTH); - mainPanel.add(scroll); - - scroll.setViewportView(file); - return mainPanel; - } - - - private void unfoldAction() { - file.showAll(); - repaintFile(); - } - - - private void retreatAction() { - file.retreatAll(); - repaintFile(); - } - - - public void repaintFile() { - file = new GraphicFile(this, file.getLines()); - this.remove(secondCard); - secondCard = secondCard(file); - this.add(secondCard); - cards.last(this.getContentPane()); - } - - - private void validationAction(JTextField field) { - try { - URL url = new URL(field.getText()); - String file = Main.getJsonInOneLine(url); - - if (file.length() <= 2) { - throw new FileNotFoundException(); - } - - tree = new Tree(file); - secondCard = secondCard(); - this.add(secondCard); - cards.last(this.getContentPane()); - - } catch (MalformedURLException e) { - JOptionPane.showMessageDialog(this, "URL invalide", "Error", JOptionPane.ERROR_MESSAGE); - - } catch (JsonSyntaxException j) { - JOptionPane.showMessageDialog(this, "Erreur de syntax dans le fichier", "Error", JOptionPane.ERROR_MESSAGE); - - } catch (FileNotFoundException f) { - JOptionPane.showMessageDialog(this, "Impossible trouver le fichier", "Error", JOptionPane.ERROR_MESSAGE); - } - } - - - private void backAction(JPanel panel) { - this.remove(panel); - cards.first(this.getContentPane()); - } -} +package JsonInspector; + +import javax.swing.*; +import java.awt.*; +import java.io.FileNotFoundException; +import java.net.MalformedURLException; +import java.net.URL; + +public class Frame extends JFrame { + private static final Dimension DEFAULT_FRAME_SIZE = new Dimension(800, 600); + private static final Dimension MINIMUM_FRAME_SIZE = new Dimension(600, 500); + private final CardLayout cards = new CardLayout(); + private boolean showTab = true; + private JPanel secondCard; + private GraphicFile file; + private Tree tree; + + + public Frame() { + super("Inspecteur JSON"); + init(); + this.setVisible(true); + } + + + private void init() { + this.setSize(DEFAULT_FRAME_SIZE); + this.setDefaultCloseOperation(EXIT_ON_CLOSE); + this.setMinimumSize(MINIMUM_FRAME_SIZE); + this.setLayout(cards); + this.add(firstCard()); + //this.add(secondCard()); + cards.first(this.getContentPane()); + } + + + private JPanel firstCard() { + GridBagLayout layout = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + JTextField textField = new JTextField("file:C:\\Users\\Elève\\Desktop\\temp\\jason.json", 30); + JButton button = new JButton("Valider"); + button.addActionListener((event) -> validationAction(textField)); + JPanel panel = new JPanel(); + panel.setLayout(layout); + + gbc.insets = new Insets(10, 10, 10, 10); + gbc.gridx = 0; + gbc.gridy = 0; + JLabel label = new JLabel("URL :"); + label.setForeground(Parameters.DEFAULT_TEXT_COLOR); + panel.add(label, gbc); + + gbc.gridx = 1; + panel.add(textField, gbc); + + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 2; + panel.add(button, gbc); + + panel.setBackground(Parameters.IHM_COLOR); + return panel; + } + + + private JPanel secondCard() { + file = new GraphicFile(this, tree); + return initSecondCard(file); + } + + + private JPanel secondCard(GraphicFile file) { + this.file = file; + return initSecondCard(file); + } + + + private JPanel initSecondCard(GraphicFile file) { + JButton unfoldButton = new JButton("Tout déplier"); + JButton retreatButton = new JButton("Tout replier"); + JButton backButton = new JButton("Retour"); + JPanel mainPanel = new JPanel(), southPanel = new JPanel(); + JScrollPane scroll = new JScrollPane(); + mainPanel.setLayout(new BorderLayout()); + + southPanel.setBackground(Parameters.IHM_COLOR); + southPanel.add(backButton); + backButton.addActionListener((event) -> backAction(mainPanel)); + southPanel.add(unfoldButton); + unfoldButton.addActionListener((event) -> unfoldAction()); + southPanel.add(retreatButton); + retreatButton.addActionListener((event) -> retreatAction()); + southPanel.add(new JButton("convertir en PHP")); + + mainPanel.add(file); + mainPanel.add(southPanel, BorderLayout.SOUTH); + mainPanel.add(scroll); + + scroll.setViewportView(file); + return mainPanel; + } + + + private void unfoldAction() { + file.showAll(); + repaintFile(); + } + + + private void retreatAction() { + file.retreatAll(); + repaintFile(); + } + + + public void repaintFile() { + file = new GraphicFile(this, file.getLines()); + this.remove(secondCard); + secondCard = secondCard(file); + this.add(secondCard); + cards.last(this.getContentPane()); + } + + + private void validationAction(JTextField field) { + try { + URL url = new URL(field.getText()); + String file = Main.getJsonInOneLine(url); + + if (file.length() <= 2) { + throw new FileNotFoundException(); + } + + tree = new Tree(file); + secondCard = secondCard(); + this.add(secondCard); + cards.last(this.getContentPane()); + + } catch (MalformedURLException e) { + JOptionPane.showMessageDialog(this, "URL invalide", "Error", JOptionPane.ERROR_MESSAGE); + + } catch (JsonSyntaxException j) { + JOptionPane.showMessageDialog(this, "Erreur de syntax dans le fichier", "Error", JOptionPane.ERROR_MESSAGE); + + } catch (FileNotFoundException f) { + JOptionPane.showMessageDialog(this, "Impossible trouver le fichier", "Error", JOptionPane.ERROR_MESSAGE); + } + } + + + private void backAction(JPanel panel) { + this.remove(panel); + cards.first(this.getContentPane()); + } +} diff --git a/src/JsonInspector/GraphicFile.java b/src/GraphicFile.java similarity index 96% rename from src/JsonInspector/GraphicFile.java rename to src/GraphicFile.java index f6a84f0..2fd87a1 100644 --- a/src/JsonInspector/GraphicFile.java +++ b/src/GraphicFile.java @@ -1,284 +1,284 @@ -package JsonInspector; - -import javax.swing.*; -import java.awt.*; -import java.util.ArrayList; - -public class GraphicFile extends JPanel { - private final GridBagConstraints gbc = new GridBagConstraints(); - private final JPanel alignementPanel = new JPanel(); - private final Frame frame; - private ArrayList lines; - private Node firstNode; - - - public GraphicFile(Frame frame, Tree tree) { - super(); - firstNode = tree.getFirstNode(); - init(); - lines = new ArrayList<>(); - this.frame = frame; - createFileRecursive(firstNode, 0, false); - //displayAllLines(); - displayLines(); - } - - - public GraphicFile(Frame frame, ArrayList lines) { - super(); - init(); - this.frame = frame; - this.lines = lines; - //displayAllLines(); - displayLines(); - } - - - private void init() { - this.setBackground(Parameters.BACKGROUND_COLOR); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - gbc.fill = GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.WEST; - alignementPanel.setLayout(new GridBagLayout()); - this.add(alignementPanel); - } - - - private void createFileRecursive(Node node, int depth, boolean virgule) { - String indentation = ""; - - for (int i = 0; i < depth; i++) { - indentation += Parameters.IHM_INDENTATION; - } - - if (node.isObject() || node.isElement()) { - createObjectElement(node, depth, indentation, virgule); - - } else if (node.isArray()) { - createArray(node, depth, indentation, virgule); - - } else if (node.isPair()) { - createPair(node, depth, indentation, virgule); - } - } - - - private void createPair(Node node, int depth, String indentation, boolean virgule) { - Line line = new Line(node, depth); - line.add(indentation); - line.add("\"" + node.getName() + "\"", Parameters.KEY_COLOR); - line.add(": "); - - if (node.getSize() != 0) { - createValue(line, node.get(0)); - } else { - line.add("null" , Parameters.OTHER_COLOR); - } - - if (virgule) { - line.add(","); - } - - lines.add(line); - } - - - private void createObjectElement(Node node, int depth, String indentation, boolean virgule) { - Line line = new Line(node, depth); - line.add(indentation); - - if (0 < depth && 0 < node.getSize()) { - line.retreat(); - } - - if (node.getType() == Type.ELEMENT) { - line.add("{"); - } else { - line.add("\"" + node.getName() + "\"", Parameters.KEY_COLOR); - line.add(": {"); - } - - if (node.getSize() == 0) { - if (virgule) { - line.add(" },"); - } else { - line.add(" }"); - } - lines.add(line); - - } else { - line.addMouseListener(new ArrayObjectListener(line, frame)); - lines.add(line); - callNextNodes(node, depth); - Line endLine = new Line(node, indentation + "}", depth); - endLine.setClosingElement(); - - if (virgule) { - endLine.add(","); - } - - lines.add(endLine); - } - } - - - private void createArray(Node node, int depth, String indentation, boolean virgule) { - Line line = new Line(node, depth); - line.add(indentation); - - if (0 < depth && 0 < node.getSize()) { - line.retreat(); - } - - line.add("\"" + node.getName() + "\"", Parameters.KEY_COLOR); - line.add(": ["); - - if (node.getSize() == 0) { - if (virgule) { - line.add(" ],"); - } else { - line.add(" ]"); - } - lines.add(line); - } else { - line.addMouseListener(new ArrayObjectListener(line, frame)); - lines.add(line); - - for (int i = 0; i < node.getSize(); i++) { - Line valueLine = new Line(new Node("", Type.NULL), depth + 1); - - if (node.get(i).isNode()) { - callNextNodes(node, depth); - } else { - String valueString = indentation + Parameters.IHM_INDENTATION; - valueLine.add(valueString, Parameters.STRING_COLOR); - createValue(valueLine, node.get(i)); - - if (i != node.getSize() - 1) { - valueLine.add(","); - } - } - - lines.add(valueLine); - } - - Line endLine = new Line(node, indentation + "]", depth); - endLine.setClosingElement(); - - if (virgule) { - endLine.add(","); - } - - lines.add(endLine); - } - } - - - private void createValue(Line line, Value value) { - if (value.isNumber()) { - line.add("" + value.getValue(), Parameters.NUMBER_COLOR); - } else if (value.isString()) { - line.add("\"" + value.getValue() + "\"", Parameters.STRING_COLOR); - } else { - line.add("" + value.getValue(), Parameters.OTHER_COLOR); - } - } - - - private void callNextNodes(Node node, int depth) { - boolean virgule; - - for (int i = 0; i < node.getSize(); i++) { - // si l'élément afficher est le dernier à son niveau "virgule" est faux - // donc il n'y aura pas de virgule en fin ligne - virgule = i != node.getSize() - 1; - - if (node.get(i).isNode()) { - createFileRecursive((Node) node.get(i).getValue(), depth + 1, virgule); - } - } - } - - - private void displayLines() { - boolean inArrayObject = false, array, object; - Node openedArrayObject = lines.get(0).getNode(); - removeAllClosingLabel(); - - for (int i = 0; i < lines.size(); i++) { - if (!inArrayObject) { - array = lines.get(i).getNode().isArray(); - object = lines.get(i).getNode().isObject(); - - // Vérifie si le noeud est du type ARRAY ou du type OBJECT et s'il doit être affiché - if ((array || object) && !lines.get(i).isShow()) { - inArrayObject = true; - openedArrayObject = lines.get(i).getNode(); - - if (openedArrayObject.isArray()) { - displayOneHidedLine(i, Parameters.ARRAY_CLOSING); - } else { - displayOneHidedLine(i, Parameters.OBJECT_ELEMENT_CLOSING); - } - - //Sinon affiche la ligne normalement - } else { - displayOneLine(i); - } - - } else if (lines.get(i).getNode().equals(openedArrayObject)) { - inArrayObject = false; - } - } - } - - - private void displayOneLine(int index) { - gbc.gridy = index; - - gbc.gridx = 0; - alignementPanel.add(lines.get(index), gbc); - } - - - private void displayOneHidedLine(int index, String endOfLine) { - gbc.gridy = index; - - gbc.gridx = 0; - lines.get(index).add(endOfLine); - alignementPanel.add(lines.get(index), gbc); - } - - - public void showAll() { - for (Line line : lines) { - if (!line.isShow()) { - line.removeClosingLabel(); - } - line.unfold(); - } - } - - - public void retreatAll() { - for (Line line : lines) { - if (line.getNode().isArrayObjectElement()) { - if (0 < line.getDepth() && 0 < line.getNode().getSize() && !line.isClosingElement()) { - line.retreat(); - } - } - } - } - - - private void removeAllClosingLabel() { - for(Line line : lines) { - line.removeClosingLabel(); - } - } - - - public ArrayList getLines() { - return lines; - } -} +package JsonInspector; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; + +public class GraphicFile extends JPanel { + private final GridBagConstraints gbc = new GridBagConstraints(); + private final JPanel alignementPanel = new JPanel(); + private final Frame frame; + private ArrayList lines; + private Node firstNode; + + + public GraphicFile(Frame frame, Tree tree) { + super(); + firstNode = tree.getFirstNode(); + init(); + lines = new ArrayList<>(); + this.frame = frame; + createFileRecursive(firstNode, 0, false); + //displayAllLines(); + displayLines(); + } + + + public GraphicFile(Frame frame, ArrayList lines) { + super(); + init(); + this.frame = frame; + this.lines = lines; + //displayAllLines(); + displayLines(); + } + + + private void init() { + this.setBackground(Parameters.BACKGROUND_COLOR); + this.setLayout(new FlowLayout(FlowLayout.LEFT)); + gbc.fill = GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.WEST; + alignementPanel.setLayout(new GridBagLayout()); + this.add(alignementPanel); + } + + + private void createFileRecursive(Node node, int depth, boolean virgule) { + String indentation = ""; + + for (int i = 0; i < depth; i++) { + indentation += Parameters.IHM_INDENTATION; + } + + if (node.isObject() || node.isElement()) { + createObjectElement(node, depth, indentation, virgule); + + } else if (node.isArray()) { + createArray(node, depth, indentation, virgule); + + } else if (node.isPair()) { + createPair(node, depth, indentation, virgule); + } + } + + + private void createPair(Node node, int depth, String indentation, boolean virgule) { + Line line = new Line(node, depth); + line.add(indentation); + line.add("\"" + node.getName() + "\"", Parameters.KEY_COLOR); + line.add(": "); + + if (node.getSize() != 0) { + createValue(line, node.get(0)); + } else { + line.add("null" , Parameters.OTHER_COLOR); + } + + if (virgule) { + line.add(","); + } + + lines.add(line); + } + + + private void createObjectElement(Node node, int depth, String indentation, boolean virgule) { + Line line = new Line(node, depth); + line.add(indentation); + + if (0 < depth && 0 < node.getSize()) { + line.retreat(); + } + + if (node.getType() == Type.ELEMENT) { + line.add("{"); + } else { + line.add("\"" + node.getName() + "\"", Parameters.KEY_COLOR); + line.add(": {"); + } + + if (node.getSize() == 0) { + if (virgule) { + line.add(" },"); + } else { + line.add(" }"); + } + lines.add(line); + + } else { + line.addMouseListener(new ArrayObjectListener(line, frame)); + lines.add(line); + callNextNodes(node, depth); + Line endLine = new Line(node, indentation + "}", depth); + endLine.setClosingElement(); + + if (virgule) { + endLine.add(","); + } + + lines.add(endLine); + } + } + + + private void createArray(Node node, int depth, String indentation, boolean virgule) { + Line line = new Line(node, depth); + line.add(indentation); + + if (0 < depth && 0 < node.getSize()) { + line.retreat(); + } + + line.add("\"" + node.getName() + "\"", Parameters.KEY_COLOR); + line.add(": ["); + + if (node.getSize() == 0) { + if (virgule) { + line.add(" ],"); + } else { + line.add(" ]"); + } + lines.add(line); + } else { + line.addMouseListener(new ArrayObjectListener(line, frame)); + lines.add(line); + + for (int i = 0; i < node.getSize(); i++) { + Line valueLine = new Line(new Node("", Type.NULL), depth + 1); + + if (node.get(i).isNode()) { + callNextNodes(node, depth); + } else { + String valueString = indentation + Parameters.IHM_INDENTATION; + valueLine.add(valueString, Parameters.STRING_COLOR); + createValue(valueLine, node.get(i)); + + if (i != node.getSize() - 1) { + valueLine.add(","); + } + } + + lines.add(valueLine); + } + + Line endLine = new Line(node, indentation + "]", depth); + endLine.setClosingElement(); + + if (virgule) { + endLine.add(","); + } + + lines.add(endLine); + } + } + + + private void createValue(Line line, Value value) { + if (value.isNumber()) { + line.add("" + value.getValue(), Parameters.NUMBER_COLOR); + } else if (value.isString()) { + line.add("\"" + value.getValue() + "\"", Parameters.STRING_COLOR); + } else { + line.add("" + value.getValue(), Parameters.OTHER_COLOR); + } + } + + + private void callNextNodes(Node node, int depth) { + boolean virgule; + + for (int i = 0; i < node.getSize(); i++) { + // si l'élément afficher est le dernier à son niveau "virgule" est faux + // donc il n'y aura pas de virgule en fin ligne + virgule = i != node.getSize() - 1; + + if (node.get(i).isNode()) { + createFileRecursive((Node) node.get(i).getValue(), depth + 1, virgule); + } + } + } + + + private void displayLines() { + boolean inArrayObject = false, array, object; + Node openedArrayObject = lines.get(0).getNode(); + removeAllClosingLabel(); + + for (int i = 0; i < lines.size(); i++) { + if (!inArrayObject) { + array = lines.get(i).getNode().isArray(); + object = lines.get(i).getNode().isObject(); + + // Vérifie si le noeud est du type ARRAY ou du type OBJECT et s'il doit être affiché + if ((array || object) && !lines.get(i).isShow()) { + inArrayObject = true; + openedArrayObject = lines.get(i).getNode(); + + if (openedArrayObject.isArray()) { + displayOneHidedLine(i, Parameters.ARRAY_CLOSING); + } else { + displayOneHidedLine(i, Parameters.OBJECT_ELEMENT_CLOSING); + } + + //Sinon affiche la ligne normalement + } else { + displayOneLine(i); + } + + } else if (lines.get(i).getNode().equals(openedArrayObject)) { + inArrayObject = false; + } + } + } + + + private void displayOneLine(int index) { + gbc.gridy = index; + + gbc.gridx = 0; + alignementPanel.add(lines.get(index), gbc); + } + + + private void displayOneHidedLine(int index, String endOfLine) { + gbc.gridy = index; + + gbc.gridx = 0; + lines.get(index).add(endOfLine); + alignementPanel.add(lines.get(index), gbc); + } + + + public void showAll() { + for (Line line : lines) { + if (!line.isShow()) { + line.removeClosingLabel(); + } + line.unfold(); + } + } + + + public void retreatAll() { + for (Line line : lines) { + if (line.getNode().isArrayObjectElement()) { + if (0 < line.getDepth() && 0 < line.getNode().getSize() && !line.isClosingElement()) { + line.retreat(); + } + } + } + } + + + private void removeAllClosingLabel() { + for(Line line : lines) { + line.removeClosingLabel(); + } + } + + + public ArrayList getLines() { + return lines; + } +} diff --git a/src/Graphics/GraphicFile.java b/src/Graphics/GraphicFile.java deleted file mode 100644 index 3194caa..0000000 --- a/src/Graphics/GraphicFile.java +++ /dev/null @@ -1,89 +0,0 @@ -package Graphics; - -import java.io.InputStream; -import java.io.IOException; -import java.util.HashMap; -import javax.swing.JLabel; -import javax.swing.JPanel; -import Graphics.Type.*; -import java.awt.FlowLayout; -import java.awt.GridLayout; -import java.util.List; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Color; -import java.net.URL; - -/** - * [Romain] - * Pour gerer l'affichage graphique du code JSON - */ - -public class GraphicFile extends JPanel { - /** - * @param url Le chemin vers le fichier JSON - */ - public GraphicFile(URL url) { - super(); - try { - System.out.println("[+] Lecture de " + url); - this.setLayout(new FlowLayout(FlowLayout.LEFT)); - this.setLocation(500, 500); - - InputStream jsonReader = url.openStream(); - Traitable fileTraited = new Traitable(jsonReader); - jsonReader.close(); - - HashMap> allVariables = fileTraited.getVariableMap(); - JPanel core = new JPanel(new GridBagLayout()); - GridBagConstraints settings = new GridBagConstraints(); - settings.gridx = 0; - settings.gridy = 0; - settings.anchor = GridBagConstraints.WEST; - - core.add(new JLabel("{"), settings); - - int rows = 1; - settings.gridy = 1; - settings.gridx = 2; - - for (String key : allVariables.keySet()) { - JPanel fusion = new JPanel(new GridLayout(1, 1)); - - settings.gridy = rows; - - JLabel name = new JLabel("\"" + key + "\": "); - name.setForeground(new Color(163, 90, 0)); - fusion.add(name); - if (allVariables.get(key).getClass().getName() != "Graphics.Type.Array") { - JLabel value = new JLabel(allVariables.get(key).display()); - value.setForeground(allVariables.get(key).getColor()); - fusion.add(value); - } else { - JPanel speForArray = new JPanel(); - speForArray.add(new JLabel("[ ")); - for (int i = 0; i <= allVariables.get(key).listGet().size() - 1; i++) { - JLabel tmp = new JLabel(String.valueOf(allVariables.get(key).listGet().get(i).display())); - tmp.setForeground(allVariables.get(key).listGet().get(i).getColor()); - speForArray.add(tmp); - } - speForArray.add(new JLabel(" ]")); - fusion.add(speForArray); - } - - core.add(fusion, settings); - rows++; - } - - settings.gridx = 0; - settings.gridy = rows; - core.add(new JLabel("}"), settings); - - this.add(core); - - this.setVisible(true); - } catch (IOException e) { - System.out.println("[!] Fichier " + url.getFile() + " n'existe pas"); - } - } -} diff --git a/src/Graphics/GraphicsCore.java b/src/Graphics/GraphicsCore.java deleted file mode 100644 index b3609a1..0000000 --- a/src/Graphics/GraphicsCore.java +++ /dev/null @@ -1,172 +0,0 @@ -package Graphics; - -import java.io.File; -import java.net.MalformedURLException; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JScrollPane; -import javax.swing.JOptionPane; -import javax.swing.JFileChooser; -import java.net.URL; -import java.awt.Dimension; -import java.awt.CardLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.BorderLayout; -import javax.swing.filechooser.FileSystemView; -import javax.swing.filechooser.FileNameExtensionFilter; - -/** - * [Romain] - * Faire le pont entre la selection du fichier JSON et l'affichage - * graphique du code JSON - */ - -public class GraphicsCore extends JFrame { - private final Dimension DEFAULT_FRAME_SIZE = new Dimension(800, 600); - private final Dimension MINIMUM_FRAME_SIZE = new Dimension(600, 500); - private final CardLayout cards; - private JLabel textField; - private URL url; - - public GraphicsCore() { - super("Inspecteur JSON - Romain & Bilal"); - - this.url = null; - this.textField = new JLabel("Clique ici pour choisir le chemin du fichier JSON ->"); - - this.cards = new CardLayout(); - - this.init(); - this.add(firstCard()); - cards.last(this.getContentPane()); - this.setVisible(true); - } - - /** - * Initalisation des parametres de la Frame par defaut. - */ - private void init() { - this.setSize(DEFAULT_FRAME_SIZE); - this.setDefaultCloseOperation(EXIT_ON_CLOSE); - this.setMinimumSize(MINIMUM_FRAME_SIZE); - this.setLayout(cards); - this.add(firstCard()); - cards.first(this.getContentPane()); - } - - /** - * Creation de la fenetre ou l'on nous demande de chemin absolut du fichier JSON - * - * @return Le JPanel de la premiere card du CardLayout - */ - private JPanel firstCard() { - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - this.textField = new JLabel("Clique ici pour choisir le chemin du fichier JSON ->"); - - JButton button = new JButton("Valider"); - button.addActionListener((event) -> validationAction(this.textField.getText())); - - JButton selectedFile = new JButton("..."); - selectedFile.addActionListener((event) -> getPathOf()); - - JPanel panel = new JPanel(); - panel.setLayout(layout); - - gbc.insets = new Insets(10, 10, 10, 10); - gbc.gridx = 0; - gbc.gridy = 0; - panel.add(new JLabel("URL :"), gbc); - - gbc.gridx = 1; - panel.add(this.textField, gbc); - - gbc.gridx = 2; - panel.add(selectedFile, gbc); - - gbc.gridx = 1; - gbc.gridy = 1; - panel.add(button, gbc); - - return panel; - } - - /** - * Creation de la fenetre ou sera afficher le code du fichier JSON - * - * @return Le JPanel contenant le rendu de Traitable - * @see Graphics.Traitable - */ - private JPanel secondCard() { - GraphicFile file = new GraphicFile(this.url); - - JPanel mainPanel = new JPanel(), southPanel = new JPanel(); - JButton backButton = new JButton("Retour"); - backButton.addActionListener((event) -> backAction(mainPanel)); - JScrollPane scroll = new JScrollPane(); - mainPanel.setLayout(new BorderLayout()); - - southPanel.add(backButton); - southPanel.add(new JButton("Tout déplier")); - southPanel.add(new JButton("convertir en PHP")); - - mainPanel.add(file, BorderLayout.CENTER); - mainPanel.add(southPanel, BorderLayout.SOUTH); - mainPanel.add(scroll); - - scroll.setViewportView(file); - return mainPanel; - } - - /** - * Permet de la fenetre ou l'on nous demande de chemin absolut du fichier JSON - * - * @param field Le chemin absolue du fichier JSON - */ - private void validationAction(String field) { - try { - this.url = new File(field).toURI().toURL(); - this.add(secondCard()); - cards.last(this.getContentPane()); - } catch (MalformedURLException e) { - JOptionPane.showMessageDialog(this, "Invalid URL", "Error", JOptionPane.ERROR_MESSAGE); - } - } - - /** - * Retourner dans la selection du fichier JSON - * - * @param panel Le JPanel ou l'on demande a l'utilisateur de choisir le fichier - * JSON - */ - private void backAction(JPanel panel) { - this.remove(panel); - cards.first(this.getContentPane()); - } - - /** - * Selection du fichier JSON - */ - private void getPathOf() { - JFileChooser jc = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory()); - - jc.setDialogTitle("Choissez le fichier json: "); - jc.setFileSelectionMode(JFileChooser.FILES_ONLY); - - FileNameExtensionFilter filter = new FileNameExtensionFilter("Fichier JSON", "json"); - jc.setFileFilter(filter); - - int res = jc.showOpenDialog(this); - - if (res == JFileChooser.APPROVE_OPTION) { - if (jc.getSelectedFile().isFile()) { - this.textField.setText(jc.getSelectedFile().getAbsolutePath()); - this.revalidate(); - } - } - } -} diff --git a/src/Graphics/Traitable.java b/src/Graphics/Traitable.java deleted file mode 100644 index e5a84d7..0000000 --- a/src/Graphics/Traitable.java +++ /dev/null @@ -1,221 +0,0 @@ -package Graphics; - -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.LinkedList; -import Graphics.Type.*; -import java.io.IOException; -import java.io.InputStream; - -/** - * [Bilal] - * Classe qui sert a stocke les valeurs contenue dans le JSON dans une liste. - */ - -public class Traitable { - private final HashMap contentRaw; - private final HashMap> content; - private final InputStream file; - - public Traitable(InputStream file) { - this.contentRaw = new LinkedHashMap<>(); - this.content = new LinkedHashMap<>(); - this.file = file; - this.Run(); - } - - /** - * Lancement automatique une fois que Traitable est instantie - * - * @see Graphics.GraphicFile - */ - private void Run() { - System.out.println("[+] Preparation..."); - - try { - try { - StringBuilder allJson = new StringBuilder(); - StringBuilder tmp = new StringBuilder(); - int i = 0; - - for (int cursor = this.file.read(); cursor != -1; cursor = this.file.read()) { - char c = (char) cursor; - allJson.append(c); - } - - allJson = this.ajustementVirguleEnd(allJson.toString()); - - while (i < allJson.length()) { - if (allJson.charAt(i) == '"') { - while (allJson.charAt(i) != ',') { - if (allJson.charAt(i) == '[') { - while (allJson.charAt(i) != ']') { - tmp.append(allJson.charAt(i)); - i++; - } - } else if (allJson.charAt(i) == '{') { - while (allJson.charAt(i) != '}') { - tmp.append(allJson.charAt(i)); - i++; - } - } else { - tmp.append(allJson.charAt(i)); - i++; - } - } - - String[] varInfo = this.getInfoOfRecord(tmp); - this.saveValue(varInfo[0], varInfo[1]); - tmp.setLength(0); - - i++; - } - - i++; - } - - } catch (StringIndexOutOfBoundsException ignore) { - } - } catch (IOException e) { - System.out.println("[!] Probleme lors de la lecture du fichier"); - } - } - - /** - * Enregistre dans la HashMap la valeur - * - * @param name Le nom de l'entree - * @param value La valeur de l'entree - * - * @see Graphics.Type.Type - * @see java.util.HashMap - */ - private void saveValue(String name, String value) { - String typeOfValue = this.getType(value); - - switch (typeOfValue) { - case "string": { - this.content.put(name, new Chaine(String.valueOf(value))); - break; - } - - case "int": { - this.content.put(name, new Entier(Integer.valueOf(value))); - break; - } - - case "double": { - this.content.put(name, new Flottant(Double.valueOf(value))); - break; - } - - case "boolean": { - this.content.put(name, new Bool(Boolean.valueOf(value))); - break; - } - - case "array": { - this.content.put(name, new Array(value)); - break; - } - } - } - - /** - * Sert a detecter le type d'une valeur - * - * @param value La chaine a evolue pour determiner son type - * @return Le type - */ - private String getType(String value) { - if (value.contains("{")) { - return "object"; - } else if (value.contains("[")) { - return "array"; - } else if (value.contains("true") || value.contains("false")) { - return "boolean"; - } else if (value.contains(".")) { - return "double"; - } else if (value.contains("null")) { - return "null"; - } else if (value.contains("\"")) { - return "string"; - } else { - return "int"; - } - } - - /** - * Recuperer le nom et la valeur divise sous forme de tableau - * - * @param sb La phrase a separer - * @return Un tableau { 0 = nom, 1 = value } - */ - private String[] getInfoOfRecord(StringBuilder sb) { - String[] info = sb.toString().split(":"); - info[0] = this.removeSpeChar(info[0]); - info[1] = this.removeFirstSpaceIfThere(info[1]); - - return info; - } - - /** - * Retourne une valeur JSON qui, si elle contient un espace au debut, le - * supprime - * - * @param str La valeur JSON - * @return La valeur JSON sans l'espace au debut si il y en a un - */ - private String removeFirstSpaceIfThere(String str) { - if (str.length() > 0 && str.charAt(0) == ' ') { - str = str.substring(1); - } - - return str; - } - - /** - * Sert a retirer le charactere guillemet - * - * @param str La phrase a soustraire le symbole guillemet - * @return Retourner une chaine sans le charactere guillemet - */ - private String removeSpeChar(String str) { - StringBuilder tmp = new StringBuilder(); - - for (int i = 0; i <= str.length() - 1; i++) { - if (str.charAt(i) != '"') { - tmp.append(str.charAt(i)); - } - } - - return tmp.toString(); - } - - /** - * Sert a rajouter une virgule a l'avant dernier charactre du fichier (pour ne - * pas skipper la derniere cle valeur) - * - * @param str Le fichier json en une ligne - * @return Le fichier avec la fameuse virgule - */ - private StringBuilder ajustementVirguleEnd(String str) { - int longueur = str.length(); - char avantDernierCaractere = str.charAt(longueur - 2); - String nouvelleChaine = str.substring(0, longueur - 2) + avantDernierCaractere + "," - + str.substring(longueur - 1); - - return new StringBuilder(nouvelleChaine); - } - - /** - * Recuperer le jeu de cles valeurs dans GrahicFile - * - * @see Graphics.GraphicFile - * @return Le jeu de cles valeurs - */ - public HashMap> getVariableMap() { - return this.content; - } -} \ No newline at end of file diff --git a/src/Graphics/Type/Array.java b/src/Graphics/Type/Array.java deleted file mode 100644 index 38ca715..0000000 --- a/src/Graphics/Type/Array.java +++ /dev/null @@ -1,114 +0,0 @@ -package Graphics.Type; - -import java.awt.Color; -import Graphics.Type.*; -import java.util.LinkedList; -import java.util.List; - -/** - * Representation d'un tableau d'object - */ - -public class Array implements Type>> { - private String valueRaw; - private List> value; - private Color color; - - public Array(String valueRaw) { - this.valueRaw = valueRaw.substring(1, valueRaw.length() - 1); - this.value = new LinkedList<>(); - - this.Run(); - } - - public void Run() { - String[] spliced = this.valueRaw.split(","); - List> list = new LinkedList<>(); - - for (int i = 0; i <= spliced.length - 1; i++) { - switch (this.getType(spliced[i])) { - case "string": { - list.add(new Chaine(String.valueOf(spliced[i]))); - break; - } - - case "int": { - list.add(new Entier(Integer.valueOf(spliced[i]))); - break; - } - - case "double": { - list.add(new Flottant(Double.valueOf(spliced[i]))); - break; - } - - case "boolean": { - list.add(new Bool(Boolean.valueOf(spliced[i]))); - break; - } - } - } - - this.value = list; - } - - public String getType(String value) { - if (value.contains("{")) { - return "object"; - } else if (value.contains("[")) { - return "array"; - } else if (value.contains("\"")) { - return "string"; - } else if (value.contains("true") || value.contains("false")) { - return "boolean"; - } else if (value.contains(".")) { - return "double"; - } else if (value.contains("null")) { - return "null"; - } else { - return "int"; - } - } - - public String getValueRaw() { - return this.valueRaw; - } - - @Override - public List> listGet() { - return this.value; - } - - @Override - public Color getColor() { - return this.color; - } - - @Override - public String display() { - StringBuilder str = new StringBuilder(); - - str.append("[ "); - - for (int i = 0; i <= this.value.size() - 1; i++) { - str.append(this.value.get(i).display() + ", "); - } - - str.deleteCharAt(str.length() - 1); - str.deleteCharAt(str.length() - 1); - - str.append(" ]"); - - return str.toString(); - } - - @Override - public String getType() { - return "array"; - } - - @Override - public List> getValue() { - return this.value; - } -} diff --git a/src/Graphics/Type/Bool.java b/src/Graphics/Type/Bool.java deleted file mode 100644 index df5b351..0000000 --- a/src/Graphics/Type/Bool.java +++ /dev/null @@ -1,47 +0,0 @@ -package Graphics.Type; - -import java.awt.Color; -import java.util.List; - -/** - * Representation du type boolean - */ - -public class Bool implements Type { - private Boolean value; - private Color color; - - public Bool(Boolean value) { - this.value = value; - if (value) { - this.color = Color.GREEN; - } else { - this.color = Color.RED; - } - } - - @Override - public List> listGet() { - return null; - } - - @Override - public Color getColor() { - return this.color; - } - - @Override - public String display() { - return String.valueOf(value); - } - - @Override - public String getType() { - return "boolean"; - } - - @Override - public Boolean getValue() { - return this.value; - } -} diff --git a/src/Graphics/Type/Chaine.java b/src/Graphics/Type/Chaine.java deleted file mode 100644 index e798ae9..0000000 --- a/src/Graphics/Type/Chaine.java +++ /dev/null @@ -1,43 +0,0 @@ -package Graphics.Type; - -import java.awt.Color; -import java.util.List; - -/** - * Representation du type string - */ - -public class Chaine implements Type { - private String value; - private Color color; - - public Chaine(String value) { - this.value = value; - this.color = Color.PINK; - } - - @Override - public List> listGet() { - return null; - } - - @Override - public Color getColor() { - return this.color; - } - - @Override - public String display() { - return String.valueOf(value); - } - - @Override - public String getType() { - return "string"; - } - - @Override - public String getValue() { - return this.value; - } -} diff --git a/src/Graphics/Type/Entier.java b/src/Graphics/Type/Entier.java deleted file mode 100644 index a00c6ab..0000000 --- a/src/Graphics/Type/Entier.java +++ /dev/null @@ -1,43 +0,0 @@ -package Graphics.Type; - -import java.awt.Color; -import java.util.List; - -/** - * Representation du type int - */ - -public class Entier implements Type { - public Integer value; - private Color color; - - public Entier(Integer value) { - this.value = value; - this.color = Color.BLUE; - } - - @Override - public List> listGet() { - return null; - } - - @Override - public Color getColor() { - return this.color; - } - - @Override - public String display() { - return String.valueOf(value); - } - - @Override - public String getType() { - return "int"; - } - - @Override - public Integer getValue() { - return this.value; - } -} diff --git a/src/Graphics/Type/Flottant.java b/src/Graphics/Type/Flottant.java deleted file mode 100644 index fc7fe89..0000000 --- a/src/Graphics/Type/Flottant.java +++ /dev/null @@ -1,43 +0,0 @@ -package Graphics.Type; - -import java.awt.Color; -import java.util.List; - -/** - * Representation du type double - */ - -public class Flottant implements Type { - private Double value; - private Color color; - - public Flottant(Double value) { - this.value = value; - this.color = Color.BLUE; - } - - @Override - public List> listGet() { - return null; - } - - @Override - public Color getColor() { - return this.color; - } - - @Override - public String display() { - return String.valueOf(value); - } - - @Override - public String getType() { - return "double"; - } - - @Override - public Double getValue() { - return this.value; - } -} \ No newline at end of file diff --git a/src/Graphics/Type/Type.java b/src/Graphics/Type/Type.java deleted file mode 100644 index f1c853c..0000000 --- a/src/Graphics/Type/Type.java +++ /dev/null @@ -1,36 +0,0 @@ -package Graphics.Type; - -import java.awt.Color; -import java.util.List; - -public interface Type { - /** - * Retourner le type de la variable - * - * @return le type en string - */ - public String getType(); - - /** - * - * @return - */ - public T getValue(); - - /** - * Recuperer la couleur de syntaxe d'un type - */ - public Color getColor(); - - /** - * Afficher la valeur / toutes les valeurs - */ - public String display(); - - /** - * UNIQUEMENT POUR Graphics.Type.Chaine - * - * @return La liste contenant les valeurs du tableau - */ - public List> listGet(); -} diff --git a/src/JsonInspector/JsonSyntaxException.java b/src/JsonSyntaxException.java similarity index 96% rename from src/JsonInspector/JsonSyntaxException.java rename to src/JsonSyntaxException.java index 46c274c..3fd2f7e 100644 --- a/src/JsonInspector/JsonSyntaxException.java +++ b/src/JsonSyntaxException.java @@ -1,9 +1,9 @@ -package JsonInspector; - -public class JsonSyntaxException extends Throwable { - private static final String MESSAGE = "Syntax error in JSON file"; - - public JsonSyntaxException() { - super(MESSAGE); - } -} +package JsonInspector; + +public class JsonSyntaxException extends Throwable { + private static final String MESSAGE = "Syntax error in JSON file"; + + public JsonSyntaxException() { + super(MESSAGE); + } +} diff --git a/src/JsonInspector/Line.java b/src/Line.java similarity index 95% rename from src/JsonInspector/Line.java rename to src/Line.java index 50d6f85..9ed41c1 100644 --- a/src/JsonInspector/Line.java +++ b/src/Line.java @@ -1,92 +1,92 @@ -package JsonInspector; - -import java.awt.*; - -public class Line extends MyJPanel { - private boolean show = true; - private final int depth; - private final Node node; - private MyJLabel lastElement; - private boolean closingElement = false; - - - public Line(Node node, int depth) { - super(); - this.node = node; - this.depth = depth; - } - - - public Line(Node node, String str, int depth) { - super(); - this.add(new MyJLabel(str)); - this.node = node; - this.depth = depth; - } - - - public Line(Node node, String str, Color color, int depth) { - super(); - this.add(new MyJLabel(str, color)); - this.node = node; - this.depth = depth; - } - - - public void add(String string) { - lastElement = new MyJLabel(string); - this.add(lastElement); - } - - - public void add(String string, Color color) { - lastElement = new MyJLabel(string, color); - this.add(lastElement); - } - - - public Node getNode() { - return node; - } - - - public int getDepth() { - return depth; - } - - - public boolean isShow() { - return show; - } - - - public void unfold() { - show = true; - } - - - public void retreat() { - show = false; - } - - - public void setClosingElement() { - closingElement = true; - } - - - public boolean isClosingElement() { - return closingElement; - } - - - public void removeClosingLabel() { - try { - if (lastElement.getText().equals("...]") || lastElement.getText().equals("...}")) { - this.remove(lastElement); - } - } catch (NullPointerException e) { - //System.out.println("La ligne est vide"); - } - } -} +package JsonInspector; + +import java.awt.*; + +public class Line extends MyJPanel { + private boolean show = true; + private final int depth; + private final Node node; + private MyJLabel lastElement; + private boolean closingElement = false; + + + public Line(Node node, int depth) { + super(); + this.node = node; + this.depth = depth; + } + + + public Line(Node node, String str, int depth) { + super(); + this.add(new MyJLabel(str)); + this.node = node; + this.depth = depth; + } + + + public Line(Node node, String str, Color color, int depth) { + super(); + this.add(new MyJLabel(str, color)); + this.node = node; + this.depth = depth; + } + + + public void add(String string) { + lastElement = new MyJLabel(string); + this.add(lastElement); + } + + + public void add(String string, Color color) { + lastElement = new MyJLabel(string, color); + this.add(lastElement); + } + + + public Node getNode() { + return node; + } + + + public int getDepth() { + return depth; + } + + + public boolean isShow() { + return show; + } + + + public void unfold() { + show = true; + } + + + public void retreat() { + show = false; + } + + + public void setClosingElement() { + closingElement = true; + } + + + public boolean isClosingElement() { + return closingElement; + } + + + public void removeClosingLabel() { + try { + if (lastElement.getText().equals("...]") || lastElement.getText().equals("...}")) { + this.remove(lastElement); + } + } catch (NullPointerException e) { + //System.out.println("La ligne est vide"); + } + } +} diff --git a/src/JsonInspector/Main.java b/src/Main.java similarity index 100% rename from src/JsonInspector/Main.java rename to src/Main.java diff --git a/src/JsonInspector/MyJLabel.java b/src/MyJLabel.java similarity index 95% rename from src/JsonInspector/MyJLabel.java rename to src/MyJLabel.java index 9618d3a..84589c8 100644 --- a/src/JsonInspector/MyJLabel.java +++ b/src/MyJLabel.java @@ -1,18 +1,18 @@ -package JsonInspector; - -import javax.swing.*; -import java.awt.*; - -public class MyJLabel extends JLabel { - public MyJLabel(String text, Color color) { - super(text); - //this.setFont(Parameters.FILE_FONT); - this.setForeground(color); - } - - public MyJLabel(String text) { - super(text); - //this.setFont(Parameters.FILE_FONT); - this.setForeground(Parameters.DEFAULT_TEXT_COLOR); - } -} +package JsonInspector; + +import javax.swing.*; +import java.awt.*; + +public class MyJLabel extends JLabel { + public MyJLabel(String text, Color color) { + super(text); + //this.setFont(Parameters.FILE_FONT); + this.setForeground(color); + } + + public MyJLabel(String text) { + super(text); + //this.setFont(Parameters.FILE_FONT); + this.setForeground(Parameters.DEFAULT_TEXT_COLOR); + } +} diff --git a/src/JsonInspector/MyJPanel.java b/src/MyJPanel.java similarity index 96% rename from src/JsonInspector/MyJPanel.java rename to src/MyJPanel.java index 05b53ad..e6ae9e1 100644 --- a/src/JsonInspector/MyJPanel.java +++ b/src/MyJPanel.java @@ -1,24 +1,24 @@ -package JsonInspector; - -import javax.swing.*; -import java.awt.*; - -public class MyJPanel extends JPanel { - public MyJPanel(Color color) { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - this.setBackground(color); - } - - public MyJPanel() { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - this.setBackground(Parameters.BACKGROUND_COLOR); - } - - public MyJPanel(boolean isTransparent) { - super(); - this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - this.setOpaque(isTransparent); - } -} +package JsonInspector; + +import javax.swing.*; +import java.awt.*; + +public class MyJPanel extends JPanel { + public MyJPanel(Color color) { + super(); + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + this.setBackground(color); + } + + public MyJPanel() { + super(); + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + this.setBackground(Parameters.BACKGROUND_COLOR); + } + + public MyJPanel(boolean isTransparent) { + super(); + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + this.setOpaque(isTransparent); + } +} diff --git a/src/JsonInspector/Node.java b/src/Node.java similarity index 95% rename from src/JsonInspector/Node.java rename to src/Node.java index 94099cf..d705da8 100644 --- a/src/JsonInspector/Node.java +++ b/src/Node.java @@ -1,115 +1,115 @@ -package JsonInspector; - -import java.awt.*; -import java.util.ArrayList; - - -public class Node { - private final ArrayList values = new ArrayList<>(); - private final String name; - private final Type type; - - - public Node(String name, Type type) { - this.type = type; - if (type == Type.ELEMENT) { - this.name = ""; - } else { - this.name = name; - } - } - - - private void findType(String value) { - if (value.charAt(0) == '"' && value.charAt(value.length()-1) == '"') { - values.add(new Value(Tree.cleanOpeningExpression(value))); - return; - } - - try { - values.add(new Value(Integer.parseInt(value))); - } catch (NumberFormatException nfeInt) { - try { - values.add(new Value(Double.parseDouble(value))); - } catch (NumberFormatException nfeDouble) { - values.add(new Value(new Other(value))); - } - } - } - - - public void add(T value) { - if (value != null) { - if (value.getClass().equals(Node.class)) { - values.add(new Value(value)); - } else { - findType((String) value); - } - } - } - - - public Type getType() { - return type; - } - - - public String getName() { - return name; - } - - - public Value get(int index) { - return values.get(index); - } - - - public int getSize() { - return values.size(); - } - - - public boolean isObject() { - return type == Type.OBJECT; - } - - - public boolean isArray() { - return type == Type.ARRAY; - } - - - public boolean isElement() { - return type == Type.ELEMENT; - } - - - public boolean isPair() { - return type == Type.PAIR; - } - - - public boolean isArrayObjectElement() { - boolean array = type == Type.ARRAY; - boolean object = type == Type.OBJECT; - boolean element = type == Type.ELEMENT; - - if (array || object || element) { - return true; - } - - return false; - } - - - @Override - public String toString() { - String string = name + " : "; - - for (int i = 0; i < values.size(); i++) { - string += values.get(i) + ", "; - } - - return string; - } -} +package JsonInspector; + +import java.awt.*; +import java.util.ArrayList; + + +public class Node { + private final ArrayList values = new ArrayList<>(); + private final String name; + private final Type type; + + + public Node(String name, Type type) { + this.type = type; + if (type == Type.ELEMENT) { + this.name = ""; + } else { + this.name = name; + } + } + + + private void findType(String value) { + if (value.charAt(0) == '"' && value.charAt(value.length()-1) == '"') { + values.add(new Value(Tree.cleanOpeningExpression(value))); + return; + } + + try { + values.add(new Value(Integer.parseInt(value))); + } catch (NumberFormatException nfeInt) { + try { + values.add(new Value(Double.parseDouble(value))); + } catch (NumberFormatException nfeDouble) { + values.add(new Value(new Other(value))); + } + } + } + + + public void add(T value) { + if (value != null) { + if (value.getClass().equals(Node.class)) { + values.add(new Value(value)); + } else { + findType((String) value); + } + } + } + + + public Type getType() { + return type; + } + + + public String getName() { + return name; + } + + + public Value get(int index) { + return values.get(index); + } + + + public int getSize() { + return values.size(); + } + + + public boolean isObject() { + return type == Type.OBJECT; + } + + + public boolean isArray() { + return type == Type.ARRAY; + } + + + public boolean isElement() { + return type == Type.ELEMENT; + } + + + public boolean isPair() { + return type == Type.PAIR; + } + + + public boolean isArrayObjectElement() { + boolean array = type == Type.ARRAY; + boolean object = type == Type.OBJECT; + boolean element = type == Type.ELEMENT; + + if (array || object || element) { + return true; + } + + return false; + } + + + @Override + public String toString() { + String string = name + " : "; + + for (int i = 0; i < values.size(); i++) { + string += values.get(i) + ", "; + } + + return string; + } +} diff --git a/src/JsonInspector/Other.java b/src/Other.java similarity index 92% rename from src/JsonInspector/Other.java rename to src/Other.java index 5a73f4b..b7545a1 100644 --- a/src/JsonInspector/Other.java +++ b/src/Other.java @@ -1,16 +1,16 @@ -package JsonInspector; - -public class Other { - String value; - - - public Other(String value) { - this.value = value; - } - - - @Override - public String toString() { - return value; - } -} +package JsonInspector; + +public class Other { + String value; + + + public Other(String value) { + this.value = value; + } + + + @Override + public String toString() { + return value; + } +} diff --git a/src/JsonInspector/Parameters.java b/src/Parameters.java similarity index 97% rename from src/JsonInspector/Parameters.java rename to src/Parameters.java index 0f07e10..e8bab69 100644 --- a/src/JsonInspector/Parameters.java +++ b/src/Parameters.java @@ -1,20 +1,20 @@ -package JsonInspector; - -import java.awt.*; - -public class Parameters { - public static final Font FILE_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 18); - public static final String IHM_INDENTATION = " "; - public static final String CONSOLE_INDENTATION = " "; - public static final String ARRAY_CLOSING = "...]"; - public static final String OBJECT_ELEMENT_CLOSING = "...}"; - - public static final Color IHM_COLOR = new Color(70, 70, 70); - public static final Color KEY_COLOR = new Color(70, 189, 204); - public static final Color OTHER_COLOR = new Color(7, 103, 183); - public static final Color STRING_COLOR = new Color(203, 109, 80); - public static final Color NUMBER_COLOR = new Color(133, 192, 95); - public static final Color MOUSE_OVER_COLOR = new Color(60, 60, 60); - public static final Color DEFAULT_TEXT_COLOR = new Color(220, 220, 220); - public static final Color BACKGROUND_COLOR = new Color(45, 45, 45); -} +package JsonInspector; + +import java.awt.*; + +public class Parameters { + public static final Font FILE_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 18); + public static final String IHM_INDENTATION = " "; + public static final String CONSOLE_INDENTATION = " "; + public static final String ARRAY_CLOSING = "...]"; + public static final String OBJECT_ELEMENT_CLOSING = "...}"; + + public static final Color IHM_COLOR = new Color(70, 70, 70); + public static final Color KEY_COLOR = new Color(70, 189, 204); + public static final Color OTHER_COLOR = new Color(7, 103, 183); + public static final Color STRING_COLOR = new Color(203, 109, 80); + public static final Color NUMBER_COLOR = new Color(133, 192, 95); + public static final Color MOUSE_OVER_COLOR = new Color(60, 60, 60); + public static final Color DEFAULT_TEXT_COLOR = new Color(220, 220, 220); + public static final Color BACKGROUND_COLOR = new Color(45, 45, 45); +} diff --git a/src/JsonInspector/Tree.java b/src/Tree.java similarity index 96% rename from src/JsonInspector/Tree.java rename to src/Tree.java index 1580093..3f8b528 100644 --- a/src/JsonInspector/Tree.java +++ b/src/Tree.java @@ -1,293 +1,293 @@ -package JsonInspector; - -import java.util.ArrayList; - -public class Tree { - private Node firstNode; - - - public Tree(String file) throws JsonSyntaxException { - firstNode = parseElement(file); - } - - - private Node whichType(String element) throws JsonSyntaxException { - String[] keyValue = splitKeyValue(element); - - if (keyValue.length == 2) { - String key = keyValue[0], value = keyValue[1]; - - if (0 < value.length()) { - if (value.charAt(0) == '[' && value.charAt(value.length() - 1) == ']') { - return parseArray(key, value); - - } else if (value.charAt(0) == '{' && value.charAt(value.length() - 1) == '}') { - return parseObject(key, value); - - } else { - return parsePair(key, value); - } - } else { - return null; - } - - } else if (keyValue[0].equals("")) { - - if (keyValue[0].charAt(0) == '{' && keyValue[0].charAt(keyValue[0].length()-1) == '}') { - return parseElement(keyValue[0]); - } else { - throw new JsonSyntaxException(); - } - - } else { - throw new JsonSyntaxException(); - } - } - - - private Node parseArray(String name, String rawValues) throws JsonSyntaxException { - Node array = new Node(cleanOpeningExpression(name), Type.ARRAY); - ArrayList elements = splitList(rawValues); - - for (String value : elements) { - if (0 < value.length()) { - if (value.charAt(0) == '{') { - if (value.charAt(value.length() - 1) == '}') { - array.add(parseElement(value)); - } else { - throw new JsonSyntaxException(); - } - - } else { - array.add(value); - } - } - } - - return array; - } - - - private Node parseObject(String name, String rawValues) throws JsonSyntaxException { - Node object = new Node(cleanOpeningExpression(name), Type.OBJECT); - ArrayList elements = splitList(rawValues); - - for (String value : elements) { - object.add(whichType(value)); - } - - return object; - } - - - private Node parsePair(String name, String value) { - Node pair = new Node(cleanOpeningExpression(name), Type.PAIR); - pair.add(value); - - return pair; - } - - - private Node parseElement(String rawValues) throws JsonSyntaxException { - Node element = new Node("", Type.ELEMENT); - ArrayList elements = splitList(rawValues); - - for (String value : elements) { - element.add(whichType(value)); - } - - return element; - } - - - public static String cleanOpeningExpression(String strToClean) { - StringBuilder cleanedString = new StringBuilder(strToClean); - cleanedString.deleteCharAt(0); - cleanedString.deleteCharAt(cleanedString.length()-1); - return cleanedString.toString(); - } - - - private ArrayList splitList(String listToSplit) { - char[] chars = cleanOpeningExpression(listToSplit).toCharArray(); - int depth = 0; - ArrayList elements = new ArrayList<>(); - String buffer = ""; - - for (char currentChar : chars) { - if (currentChar == ',' && depth == 0) { - elements.add(buffer); - buffer = ""; - } else if (currentChar == '{' || currentChar == '[') { - depth += 1; - buffer += currentChar; - } else if (currentChar == '}' || currentChar == ']') { - depth -= 1; - buffer += currentChar; - } else { - buffer += currentChar; - } - } - elements.add(buffer); - return elements; - } - - - private String[] splitKeyValue(String expressionToSplit) { - boolean inKey = true; - char[] chars = expressionToSplit.toCharArray(); - String key = "", value, buffer = ""; - - for (char currentChar : chars) { - if (inKey) { - if (currentChar == '{' || currentChar == ':') { - key = buffer; - buffer = ""; - if (currentChar == '{') { - buffer += currentChar; - } - inKey = false; - } else { - buffer += currentChar; - } - } else { - buffer += currentChar; - } - } - value = buffer; - - return new String[] {key, value}; - } - - - public static String printTree(Node node, int depth) { - String line = "", indentation = ""; - - //créé l'indentation de la bonne taille en fonction de la - //profondeur dans l'arbre - for (int i = 0; i < depth; i++) { - indentation += Parameters.CONSOLE_INDENTATION; - } - - if (!node.isElement()) { - line += indentation + "\"" + node.getName() + "\""; - } else { - line += indentation + node.getName(); - } - - - if (node.isObject() || node.isElement()) { - line += printObjectElement(node, depth, indentation); - - } else if (node.isPair()){ - line += printPair(node); - - } else if (node.isArray()){ - line += printArray(node, depth, indentation); - } - - return line; - } - - - private static String callNextNodes(Node node, int depth) { - String line = ""; - - for (int i = 0; i < node.getSize(); i++) { - if (node.get(i).isNode()) { - line += "\n" + printTree((Node) node.get(i).getValue(), depth + 1); - } - - if (i != node.getSize() - 1) { - line += ","; - } - } - - return line; - } - - - private static String printPair(Node node) { - String line = ""; - - if (node.getSize() != 0) { - if (node.get(0).isString()) { - line += ": \"" + node.get(0).getValue() + "\""; - } else { - line += ": " + node.get(0).getValue(); - } - - } else { - line += ": null"; - } - - return line; - } - - - private static String printObjectElement(Node node, int depth, String indentation) { - String line = ""; - - if (node.getType() == Type.ELEMENT) { - line += "{"; - } else { - line += ": {"; - } - - if (node.getSize() == 0) { - line += "}"; - } else { - line += callNextNodes(node, depth); - line += "\n" + indentation + "}"; - } - - return line; - } - - - private static String printArray(Node node, int depth, String indentation) { - String line = ""; - line += ": ["; - - if (node.getSize() == 0) { - line += "]"; - - } else { - // Cette boucle parcours les valeurs du tableau - for (int i = 0; i < node.getSize(); i++) { - // si la valeur a l'indice i n'est pas une valeur brute alors - // on appelle de manière récursive la fonction d'affichage de l'arbre - if (node.get(i).isNode()) { - line += "\n" + printTree((Node) node.get(i).getValue(), depth + 1); - } else { - line += "\n" + indentation + Parameters.CONSOLE_INDENTATION; - if (node.get(i).isString()) { - line += "\"" + node.get(i).getValue() + "\""; - } else { - line += node.get(i).getValue(); - } - } - - // si la valeur n'est pas la dernière alors on lui ajoute une virgule - if (i != node.getSize() - 1) { - line += ","; - } - } - - line += "\n" + indentation + "]"; - } - - return line; - } - - - @Override - public String toString() { - return printTree(firstNode, 0); - } - - - public Node getFirstNode() { - return firstNode; - } -} +package JsonInspector; + +import java.util.ArrayList; + +public class Tree { + private Node firstNode; + + + public Tree(String file) throws JsonSyntaxException { + firstNode = parseElement(file); + } + + + private Node whichType(String element) throws JsonSyntaxException { + String[] keyValue = splitKeyValue(element); + + if (keyValue.length == 2) { + String key = keyValue[0], value = keyValue[1]; + + if (0 < value.length()) { + if (value.charAt(0) == '[' && value.charAt(value.length() - 1) == ']') { + return parseArray(key, value); + + } else if (value.charAt(0) == '{' && value.charAt(value.length() - 1) == '}') { + return parseObject(key, value); + + } else { + return parsePair(key, value); + } + } else { + return null; + } + + } else if (keyValue[0].equals("")) { + + if (keyValue[0].charAt(0) == '{' && keyValue[0].charAt(keyValue[0].length()-1) == '}') { + return parseElement(keyValue[0]); + } else { + throw new JsonSyntaxException(); + } + + } else { + throw new JsonSyntaxException(); + } + } + + + private Node parseArray(String name, String rawValues) throws JsonSyntaxException { + Node array = new Node(cleanOpeningExpression(name), Type.ARRAY); + ArrayList elements = splitList(rawValues); + + for (String value : elements) { + if (0 < value.length()) { + if (value.charAt(0) == '{') { + if (value.charAt(value.length() - 1) == '}') { + array.add(parseElement(value)); + } else { + throw new JsonSyntaxException(); + } + + } else { + array.add(value); + } + } + } + + return array; + } + + + private Node parseObject(String name, String rawValues) throws JsonSyntaxException { + Node object = new Node(cleanOpeningExpression(name), Type.OBJECT); + ArrayList elements = splitList(rawValues); + + for (String value : elements) { + object.add(whichType(value)); + } + + return object; + } + + + private Node parsePair(String name, String value) { + Node pair = new Node(cleanOpeningExpression(name), Type.PAIR); + pair.add(value); + + return pair; + } + + + private Node parseElement(String rawValues) throws JsonSyntaxException { + Node element = new Node("", Type.ELEMENT); + ArrayList elements = splitList(rawValues); + + for (String value : elements) { + element.add(whichType(value)); + } + + return element; + } + + + public static String cleanOpeningExpression(String strToClean) { + StringBuilder cleanedString = new StringBuilder(strToClean); + cleanedString.deleteCharAt(0); + cleanedString.deleteCharAt(cleanedString.length()-1); + return cleanedString.toString(); + } + + + private ArrayList splitList(String listToSplit) { + char[] chars = cleanOpeningExpression(listToSplit).toCharArray(); + int depth = 0; + ArrayList elements = new ArrayList<>(); + String buffer = ""; + + for (char currentChar : chars) { + if (currentChar == ',' && depth == 0) { + elements.add(buffer); + buffer = ""; + } else if (currentChar == '{' || currentChar == '[') { + depth += 1; + buffer += currentChar; + } else if (currentChar == '}' || currentChar == ']') { + depth -= 1; + buffer += currentChar; + } else { + buffer += currentChar; + } + } + elements.add(buffer); + return elements; + } + + + private String[] splitKeyValue(String expressionToSplit) { + boolean inKey = true; + char[] chars = expressionToSplit.toCharArray(); + String key = "", value, buffer = ""; + + for (char currentChar : chars) { + if (inKey) { + if (currentChar == '{' || currentChar == ':') { + key = buffer; + buffer = ""; + if (currentChar == '{') { + buffer += currentChar; + } + inKey = false; + } else { + buffer += currentChar; + } + } else { + buffer += currentChar; + } + } + value = buffer; + + return new String[] {key, value}; + } + + + public static String printTree(Node node, int depth) { + String line = "", indentation = ""; + + //créé l'indentation de la bonne taille en fonction de la + //profondeur dans l'arbre + for (int i = 0; i < depth; i++) { + indentation += Parameters.CONSOLE_INDENTATION; + } + + if (!node.isElement()) { + line += indentation + "\"" + node.getName() + "\""; + } else { + line += indentation + node.getName(); + } + + + if (node.isObject() || node.isElement()) { + line += printObjectElement(node, depth, indentation); + + } else if (node.isPair()){ + line += printPair(node); + + } else if (node.isArray()){ + line += printArray(node, depth, indentation); + } + + return line; + } + + + private static String callNextNodes(Node node, int depth) { + String line = ""; + + for (int i = 0; i < node.getSize(); i++) { + if (node.get(i).isNode()) { + line += "\n" + printTree((Node) node.get(i).getValue(), depth + 1); + } + + if (i != node.getSize() - 1) { + line += ","; + } + } + + return line; + } + + + private static String printPair(Node node) { + String line = ""; + + if (node.getSize() != 0) { + if (node.get(0).isString()) { + line += ": \"" + node.get(0).getValue() + "\""; + } else { + line += ": " + node.get(0).getValue(); + } + + } else { + line += ": null"; + } + + return line; + } + + + private static String printObjectElement(Node node, int depth, String indentation) { + String line = ""; + + if (node.getType() == Type.ELEMENT) { + line += "{"; + } else { + line += ": {"; + } + + if (node.getSize() == 0) { + line += "}"; + } else { + line += callNextNodes(node, depth); + line += "\n" + indentation + "}"; + } + + return line; + } + + + private static String printArray(Node node, int depth, String indentation) { + String line = ""; + line += ": ["; + + if (node.getSize() == 0) { + line += "]"; + + } else { + // Cette boucle parcours les valeurs du tableau + for (int i = 0; i < node.getSize(); i++) { + // si la valeur a l'indice i n'est pas une valeur brute alors + // on appelle de manière récursive la fonction d'affichage de l'arbre + if (node.get(i).isNode()) { + line += "\n" + printTree((Node) node.get(i).getValue(), depth + 1); + } else { + line += "\n" + indentation + Parameters.CONSOLE_INDENTATION; + if (node.get(i).isString()) { + line += "\"" + node.get(i).getValue() + "\""; + } else { + line += node.get(i).getValue(); + } + } + + // si la valeur n'est pas la dernière alors on lui ajoute une virgule + if (i != node.getSize() - 1) { + line += ","; + } + } + + line += "\n" + indentation + "]"; + } + + return line; + } + + + @Override + public String toString() { + return printTree(firstNode, 0); + } + + + public Node getFirstNode() { + return firstNode; + } +} diff --git a/src/JsonInspector/Type.java b/src/Type.java similarity index 94% rename from src/JsonInspector/Type.java rename to src/Type.java index 204cb67..ecd7ada 100644 --- a/src/JsonInspector/Type.java +++ b/src/Type.java @@ -1,5 +1,5 @@ -package JsonInspector; - -public enum Type { - OBJECT, ELEMENT, ARRAY, PAIR, NULL -} +package JsonInspector; + +public enum Type { + OBJECT, ELEMENT, ARRAY, PAIR, NULL +} diff --git a/src/JsonInspector/Value.java b/src/Value.java similarity index 95% rename from src/JsonInspector/Value.java rename to src/Value.java index c244c28..899ec48 100644 --- a/src/JsonInspector/Value.java +++ b/src/Value.java @@ -1,44 +1,44 @@ -package JsonInspector; - -public class Value { - private T value; - - - public Value(T value) { - this.value = value; - } - - - public T getValue() { - return value; - } - - - public boolean isObjectOrArray() { - if (value.getClass().equals(Node.class)) { - Node node = (Node) value; - if (node.getType() == Type.OBJECT || node.getType() == Type.ARRAY) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - - public boolean isNode() { - return value.getClass().equals(Node.class); - } - - - public boolean isString () { - return value.getClass().equals(String.class); - } - - - public boolean isNumber() { - return value.getClass().equals(Integer.class) || value.getClass().equals(Double.class); - } -} +package JsonInspector; + +public class Value { + private T value; + + + public Value(T value) { + this.value = value; + } + + + public T getValue() { + return value; + } + + + public boolean isObjectOrArray() { + if (value.getClass().equals(Node.class)) { + Node node = (Node) value; + if (node.getType() == Type.OBJECT || node.getType() == Type.ARRAY) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + + public boolean isNode() { + return value.getClass().equals(Node.class); + } + + + public boolean isString () { + return value.getClass().equals(String.class); + } + + + public boolean isNumber() { + return value.getClass().equals(Integer.class) || value.getClass().equals(Double.class); + } +} diff --git a/toFormat.json b/toFormat.json index 485ce75..40d1bbf 100644 --- a/toFormat.json +++ b/toFormat.json @@ -1 +1 @@ -{"couple": [true, "Onde"], "age": 19, "nationalite": "Franco-Algerienne", "enVie": true, "poid": 1.7} \ No newline at end of file +{"couple": [true, "Onde", ["F", 3]], "age": 19, "nationalite": "Franco-Algerienne", "enVie": true, "poid": 1.7} \ No newline at end of file