$
This commit is contained in:
parent
068f0f3b50
commit
3175d93380
90
src/.idea/workspace.xml
generated
Normal file
90
src/.idea/workspace.xml
generated
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="69aa91be-5611-42c9-9edd-6b71bc260d1f" name="Changes" comment="">
|
||||||
|
<change beforePath="$PROJECT_DIR$/../rapport.tex" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/ArrayObjectListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/Graphics/ArrayObjectListener.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/CoreJSONDescriptor.java" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Frame.java" beforeDir="false" afterPath="$PROJECT_DIR$/Graphics/Frame.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/GraphicFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/Graphics/GraphicFile.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/JsonSyntaxException.java" beforeDir="false" afterPath="$PROJECT_DIR$/Exception/JsonSyntaxException.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Line.java" beforeDir="false" afterPath="$PROJECT_DIR$/Graphics/Line.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/Main.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/MyJLabel.java" beforeDir="false" afterPath="$PROJECT_DIR$/Graphics/MyJLabel.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/MyJPanel.java" beforeDir="false" afterPath="$PROJECT_DIR$/Graphics/MyJPanel.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Node.java" beforeDir="false" afterPath="$PROJECT_DIR$/Storage/Node.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Other.java" beforeDir="false" afterPath="$PROJECT_DIR$/Storage/Other.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Parameters.java" beforeDir="false" afterPath="$PROJECT_DIR$/Settings/Parameters.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Tree.java" beforeDir="false" afterPath="$PROJECT_DIR$/Storage/Tree.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Type.java" beforeDir="false" afterPath="$PROJECT_DIR$/Storage/Type.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Value.java" beforeDir="false" afterPath="$PROJECT_DIR$/Storage/Value.java" afterDir="false" />
|
||||||
|
</list>
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
|
||||||
|
</component>
|
||||||
|
<component name="MarkdownSettingsMigration">
|
||||||
|
<option name="stateVersion" value="1" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectId" id="2KNL1Ow3saeeR5uGp5TWiHuom3y" />
|
||||||
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent">
|
||||||
|
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||||
|
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||||
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||||
|
</component>
|
||||||
|
<component name="RunManager">
|
||||||
|
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||||
|
<option name="MAIN_CLASS_NAME" value="JsonInspector.Main" />
|
||||||
|
<module name="SAE32_2022" />
|
||||||
|
<extension name="coverage">
|
||||||
|
<pattern>
|
||||||
|
<option name="PATTERN" value="JsonInspector.Storage.*" />
|
||||||
|
<option name="ENABLED" value="true" />
|
||||||
|
</pattern>
|
||||||
|
</extension>
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
<recent_temporary>
|
||||||
|
<list>
|
||||||
|
<item itemvalue="Application.Main" />
|
||||||
|
</list>
|
||||||
|
</recent_temporary>
|
||||||
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="69aa91be-5611-42c9-9edd-6b71bc260d1f" name="Changes" comment="" />
|
||||||
|
<created>1673809886930</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1673809886930</updated>
|
||||||
|
<workItem from="1673809891720" duration="280000" />
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
<option name="version" value="3" />
|
||||||
|
</component>
|
||||||
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
<option name="TAB_STATES">
|
||||||
|
<map>
|
||||||
|
<entry key="MAIN">
|
||||||
|
<value>
|
||||||
|
<State />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,47 +0,0 @@
|
|||||||
package JsonInspector;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
public class CoreJSONDescriptor {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
new Frame();
|
|
||||||
} else {
|
|
||||||
File jsonFile = new File("toFormat.json");
|
|
||||||
|
|
||||||
if(jsonFile.exists()) {
|
|
||||||
//new Descriptor(getCodeJsonInOneLine(jsonFile));
|
|
||||||
} else {
|
|
||||||
System.err.println("[!] Probleme lors de l'ouverture du fichier");
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCodeJsonInOneLine(File f) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
try {
|
|
||||||
BufferedReader buff = new BufferedReader(new FileReader(f));
|
|
||||||
String line;
|
|
||||||
while ((line = buff.readLine()) != null) {
|
|
||||||
line = line.replaceAll("\t", "");
|
|
||||||
line = line.replaceAll("\n", "");
|
|
||||||
line = line.replaceAll(" ", "");
|
|
||||||
sb.append(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
buff.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.err.println("[!] Probleme lors de l'ouverture du fichier");
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Exception;
|
||||||
|
|
||||||
public class JsonSyntaxException extends Throwable {
|
public class JsonSyntaxException extends Throwable {
|
||||||
private static final String MESSAGE = "Syntax error in JSON file";
|
private static final String MESSAGE = "Syntax error in JSON file";
|
@ -1,4 +1,4 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Graphics;
|
||||||
|
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
@ -7,7 +7,6 @@ public class ArrayObjectListener implements MouseListener {
|
|||||||
private final Line line;
|
private final Line line;
|
||||||
private final Frame frame;
|
private final Frame frame;
|
||||||
|
|
||||||
|
|
||||||
public ArrayObjectListener(Line line, Frame frame) {
|
public ArrayObjectListener(Line line, Frame frame) {
|
||||||
this.line = line;
|
this.line = line;
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
@ -24,14 +23,18 @@ public class ArrayObjectListener implements MouseListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {}
|
public void mousePressed(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {}
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {}
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) {}
|
public void mouseExited(MouseEvent e) {
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,9 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Graphics;
|
||||||
|
|
||||||
|
import fr.sae.JSonInspector.Exception.JsonSyntaxException;
|
||||||
|
import fr.sae.JSonInspector.Main;
|
||||||
|
import fr.sae.JSonInspector.Settings.Parameters;
|
||||||
|
import fr.sae.JSonInspector.Storage.Tree;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -15,25 +20,22 @@ public class Frame extends JFrame {
|
|||||||
private GraphicFile file;
|
private GraphicFile file;
|
||||||
private Tree tree;
|
private Tree tree;
|
||||||
|
|
||||||
|
|
||||||
public Frame() {
|
public Frame() {
|
||||||
super("Inspecteur JSON");
|
super("Inspecteur JSON");
|
||||||
init();
|
init();
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
this.setSize(DEFAULT_FRAME_SIZE);
|
this.setSize(DEFAULT_FRAME_SIZE);
|
||||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
this.setMinimumSize(MINIMUM_FRAME_SIZE);
|
this.setMinimumSize(MINIMUM_FRAME_SIZE);
|
||||||
this.setLayout(cards);
|
this.setLayout(cards);
|
||||||
this.add(firstCard());
|
this.add(firstCard());
|
||||||
//this.add(secondCard());
|
// this.add(secondCard());
|
||||||
cards.first(this.getContentPane());
|
cards.first(this.getContentPane());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel firstCard() {
|
private JPanel firstCard() {
|
||||||
GridBagLayout layout = new GridBagLayout();
|
GridBagLayout layout = new GridBagLayout();
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
@ -44,8 +46,8 @@ public class Frame extends JFrame {
|
|||||||
panel.setLayout(layout);
|
panel.setLayout(layout);
|
||||||
|
|
||||||
gbc.insets = new Insets(10, 10, 10, 10);
|
gbc.insets = new Insets(10, 10, 10, 10);
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
gbc.gridy = 0;
|
gbc.gridy = 0;
|
||||||
JLabel label = new JLabel("URL :");
|
JLabel label = new JLabel("URL :");
|
||||||
label.setForeground(Parameters.DEFAULT_TEXT_COLOR);
|
label.setForeground(Parameters.DEFAULT_TEXT_COLOR);
|
||||||
panel.add(label, gbc);
|
panel.add(label, gbc);
|
||||||
@ -53,8 +55,8 @@ public class Frame extends JFrame {
|
|||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
panel.add(textField, gbc);
|
panel.add(textField, gbc);
|
||||||
|
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
gbc.gridy = 1;
|
gbc.gridy = 1;
|
||||||
gbc.gridwidth = 2;
|
gbc.gridwidth = 2;
|
||||||
panel.add(button, gbc);
|
panel.add(button, gbc);
|
||||||
|
|
||||||
@ -62,19 +64,16 @@ public class Frame extends JFrame {
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel secondCard() {
|
private JPanel secondCard() {
|
||||||
file = new GraphicFile(this, tree);
|
file = new GraphicFile(this, tree);
|
||||||
return initSecondCard(file);
|
return initSecondCard(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel secondCard(GraphicFile file) {
|
private JPanel secondCard(GraphicFile file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
return initSecondCard(file);
|
return initSecondCard(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel initSecondCard(GraphicFile file) {
|
private JPanel initSecondCard(GraphicFile file) {
|
||||||
JButton unfoldButton = new JButton("Tout déplier");
|
JButton unfoldButton = new JButton("Tout déplier");
|
||||||
JButton retreatButton = new JButton("Tout replier");
|
JButton retreatButton = new JButton("Tout replier");
|
||||||
@ -100,19 +99,16 @@ public class Frame extends JFrame {
|
|||||||
return mainPanel;
|
return mainPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void unfoldAction() {
|
private void unfoldAction() {
|
||||||
file.showAll();
|
file.showAll();
|
||||||
repaintFile();
|
repaintFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void retreatAction() {
|
private void retreatAction() {
|
||||||
file.retreatAll();
|
file.retreatAll();
|
||||||
repaintFile();
|
repaintFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void repaintFile() {
|
public void repaintFile() {
|
||||||
file = new GraphicFile(this, file.getLines());
|
file = new GraphicFile(this, file.getLines());
|
||||||
this.remove(secondCard);
|
this.remove(secondCard);
|
||||||
@ -121,7 +117,6 @@ public class Frame extends JFrame {
|
|||||||
cards.last(this.getContentPane());
|
cards.last(this.getContentPane());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void validationAction(JTextField field) {
|
private void validationAction(JTextField field) {
|
||||||
try {
|
try {
|
||||||
URL url = new URL(field.getText());
|
URL url = new URL(field.getText());
|
||||||
@ -147,7 +142,6 @@ public class Frame extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void backAction(JPanel panel) {
|
private void backAction(JPanel panel) {
|
||||||
this.remove(panel);
|
this.remove(panel);
|
||||||
cards.first(this.getContentPane());
|
cards.first(this.getContentPane());
|
@ -1,4 +1,10 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Graphics;
|
||||||
|
|
||||||
|
import fr.sae.JSonInspector.Settings.Parameters;
|
||||||
|
import fr.sae.JSonInspector.Storage.Node;
|
||||||
|
import fr.sae.JSonInspector.Storage.Tree;
|
||||||
|
import fr.sae.JSonInspector.Storage.Type;
|
||||||
|
import fr.sae.JSonInspector.Storage.Value;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -11,7 +17,6 @@ public class GraphicFile extends JPanel {
|
|||||||
private ArrayList<Line> lines;
|
private ArrayList<Line> lines;
|
||||||
private Node firstNode;
|
private Node firstNode;
|
||||||
|
|
||||||
|
|
||||||
public GraphicFile(Frame frame, Tree tree) {
|
public GraphicFile(Frame frame, Tree tree) {
|
||||||
super();
|
super();
|
||||||
firstNode = tree.getFirstNode();
|
firstNode = tree.getFirstNode();
|
||||||
@ -19,21 +24,19 @@ public class GraphicFile extends JPanel {
|
|||||||
lines = new ArrayList<>();
|
lines = new ArrayList<>();
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
createFileRecursive(firstNode, 0, false);
|
createFileRecursive(firstNode, 0, false);
|
||||||
//displayAllLines();
|
// displayAllLines();
|
||||||
displayLines();
|
displayLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public GraphicFile(Frame frame, ArrayList<Line> lines) {
|
public GraphicFile(Frame frame, ArrayList<Line> lines) {
|
||||||
super();
|
super();
|
||||||
init();
|
init();
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
//displayAllLines();
|
// displayAllLines();
|
||||||
displayLines();
|
displayLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
this.setBackground(Parameters.BACKGROUND_COLOR);
|
this.setBackground(Parameters.BACKGROUND_COLOR);
|
||||||
this.setLayout(new FlowLayout(FlowLayout.LEFT));
|
this.setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||||
@ -43,7 +46,6 @@ public class GraphicFile extends JPanel {
|
|||||||
this.add(alignementPanel);
|
this.add(alignementPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createFileRecursive(Node node, int depth, boolean virgule) {
|
private void createFileRecursive(Node node, int depth, boolean virgule) {
|
||||||
String indentation = "";
|
String indentation = "";
|
||||||
|
|
||||||
@ -62,7 +64,6 @@ public class GraphicFile extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createPair(Node node, int depth, String indentation, boolean virgule) {
|
private void createPair(Node node, int depth, String indentation, boolean virgule) {
|
||||||
Line line = new Line(node, depth);
|
Line line = new Line(node, depth);
|
||||||
line.add(indentation);
|
line.add(indentation);
|
||||||
@ -72,7 +73,7 @@ public class GraphicFile extends JPanel {
|
|||||||
if (node.getSize() != 0) {
|
if (node.getSize() != 0) {
|
||||||
createValue(line, node.get(0));
|
createValue(line, node.get(0));
|
||||||
} else {
|
} else {
|
||||||
line.add("null" , Parameters.OTHER_COLOR);
|
line.add("null", Parameters.OTHER_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virgule) {
|
if (virgule) {
|
||||||
@ -82,7 +83,6 @@ public class GraphicFile extends JPanel {
|
|||||||
lines.add(line);
|
lines.add(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createObjectElement(Node node, int depth, String indentation, boolean virgule) {
|
private void createObjectElement(Node node, int depth, String indentation, boolean virgule) {
|
||||||
Line line = new Line(node, depth);
|
Line line = new Line(node, depth);
|
||||||
line.add(indentation);
|
line.add(indentation);
|
||||||
@ -121,7 +121,6 @@ public class GraphicFile extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createArray(Node node, int depth, String indentation, boolean virgule) {
|
private void createArray(Node node, int depth, String indentation, boolean virgule) {
|
||||||
Line line = new Line(node, depth);
|
Line line = new Line(node, depth);
|
||||||
line.add(indentation);
|
line.add(indentation);
|
||||||
@ -173,7 +172,6 @@ public class GraphicFile extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createValue(Line line, Value value) {
|
private void createValue(Line line, Value value) {
|
||||||
if (value.isNumber()) {
|
if (value.isNumber()) {
|
||||||
line.add("" + value.getValue(), Parameters.NUMBER_COLOR);
|
line.add("" + value.getValue(), Parameters.NUMBER_COLOR);
|
||||||
@ -184,7 +182,6 @@ public class GraphicFile extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void callNextNodes(Node node, int depth) {
|
private void callNextNodes(Node node, int depth) {
|
||||||
boolean virgule;
|
boolean virgule;
|
||||||
|
|
||||||
@ -199,7 +196,6 @@ public class GraphicFile extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void displayLines() {
|
private void displayLines() {
|
||||||
boolean inArrayObject = false, array, object;
|
boolean inArrayObject = false, array, object;
|
||||||
Node openedArrayObject = lines.get(0).getNode();
|
Node openedArrayObject = lines.get(0).getNode();
|
||||||
@ -210,7 +206,8 @@ public class GraphicFile extends JPanel {
|
|||||||
array = lines.get(i).getNode().isArray();
|
array = lines.get(i).getNode().isArray();
|
||||||
object = lines.get(i).getNode().isObject();
|
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é
|
// 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()) {
|
if ((array || object) && !lines.get(i).isShow()) {
|
||||||
inArrayObject = true;
|
inArrayObject = true;
|
||||||
openedArrayObject = lines.get(i).getNode();
|
openedArrayObject = lines.get(i).getNode();
|
||||||
@ -221,7 +218,7 @@ public class GraphicFile extends JPanel {
|
|||||||
displayOneHidedLine(i, Parameters.OBJECT_ELEMENT_CLOSING);
|
displayOneHidedLine(i, Parameters.OBJECT_ELEMENT_CLOSING);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sinon affiche la ligne normalement
|
// Sinon affiche la ligne normalement
|
||||||
} else {
|
} else {
|
||||||
displayOneLine(i);
|
displayOneLine(i);
|
||||||
}
|
}
|
||||||
@ -232,7 +229,6 @@ public class GraphicFile extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void displayOneLine(int index) {
|
private void displayOneLine(int index) {
|
||||||
gbc.gridy = index;
|
gbc.gridy = index;
|
||||||
|
|
||||||
@ -240,7 +236,6 @@ public class GraphicFile extends JPanel {
|
|||||||
alignementPanel.add(lines.get(index), gbc);
|
alignementPanel.add(lines.get(index), gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void displayOneHidedLine(int index, String endOfLine) {
|
private void displayOneHidedLine(int index, String endOfLine) {
|
||||||
gbc.gridy = index;
|
gbc.gridy = index;
|
||||||
|
|
||||||
@ -249,7 +244,6 @@ public class GraphicFile extends JPanel {
|
|||||||
alignementPanel.add(lines.get(index), gbc);
|
alignementPanel.add(lines.get(index), gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void showAll() {
|
public void showAll() {
|
||||||
for (Line line : lines) {
|
for (Line line : lines) {
|
||||||
if (!line.isShow()) {
|
if (!line.isShow()) {
|
||||||
@ -259,7 +253,6 @@ public class GraphicFile extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void retreatAll() {
|
public void retreatAll() {
|
||||||
for (Line line : lines) {
|
for (Line line : lines) {
|
||||||
if (line.getNode().isArrayObjectElement()) {
|
if (line.getNode().isArrayObjectElement()) {
|
||||||
@ -270,14 +263,12 @@ public class GraphicFile extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void removeAllClosingLabel() {
|
private void removeAllClosingLabel() {
|
||||||
for(Line line : lines) {
|
for (Line line : lines) {
|
||||||
line.removeClosingLabel();
|
line.removeClosingLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<Line> getLines() {
|
public ArrayList<Line> getLines() {
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
@ -1,4 +1,8 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Graphics;
|
||||||
|
|
||||||
|
import fr.sae.JSonInspector.Graphics.MyJLabel;
|
||||||
|
import fr.sae.JSonInspector.Graphics.MyJPanel;
|
||||||
|
import fr.sae.JSonInspector.Storage.Node;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
@ -9,14 +13,12 @@ public class Line extends MyJPanel {
|
|||||||
private MyJLabel lastElement;
|
private MyJLabel lastElement;
|
||||||
private boolean closingElement = false;
|
private boolean closingElement = false;
|
||||||
|
|
||||||
|
|
||||||
public Line(Node node, int depth) {
|
public Line(Node node, int depth) {
|
||||||
super();
|
super();
|
||||||
this.node = node;
|
this.node = node;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Line(Node node, String str, int depth) {
|
public Line(Node node, String str, int depth) {
|
||||||
super();
|
super();
|
||||||
this.add(new MyJLabel(str));
|
this.add(new MyJLabel(str));
|
||||||
@ -24,7 +26,6 @@ public class Line extends MyJPanel {
|
|||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Line(Node node, String str, Color color, int depth) {
|
public Line(Node node, String str, Color color, int depth) {
|
||||||
super();
|
super();
|
||||||
this.add(new MyJLabel(str, color));
|
this.add(new MyJLabel(str, color));
|
||||||
@ -32,61 +33,51 @@ public class Line extends MyJPanel {
|
|||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void add(String string) {
|
public void add(String string) {
|
||||||
lastElement = new MyJLabel(string);
|
lastElement = new MyJLabel(string);
|
||||||
this.add(lastElement);
|
this.add(lastElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void add(String string, Color color) {
|
public void add(String string, Color color) {
|
||||||
lastElement = new MyJLabel(string, color);
|
lastElement = new MyJLabel(string, color);
|
||||||
this.add(lastElement);
|
this.add(lastElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Node getNode() {
|
public Node getNode() {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getDepth() {
|
public int getDepth() {
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isShow() {
|
public boolean isShow() {
|
||||||
return show;
|
return show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void unfold() {
|
public void unfold() {
|
||||||
show = true;
|
show = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void retreat() {
|
public void retreat() {
|
||||||
show = false;
|
show = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setClosingElement() {
|
public void setClosingElement() {
|
||||||
closingElement = true;
|
closingElement = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isClosingElement() {
|
public boolean isClosingElement() {
|
||||||
return closingElement;
|
return closingElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void removeClosingLabel() {
|
public void removeClosingLabel() {
|
||||||
try {
|
try {
|
||||||
if (lastElement.getText().equals("...]") || lastElement.getText().equals("...}")) {
|
if (lastElement.getText().equals("...]") || lastElement.getText().equals("...}")) {
|
||||||
this.remove(lastElement);
|
this.remove(lastElement);
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
//System.out.println("La ligne est vide");
|
// System.out.println("La ligne est vide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Graphics;
|
||||||
|
|
||||||
|
import fr.sae.JSonInspector.Settings.Parameters;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -6,13 +8,13 @@ import java.awt.*;
|
|||||||
public class MyJLabel extends JLabel {
|
public class MyJLabel extends JLabel {
|
||||||
public MyJLabel(String text, Color color) {
|
public MyJLabel(String text, Color color) {
|
||||||
super(text);
|
super(text);
|
||||||
//this.setFont(Parameters.FILE_FONT);
|
// this.setFont(Parameters.FILE_FONT);
|
||||||
this.setForeground(color);
|
this.setForeground(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyJLabel(String text) {
|
public MyJLabel(String text) {
|
||||||
super(text);
|
super(text);
|
||||||
//this.setFont(Parameters.FILE_FONT);
|
// this.setFont(Parameters.FILE_FONT);
|
||||||
this.setForeground(Parameters.DEFAULT_TEXT_COLOR);
|
this.setForeground(Parameters.DEFAULT_TEXT_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Graphics;
|
||||||
|
|
||||||
|
import fr.sae.JSonInspector.Settings.Parameters;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
@ -1,5 +1,8 @@
|
|||||||
package JsonInspector;
|
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.io.*;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -8,7 +11,6 @@ public class Main {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
new Frame();
|
new Frame();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
URL url = new URL(args[0]);
|
URL url = new URL(args[0]);
|
||||||
@ -44,7 +46,6 @@ public class Main {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String cleanFile(String file) {
|
public static String cleanFile(String file) {
|
||||||
char[] chars = file.toCharArray();
|
char[] chars = file.toCharArray();
|
||||||
boolean inString = false, inValue = false;
|
boolean inString = false, inValue = false;
|
||||||
@ -72,13 +73,12 @@ public class Main {
|
|||||||
return cleanedFile;
|
return cleanedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static boolean isJsonSyntax(char character) {
|
private static boolean isJsonSyntax(char character) {
|
||||||
boolean openingArray = character == '[', closingArray = character == ']';
|
boolean openingArray = character == '[', closingArray = character == ']';
|
||||||
boolean openingObject = character == '{', closingObject = character == '}';
|
boolean openingObject = character == '{', closingObject = character == '}';
|
||||||
boolean virgule = character == ',', deuxPoints = character == ':';
|
boolean virgule = character == ',', deuxPoints = character == ':';
|
||||||
|
|
||||||
if (openingArray||closingArray||openingObject||closingObject||virgule||deuxPoints) {
|
if (openingArray || closingArray || openingObject || closingObject || virgule || deuxPoints) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
@ -1,4 +1,4 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Settings;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
@ -1,15 +1,12 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Storage;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
public class Node {
|
public class Node {
|
||||||
private final ArrayList<Value> values = new ArrayList<>();
|
private final ArrayList<Value> values = new ArrayList<>();
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
|
|
||||||
public Node(String name, Type type) {
|
public Node(String name, Type type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
if (type == Type.ELEMENT) {
|
if (type == Type.ELEMENT) {
|
||||||
@ -19,9 +16,8 @@ public class Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void findType(String value) {
|
private void findType(String value) {
|
||||||
if (value.charAt(0) == '"' && value.charAt(value.length()-1) == '"') {
|
if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') {
|
||||||
values.add(new Value<String>(Tree.cleanOpeningExpression(value)));
|
values.add(new Value<String>(Tree.cleanOpeningExpression(value)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -37,7 +33,6 @@ public class Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public <T> void add(T value) {
|
public <T> void add(T value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
if (value.getClass().equals(Node.class)) {
|
if (value.getClass().equals(Node.class)) {
|
||||||
@ -48,47 +43,38 @@ public class Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Value get(int index) {
|
public Value get(int index) {
|
||||||
return values.get(index);
|
return values.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return values.size();
|
return values.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isObject() {
|
public boolean isObject() {
|
||||||
return type == Type.OBJECT;
|
return type == Type.OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isArray() {
|
public boolean isArray() {
|
||||||
return type == Type.ARRAY;
|
return type == Type.ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isElement() {
|
public boolean isElement() {
|
||||||
return type == Type.ELEMENT;
|
return type == Type.ELEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isPair() {
|
public boolean isPair() {
|
||||||
return type == Type.PAIR;
|
return type == Type.PAIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isArrayObjectElement() {
|
public boolean isArrayObjectElement() {
|
||||||
boolean array = type == Type.ARRAY;
|
boolean array = type == Type.ARRAY;
|
||||||
boolean object = type == Type.OBJECT;
|
boolean object = type == Type.OBJECT;
|
||||||
@ -101,7 +87,6 @@ public class Node {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String string = name + " : ";
|
String string = name + " : ";
|
@ -1,14 +1,12 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Storage;
|
||||||
|
|
||||||
public class Other {
|
public class Other {
|
||||||
String value;
|
String value;
|
||||||
|
|
||||||
|
|
||||||
public Other(String value) {
|
public Other(String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return value;
|
return value;
|
@ -1,16 +1,17 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Storage;
|
||||||
|
|
||||||
|
import fr.sae.JSonInspector.Exception.JsonSyntaxException;
|
||||||
|
import fr.sae.JSonInspector.Settings.Parameters;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Tree {
|
public class Tree {
|
||||||
private Node firstNode;
|
private Node firstNode;
|
||||||
|
|
||||||
|
|
||||||
public Tree(String file) throws JsonSyntaxException {
|
public Tree(String file) throws JsonSyntaxException {
|
||||||
firstNode = parseElement(file);
|
firstNode = parseElement(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Node whichType(String element) throws JsonSyntaxException {
|
private Node whichType(String element) throws JsonSyntaxException {
|
||||||
String[] keyValue = splitKeyValue(element);
|
String[] keyValue = splitKeyValue(element);
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ public class Tree {
|
|||||||
|
|
||||||
} else if (keyValue[0].equals("")) {
|
} else if (keyValue[0].equals("")) {
|
||||||
|
|
||||||
if (keyValue[0].charAt(0) == '{' && keyValue[0].charAt(keyValue[0].length()-1) == '}') {
|
if (keyValue[0].charAt(0) == '{' && keyValue[0].charAt(keyValue[0].length() - 1) == '}') {
|
||||||
return parseElement(keyValue[0]);
|
return parseElement(keyValue[0]);
|
||||||
} else {
|
} else {
|
||||||
throw new JsonSyntaxException();
|
throw new JsonSyntaxException();
|
||||||
@ -44,7 +45,6 @@ public class Tree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Node parseArray(String name, String rawValues) throws JsonSyntaxException {
|
private Node parseArray(String name, String rawValues) throws JsonSyntaxException {
|
||||||
Node array = new Node(cleanOpeningExpression(name), Type.ARRAY);
|
Node array = new Node(cleanOpeningExpression(name), Type.ARRAY);
|
||||||
ArrayList<String> elements = splitList(rawValues);
|
ArrayList<String> elements = splitList(rawValues);
|
||||||
@ -67,7 +67,6 @@ public class Tree {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Node parseObject(String name, String rawValues) throws JsonSyntaxException {
|
private Node parseObject(String name, String rawValues) throws JsonSyntaxException {
|
||||||
Node object = new Node(cleanOpeningExpression(name), Type.OBJECT);
|
Node object = new Node(cleanOpeningExpression(name), Type.OBJECT);
|
||||||
ArrayList<String> elements = splitList(rawValues);
|
ArrayList<String> elements = splitList(rawValues);
|
||||||
@ -79,7 +78,6 @@ public class Tree {
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Node parsePair(String name, String value) {
|
private Node parsePair(String name, String value) {
|
||||||
Node pair = new Node(cleanOpeningExpression(name), Type.PAIR);
|
Node pair = new Node(cleanOpeningExpression(name), Type.PAIR);
|
||||||
pair.add(value);
|
pair.add(value);
|
||||||
@ -87,7 +85,6 @@ public class Tree {
|
|||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Node parseElement(String rawValues) throws JsonSyntaxException {
|
private Node parseElement(String rawValues) throws JsonSyntaxException {
|
||||||
Node element = new Node("", Type.ELEMENT);
|
Node element = new Node("", Type.ELEMENT);
|
||||||
ArrayList<String> elements = splitList(rawValues);
|
ArrayList<String> elements = splitList(rawValues);
|
||||||
@ -99,15 +96,13 @@ public class Tree {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String cleanOpeningExpression(String strToClean) {
|
public static String cleanOpeningExpression(String strToClean) {
|
||||||
StringBuilder cleanedString = new StringBuilder(strToClean);
|
StringBuilder cleanedString = new StringBuilder(strToClean);
|
||||||
cleanedString.deleteCharAt(0);
|
cleanedString.deleteCharAt(0);
|
||||||
cleanedString.deleteCharAt(cleanedString.length()-1);
|
cleanedString.deleteCharAt(cleanedString.length() - 1);
|
||||||
return cleanedString.toString();
|
return cleanedString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ArrayList<String> splitList(String listToSplit) {
|
private ArrayList<String> splitList(String listToSplit) {
|
||||||
char[] chars = cleanOpeningExpression(listToSplit).toCharArray();
|
char[] chars = cleanOpeningExpression(listToSplit).toCharArray();
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
@ -132,7 +127,6 @@ public class Tree {
|
|||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String[] splitKeyValue(String expressionToSplit) {
|
private String[] splitKeyValue(String expressionToSplit) {
|
||||||
boolean inKey = true;
|
boolean inKey = true;
|
||||||
char[] chars = expressionToSplit.toCharArray();
|
char[] chars = expressionToSplit.toCharArray();
|
||||||
@ -156,15 +150,14 @@ public class Tree {
|
|||||||
}
|
}
|
||||||
value = buffer;
|
value = buffer;
|
||||||
|
|
||||||
return new String[] {key, value};
|
return new String[] { key, value };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String printTree(Node node, int depth) {
|
public static String printTree(Node node, int depth) {
|
||||||
String line = "", indentation = "";
|
String line = "", indentation = "";
|
||||||
|
|
||||||
//créé l'indentation de la bonne taille en fonction de la
|
// créé l'indentation de la bonne taille en fonction de la
|
||||||
//profondeur dans l'arbre
|
// profondeur dans l'arbre
|
||||||
for (int i = 0; i < depth; i++) {
|
for (int i = 0; i < depth; i++) {
|
||||||
indentation += Parameters.CONSOLE_INDENTATION;
|
indentation += Parameters.CONSOLE_INDENTATION;
|
||||||
}
|
}
|
||||||
@ -175,21 +168,19 @@ public class Tree {
|
|||||||
line += indentation + node.getName();
|
line += indentation + node.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (node.isObject() || node.isElement()) {
|
if (node.isObject() || node.isElement()) {
|
||||||
line += printObjectElement(node, depth, indentation);
|
line += printObjectElement(node, depth, indentation);
|
||||||
|
|
||||||
} else if (node.isPair()){
|
} else if (node.isPair()) {
|
||||||
line += printPair(node);
|
line += printPair(node);
|
||||||
|
|
||||||
} else if (node.isArray()){
|
} else if (node.isArray()) {
|
||||||
line += printArray(node, depth, indentation);
|
line += printArray(node, depth, indentation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String callNextNodes(Node node, int depth) {
|
private static String callNextNodes(Node node, int depth) {
|
||||||
String line = "";
|
String line = "";
|
||||||
|
|
||||||
@ -206,7 +197,6 @@ public class Tree {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String printPair(Node node) {
|
private static String printPair(Node node) {
|
||||||
String line = "";
|
String line = "";
|
||||||
|
|
||||||
@ -224,7 +214,6 @@ public class Tree {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String printObjectElement(Node node, int depth, String indentation) {
|
private static String printObjectElement(Node node, int depth, String indentation) {
|
||||||
String line = "";
|
String line = "";
|
||||||
|
|
||||||
@ -244,7 +233,6 @@ public class Tree {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String printArray(Node node, int depth, String indentation) {
|
private static String printArray(Node node, int depth, String indentation) {
|
||||||
String line = "";
|
String line = "";
|
||||||
line += ": [";
|
line += ": [";
|
||||||
@ -261,11 +249,11 @@ public class Tree {
|
|||||||
line += "\n" + printTree((Node) node.get(i).getValue(), depth + 1);
|
line += "\n" + printTree((Node) node.get(i).getValue(), depth + 1);
|
||||||
} else {
|
} else {
|
||||||
line += "\n" + indentation + Parameters.CONSOLE_INDENTATION;
|
line += "\n" + indentation + Parameters.CONSOLE_INDENTATION;
|
||||||
if (node.get(i).isString()) {
|
if (node.get(i).isString()) {
|
||||||
line += "\"" + node.get(i).getValue() + "\"";
|
line += "\"" + node.get(i).getValue() + "\"";
|
||||||
} else {
|
} else {
|
||||||
line += node.get(i).getValue();
|
line += node.get(i).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// si la valeur n'est pas la dernière alors on lui ajoute une virgule
|
// si la valeur n'est pas la dernière alors on lui ajoute une virgule
|
||||||
@ -280,13 +268,11 @@ public class Tree {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return printTree(firstNode, 0);
|
return printTree(firstNode, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Node getFirstNode() {
|
public Node getFirstNode() {
|
||||||
return firstNode;
|
return firstNode;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Storage;
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
OBJECT, ELEMENT, ARRAY, PAIR, NULL
|
OBJECT, ELEMENT, ARRAY, PAIR, NULL
|
@ -1,19 +1,16 @@
|
|||||||
package JsonInspector;
|
package fr.sae.JSonInspector.Storage;
|
||||||
|
|
||||||
public class Value <T> {
|
public class Value<T> {
|
||||||
private T value;
|
private T value;
|
||||||
|
|
||||||
|
|
||||||
public Value(T value) {
|
public Value(T value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public T getValue() {
|
public T getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isObjectOrArray() {
|
public boolean isObjectOrArray() {
|
||||||
if (value.getClass().equals(Node.class)) {
|
if (value.getClass().equals(Node.class)) {
|
||||||
Node node = (Node) value;
|
Node node = (Node) value;
|
||||||
@ -27,17 +24,14 @@ public class Value <T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isNode() {
|
public boolean isNode() {
|
||||||
return value.getClass().equals(Node.class);
|
return value.getClass().equals(Node.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isString() {
|
||||||
public boolean isString () {
|
|
||||||
return value.getClass().equals(String.class);
|
return value.getClass().equals(String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isNumber() {
|
public boolean isNumber() {
|
||||||
return value.getClass().equals(Integer.class) || value.getClass().equals(Double.class);
|
return value.getClass().equals(Integer.class) || value.getClass().equals(Double.class);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user