net.intelie.pipes.util.SpanReprHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pipes-api Show documentation
Show all versions of pipes-api Show documentation
Intelie Pipes' API classes and interfaces
package net.intelie.pipes.util;
import net.intelie.pipes.time.TimeSpan;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public abstract class SpanReprHelper {
public static AutomatonRepr repr(TimeSpan span, long timestamp, String zone, String label, TimeSpan... children) {
AutomatonRepr auto = new AutomatonRepr("start");
long start = span.start(timestamp);
long end = span.end(timestamp);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.ROOT);
formatter.setTimeZone(TimeZone.getTimeZone(zone));
AutomatonRepr.LabelLines lines = new AutomatonRepr.LabelLines();
lines.addLine(14, label);
lines.addLine(10, formatter.format(new Date(start)));
lines.addLine(10, formatter.format(new Date(end)));
auto.addNode("rectangle", "start", lines);
for (int i = 0; i < children.length; i++) {
if (children[i] != null) {
AutomatonRepr repr = children[i].repr(timestamp, zone);
if (repr != null)
auto.addEdge("start", "s" + (i + 1) + "_", repr, i + 1);
}
}
return auto;
}
}