-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParser.java
More file actions
75 lines (71 loc) · 2.36 KB
/
Copy pathParser.java
File metadata and controls
75 lines (71 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package lab5;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.io.File;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
public class Parser {
Scanner scanner = new Scanner (System.in);
public void parse(ConcurrentLinkedDeque<Jar> x,String g, Server S) throws IOException{
File j1 = new File(""+ g);
j1.setExecutable(true);
j1.setReadable(true);
j1.setWritable(true);
String line;
String in;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(j1)))){
line=reader.readLine();
while (line != null){
Gson gs = new Gson();
x.add(gs.fromJson(line, Jar.class));
line=reader.readLine();
}
}
catch(IOException e){
Manager z = new Manager();
z.setColl(x);
System.out.println("Ôàéë íå íàéäåí(×ÒÅÍÈÅ)");
try{
while (true) {
in = scanner.nextLine();
String[] message = in.split(" ");
if (!(message[0].equals("add") || message[0].equals("add_if_max") || message[0].equals("info")||message[0].equals("import")||message[0].equals("load") || message[0].equals("terminate"))) {
System.out.println("Íå ñóùåñòâóåò òàêîé êîìàíäû");
}
else {
if (message[0].equals("terminate")) {
System.exit(0);
}
z.Analyze(in, S);
}
S.send(x);
}}catch(Exception h){System.exit(0);};
}
catch (JsonSyntaxException e){
Manager z = new Manager();
z.setColl(x);
System.out.println("Íåâåðíûé ôîðìàò ôàéëà");
try{
while (true) {
in = scanner.nextLine();
String[] message = in.split(" ");
if (!(message[0].equals("add") || message[0].equals("add_if_max") || message[0].equals("info")||message[0].equals("import")||message[0].equals("load") || message[0].equals("terminate"))) {
System.out.println("Íå ñóùåñòâóåò òàêîé êîìàíäû");
}
else {
if (message[0].equals("terminate")) {
System.exit(0);
}
z.Analyze(in, S);
}
S.send(x);
}}catch(Exception h){System.exit(0);};
}
}
}