diff --git a/src/main/java/br/ufrgs/inf/prosoft/trace/tools/CheckTraces.java b/src/main/java/br/ufrgs/inf/prosoft/trace/tools/CheckTraces.java
new file mode 100644
index 0000000..9227e99
--- /dev/null
+++ b/src/main/java/br/ufrgs/inf/prosoft/trace/tools/CheckTraces.java
@@ -0,0 +1,64 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package br.ufrgs.inf.prosoft.trace.tools;
+
+import br.ufrgs.inf.prosoft.trace.TraceConcrete;
+import br.ufrgs.inf.prosoft.trace.reader.TraceReader;
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.function.Consumer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Stream;
+
+/**
+ *
+ * @author romulo
+ */
+public class CheckTraces {
+
+ private static final Logger LOGGER = Logger.getLogger(CheckTraces.class.getName());
+
+ public static void check(String inputPath) {
+ try {
+ LOGGER.log(Level.INFO, "Checking {0} traces", TraceReader.getLineCount(inputPath));
+ Stream<String> lines = Files.lines(Paths.get(inputPath));
+ lines.forEach(new Consumer<String>() {
+ private int index = 0;
+ private final Gson gson;
+
+ {
+ this.gson = new Gson();
+ }
+
+ @Override
+ public void accept(String line) {
+ try {
+ gson.fromJson(line, TraceConcrete.class);
+ System.out.print(".");
+ System.out.flush();
+ if (index != 0 && index % 100 == 0) {
+ System.out.println();
+ }
+ } catch (JsonSyntaxException e) {
+ if (line.length() > 2000) {
+ line = line.substring(0, 2000);
+ }
+ LOGGER.log(Level.INFO, "Malformed Trace {0}: {1}", new java.lang.Object[]{index, line});
+ } finally {
+ index++;
+ }
+ }
+ });
+ } catch (IOException ex) {
+ LOGGER.log(Level.SEVERE, null, ex);
+ }
+ }
+}
diff --git a/src/main/java/br/ufrgs/inf/prosoft/trace/tools/Main.java b/src/main/java/br/ufrgs/inf/prosoft/trace/tools/Main.java
index 23e0b5b..2616ed0 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/trace/tools/Main.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/trace/tools/Main.java
@@ -20,19 +20,28 @@ public class Main {
String tool = null;
String firstPath = null;
String secondPath = null;
- if (args.length < 3) {
- System.err.println("<diff> <FirstTracePath> <SecondTracePath>");
- System.err.println("<hash> <InputTracePath> <OutputTracePath>");
+ if (args.length < 2) {
+ System.err.println("check <TracePath>");
+ System.err.println("diff <FirstTracePath> <SecondTracePath>");
+ System.err.println("hash <InputTracePath> <OutputTracePath>");
System.exit(1);
- } else {
- tool = args[0];
- firstPath = args[1];
- secondPath = args[2];
}
- if (tool.equals("diff")) {
- DiffTraces.diff(firstPath, secondPath);
+ tool = args[0];
+ if (tool.equals("check")) {
+ firstPath = args[1];
+ CheckTraces.check(firstPath);
} else {
- HashFile.convert(firstPath, secondPath);
+ if (args.length < 3) {
+ System.err.println("diff <FirstTracePath> <SecondTracePath>");
+ System.err.println("hash <InputTracePath> <OutputTracePath>");
+ System.exit(1);
+ }
+ secondPath = args[2];
+ if (tool.equals("diff")) {
+ DiffTraces.diff(firstPath, secondPath);
+ } else {
+ HashFile.convert(firstPath, secondPath);
+ }
}
}
}