1 package org.matsim.core.events.algorithms;
3 import com.fasterxml.jackson.core.JsonFactory;
4 import com.fasterxml.jackson.core.JsonGenerator;
5 import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
11 import java.io.IOException;
12 import java.io.OutputStream;
13 import java.io.UncheckedIOException;
21 private OutputStream
out = null;
27 this.jsonGenerator =
new JsonFactory().createGenerator(this.out);
28 this.jsonGenerator.setPrettyPrinter(
new MinimalPrettyPrinter(
"\n"));
29 }
catch (IOException e) {
30 throw new UncheckedIOException(e);
37 this.jsonGenerator =
new JsonFactory().createGenerator(this.out);
38 this.jsonGenerator.setPrettyPrinter(
new MinimalPrettyPrinter(
"\n"));
39 }
catch (IOException e) {
40 throw new UncheckedIOException(e);
47 this.jsonGenerator.close();
49 }
catch (IOException e) {
50 throw new UncheckedIOException(e);
57 this.jsonGenerator.writeStartObject();
58 Map<String, String> attr =
event.getAttributes();
59 for(Map.Entry<String, String> entry : attr.entrySet()) {
60 this.jsonGenerator.writeStringField(entry.getKey(), entry.getValue());
62 this.jsonGenerator.writeEndObject();
63 }
catch (IOException e) {
64 throw new UncheckedIOException(e);
69 public void reset(
final int iter) {
EventWriterJson(OutputStream stream)
static OutputStream getOutputStream(URL url, boolean append)
EventWriterJson(File outfile)
JsonGenerator jsonGenerator
void handleEvent(final Event event)
void reset(final int iter)