This commit is contained in:
pro.boooooo 2023-01-15 20:37:28 +01:00
parent 068f0f3b50
commit 3175d93380
16 changed files with 168 additions and 179 deletions

90
src/.idea/workspace.xml generated Normal file
View 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>

View File

@ -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();
}
}

View File

@ -1,4 +1,4 @@
package JsonInspector;
package fr.sae.JSonInspector.Exception;
public class JsonSyntaxException extends Throwable {
private static final String MESSAGE = "Syntax error in JSON file";

View File

@ -1,4 +1,4 @@
package JsonInspector;
package fr.sae.JSonInspector.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@ -7,7 +7,6 @@ public class ArrayObjectListener implements MouseListener {
private final Line line;
private final Frame frame;
public ArrayObjectListener(Line line, Frame frame) {
this.line = line;
this.frame = frame;
@ -24,14 +23,18 @@ public class ArrayObjectListener implements MouseListener {
}
@Override
public void mousePressed(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {}
public void mouseExited(MouseEvent e) {
}
}

View File

@ -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 java.awt.*;
@ -15,25 +20,22 @@ public class Frame extends JFrame {
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());
// this.add(secondCard());
cards.first(this.getContentPane());
}
private JPanel firstCard() {
GridBagLayout layout = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
@ -62,19 +64,16 @@ public class Frame extends JFrame {
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");
@ -100,19 +99,16 @@ public class Frame extends JFrame {
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);
@ -121,7 +117,6 @@ public class Frame extends JFrame {
cards.last(this.getContentPane());
}
private void validationAction(JTextField field) {
try {
URL url = new URL(field.getText());
@ -147,7 +142,6 @@ public class Frame extends JFrame {
}
}
private void backAction(JPanel panel) {
this.remove(panel);
cards.first(this.getContentPane());

View File

@ -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 java.awt.*;
@ -11,7 +17,6 @@ public class GraphicFile extends JPanel {
private ArrayList<Line> lines;
private Node firstNode;
public GraphicFile(Frame frame, Tree tree) {
super();
firstNode = tree.getFirstNode();
@ -19,21 +24,19 @@ public class GraphicFile extends JPanel {
lines = new ArrayList<>();
this.frame = frame;
createFileRecursive(firstNode, 0, false);
//displayAllLines();
// displayAllLines();
displayLines();
}
public GraphicFile(Frame frame, ArrayList<Line> lines) {
super();
init();
this.frame = frame;
this.lines = lines;
//displayAllLines();
// displayAllLines();
displayLines();
}
private void init() {
this.setBackground(Parameters.BACKGROUND_COLOR);
this.setLayout(new FlowLayout(FlowLayout.LEFT));
@ -43,7 +46,6 @@ public class GraphicFile extends JPanel {
this.add(alignementPanel);
}
private void createFileRecursive(Node node, int depth, boolean virgule) {
String indentation = "";
@ -62,7 +64,6 @@ public class GraphicFile extends JPanel {
}
}
private void createPair(Node node, int depth, String indentation, boolean virgule) {
Line line = new Line(node, depth);
line.add(indentation);
@ -72,7 +73,7 @@ public class GraphicFile extends JPanel {
if (node.getSize() != 0) {
createValue(line, node.get(0));
} else {
line.add("null" , Parameters.OTHER_COLOR);
line.add("null", Parameters.OTHER_COLOR);
}
if (virgule) {
@ -82,7 +83,6 @@ public class GraphicFile extends JPanel {
lines.add(line);
}
private void createObjectElement(Node node, int depth, String indentation, boolean virgule) {
Line line = new Line(node, depth);
line.add(indentation);
@ -121,7 +121,6 @@ public class GraphicFile extends JPanel {
}
}
private void createArray(Node node, int depth, String indentation, boolean virgule) {
Line line = new Line(node, depth);
line.add(indentation);
@ -173,7 +172,6 @@ public class GraphicFile extends JPanel {
}
}
private void createValue(Line line, Value value) {
if (value.isNumber()) {
line.add("" + value.getValue(), Parameters.NUMBER_COLOR);
@ -184,7 +182,6 @@ public class GraphicFile extends JPanel {
}
}
private void callNextNodes(Node node, int depth) {
boolean virgule;
@ -199,7 +196,6 @@ public class GraphicFile extends JPanel {
}
}
private void displayLines() {
boolean inArrayObject = false, array, object;
Node openedArrayObject = lines.get(0).getNode();
@ -210,7 +206,8 @@ public class GraphicFile extends JPanel {
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é
// 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();
@ -221,7 +218,7 @@ public class GraphicFile extends JPanel {
displayOneHidedLine(i, Parameters.OBJECT_ELEMENT_CLOSING);
}
//Sinon affiche la ligne normalement
// Sinon affiche la ligne normalement
} else {
displayOneLine(i);
}
@ -232,7 +229,6 @@ public class GraphicFile extends JPanel {
}
}
private void displayOneLine(int index) {
gbc.gridy = index;
@ -240,7 +236,6 @@ public class GraphicFile extends JPanel {
alignementPanel.add(lines.get(index), gbc);
}
private void displayOneHidedLine(int index, String endOfLine) {
gbc.gridy = index;
@ -249,7 +244,6 @@ public class GraphicFile extends JPanel {
alignementPanel.add(lines.get(index), gbc);
}
public void showAll() {
for (Line line : lines) {
if (!line.isShow()) {
@ -259,7 +253,6 @@ public class GraphicFile extends JPanel {
}
}
public void retreatAll() {
for (Line line : lines) {
if (line.getNode().isArrayObjectElement()) {
@ -270,14 +263,12 @@ public class GraphicFile extends JPanel {
}
}
private void removeAllClosingLabel() {
for(Line line : lines) {
for (Line line : lines) {
line.removeClosingLabel();
}
}
public ArrayList<Line> getLines() {
return lines;
}

View File

@ -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.*;
@ -9,14 +13,12 @@ public class Line extends MyJPanel {
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));
@ -24,7 +26,6 @@ public class Line extends MyJPanel {
this.depth = depth;
}
public Line(Node node, String str, Color color, int depth) {
super();
this.add(new MyJLabel(str, color));
@ -32,61 +33,51 @@ public class Line extends MyJPanel {
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");
// System.out.println("La ligne est vide");
}
}
}

View File

@ -1,4 +1,6 @@
package JsonInspector;
package fr.sae.JSonInspector.Graphics;
import fr.sae.JSonInspector.Settings.Parameters;
import javax.swing.*;
import java.awt.*;
@ -6,13 +8,13 @@ import java.awt.*;
public class MyJLabel extends JLabel {
public MyJLabel(String text, Color color) {
super(text);
//this.setFont(Parameters.FILE_FONT);
// this.setFont(Parameters.FILE_FONT);
this.setForeground(color);
}
public MyJLabel(String text) {
super(text);
//this.setFont(Parameters.FILE_FONT);
// this.setFont(Parameters.FILE_FONT);
this.setForeground(Parameters.DEFAULT_TEXT_COLOR);
}
}

View File

@ -1,4 +1,6 @@
package JsonInspector;
package fr.sae.JSonInspector.Graphics;
import fr.sae.JSonInspector.Settings.Parameters;
import javax.swing.*;
import java.awt.*;

View File

@ -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.net.MalformedURLException;
import java.net.URL;
@ -8,7 +11,6 @@ public class Main {
public static void main(String[] args) {
if (args.length == 0) {
new Frame();
} else {
try {
URL url = new URL(args[0]);
@ -44,7 +46,6 @@ public class Main {
return sb.toString();
}
public static String cleanFile(String file) {
char[] chars = file.toCharArray();
boolean inString = false, inValue = false;
@ -72,13 +73,12 @@ public class Main {
return cleanedFile;
}
private static boolean isJsonSyntax(char character) {
boolean openingArray = character == '[', closingArray = character == ']';
boolean openingObject = character == '{', closingObject = character == '}';
boolean virgule = character == ',', deuxPoints = character == ':';
if (openingArray||closingArray||openingObject||closingObject||virgule||deuxPoints) {
if (openingArray || closingArray || openingObject || closingObject || virgule || deuxPoints) {
return true;
}
return false;

View File

@ -1,4 +1,4 @@
package JsonInspector;
package fr.sae.JSonInspector.Settings;
import java.awt.*;

View File

@ -1,15 +1,12 @@
package JsonInspector;
package fr.sae.JSonInspector.Storage;
import java.awt.*;
import java.util.ArrayList;
public class Node {
private final ArrayList<Value> values = new ArrayList<>();
private final String name;
private final Type type;
public Node(String name, Type type) {
this.type = type;
if (type == Type.ELEMENT) {
@ -19,9 +16,8 @@ public class Node {
}
}
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)));
return;
}
@ -37,7 +33,6 @@ public class Node {
}
}
public <T> void add(T value) {
if (value != null) {
if (value.getClass().equals(Node.class)) {
@ -48,47 +43,38 @@ public class Node {
}
}
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;
@ -101,7 +87,6 @@ public class Node {
return false;
}
@Override
public String toString() {
String string = name + " : ";

View File

@ -1,14 +1,12 @@
package JsonInspector;
package fr.sae.JSonInspector.Storage;
public class Other {
String value;
public Other(String value) {
this.value = value;
}
@Override
public String toString() {
return value;

View File

@ -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;
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);
@ -33,7 +34,7 @@ public class Tree {
} 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]);
} else {
throw new JsonSyntaxException();
@ -44,7 +45,6 @@ public class Tree {
}
}
private Node parseArray(String name, String rawValues) throws JsonSyntaxException {
Node array = new Node(cleanOpeningExpression(name), Type.ARRAY);
ArrayList<String> elements = splitList(rawValues);
@ -67,7 +67,6 @@ public class Tree {
return array;
}
private Node parseObject(String name, String rawValues) throws JsonSyntaxException {
Node object = new Node(cleanOpeningExpression(name), Type.OBJECT);
ArrayList<String> elements = splitList(rawValues);
@ -79,7 +78,6 @@ public class Tree {
return object;
}
private Node parsePair(String name, String value) {
Node pair = new Node(cleanOpeningExpression(name), Type.PAIR);
pair.add(value);
@ -87,7 +85,6 @@ public class Tree {
return pair;
}
private Node parseElement(String rawValues) throws JsonSyntaxException {
Node element = new Node("", Type.ELEMENT);
ArrayList<String> elements = splitList(rawValues);
@ -99,15 +96,13 @@ public class Tree {
return element;
}
public static String cleanOpeningExpression(String strToClean) {
StringBuilder cleanedString = new StringBuilder(strToClean);
cleanedString.deleteCharAt(0);
cleanedString.deleteCharAt(cleanedString.length()-1);
cleanedString.deleteCharAt(cleanedString.length() - 1);
return cleanedString.toString();
}
private ArrayList<String> splitList(String listToSplit) {
char[] chars = cleanOpeningExpression(listToSplit).toCharArray();
int depth = 0;
@ -132,7 +127,6 @@ public class Tree {
return elements;
}
private String[] splitKeyValue(String expressionToSplit) {
boolean inKey = true;
char[] chars = expressionToSplit.toCharArray();
@ -156,15 +150,14 @@ public class Tree {
}
value = buffer;
return new String[] {key, value};
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
// 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;
}
@ -175,21 +168,19 @@ public class Tree {
line += indentation + node.getName();
}
if (node.isObject() || node.isElement()) {
line += printObjectElement(node, depth, indentation);
} else if (node.isPair()){
} else if (node.isPair()) {
line += printPair(node);
} else if (node.isArray()){
} else if (node.isArray()) {
line += printArray(node, depth, indentation);
}
return line;
}
private static String callNextNodes(Node node, int depth) {
String line = "";
@ -206,7 +197,6 @@ public class Tree {
return line;
}
private static String printPair(Node node) {
String line = "";
@ -224,7 +214,6 @@ public class Tree {
return line;
}
private static String printObjectElement(Node node, int depth, String indentation) {
String line = "";
@ -244,7 +233,6 @@ public class Tree {
return line;
}
private static String printArray(Node node, int depth, String indentation) {
String line = "";
line += ": [";
@ -280,13 +268,11 @@ public class Tree {
return line;
}
@Override
public String toString() {
return printTree(firstNode, 0);
}
public Node getFirstNode() {
return firstNode;
}

View File

@ -1,4 +1,4 @@
package JsonInspector;
package fr.sae.JSonInspector.Storage;
public enum Type {
OBJECT, ELEMENT, ARRAY, PAIR, NULL

View File

@ -1,19 +1,16 @@
package JsonInspector;
package fr.sae.JSonInspector.Storage;
public class Value <T> {
public class Value<T> {
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;
@ -27,17 +24,14 @@ public class Value <T> {
}
}
public boolean isNode() {
return value.getClass().equals(Node.class);
}
public boolean isString () {
public boolean isString() {
return value.getClass().equals(String.class);
}
public boolean isNumber() {
return value.getClass().equals(Integer.class) || value.getClass().equals(Double.class);
}