Make the separator sign adjustable

parent c9472f6b
......@@ -2,7 +2,8 @@
"files": [ {
"type": "org.vadere.simulator.projects.dataprocessing_mtp.TimestepPedestrianIdOutputFile",
"filename": "output_ts_pid.txt",
"processors": [ 1, 2, 3, 5, 13, 14, 17 ]
"processors": [ 1, 2, 3, 5, 13, 14, 17 ],
"separator": ";"
}, {
"type": "org.vadere.simulator.projects.dataprocessing_mtp.PedestrianIdOutputFile",
"filename": "output_pid.txt",
......
......@@ -25,12 +25,15 @@ public class DataProcessingJsonManager {
private static final String TYPE_KEY = "type";
private static final String FILENAME_KEY = "filename";
private static final String FILE_PROCESSORS_KEY = "processors";
private static final String SEPARATOR_KEY = "separator";
public static final String PROCESSORS_KEY = "processors";
private static final String PROCESSORID_KEY = "id";
public static final String ATTRIBUTES_KEY = "attributes";
private static final String DEFAULT_SEPARATOR = " ";
private static ObjectMapper mapper;
public static ObjectWriter writer;
......@@ -51,6 +54,21 @@ public class DataProcessingJsonManager {
String type;
String filename;
List<Integer> processors;
private String separator;
public OutputFileStore() {
this.separator = DEFAULT_SEPARATOR;
}
public String getSeparator() {
return this.separator;
}
public void setSeparator(String separator) {
if (separator != null) {
this.separator = separator;
}
}
}
static {
......@@ -75,6 +93,7 @@ public class DataProcessingJsonManager {
OutputFile<?> file = outputFileInstantiator.createObject(fileStore.type);
file.setFileName(fileStore.filename);
file.setProcessorIds(fileStore.processors);
file.setSeparator(fileStore.getSeparator());
this.outputFiles.add(file);
}
......@@ -95,6 +114,11 @@ public class DataProcessingJsonManager {
node.put(FILENAME_KEY, outputFile.getFileName());
node.set(FILE_PROCESSORS_KEY, mapper.convertValue(outputFile.getProcessorIds(), JsonNode.class));
final String separator = outputFile.getSeparator();
if (separator != DEFAULT_SEPARATOR) {
node.put(SEPARATOR_KEY, separator);
}
return node;
}
......
......@@ -19,7 +19,7 @@ public abstract class OutputFile<K extends Comparable<K>> {
private List<Integer> processorIds;
private List<Processor<K, ?>> processors;
private static String SEPARATOR = " ";
private String separator;
OutputFile(final String... keyHeaders) {
this.keyHeaders = keyHeaders;
......@@ -35,6 +35,14 @@ public abstract class OutputFile<K extends Comparable<K>> {
this.processors.clear();
}
public String getSeparator() {
return this.separator;
}
public void setSeparator(final String separator) {
this.separator = separator;
}
@SuppressWarnings("unchecked")
public void init(final ProcessorManager manager) {
processorIds.forEach(pid -> this.processors.add((Processor<K, ?>) manager.getProcessor(pid)));
......@@ -76,7 +84,7 @@ public abstract class OutputFile<K extends Comparable<K>> {
}
private void writeLine(PrintWriter out, final List<String> fields) {
out.println(String.join(SEPARATOR, fields));
out.println(String.join(this.separator, fields));
}
/** Return the column headers as string or the empty array. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment