Search in sources :

Example 1 with StationTimetablesExtractor

use of net.parostroj.timetable.output2.impl.StationTimetablesExtractor in project grafikon by jub77.

the class XmlStationTimetablesOutput method writeTo.

@Override
protected void writeTo(OutputParams params, OutputStream stream, TrainDiagram diagram) throws OutputException {
    try {
        // show circulations in adjacent sessions
        boolean adjacentSessions = params.getParamValue("adjacent.sessions", Boolean.class, false);
        // technological times
        boolean techTime = false;
        if (params.paramExistWithValue("tech.time")) {
            techTime = params.getParam("tech.time").getValue(Boolean.class);
        }
        // extract positions
        StationTimetablesExtractor se = new StationTimetablesExtractor(diagram, SelectionHelper.selectNodes(params, diagram), techTime, adjacentSessions, this.getLocale());
        StationTimetables st = new StationTimetables(se.getStationTimetables());
        JAXBContext context = JAXBContext.newInstance(StationTimetables.class);
        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_ENCODING, this.getCharset().name());
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        Writer writer = new OutputStreamWriter(stream, this.getCharset());
        m.marshal(st, writer);
    } catch (Exception e) {
        throw new OutputException(e);
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) OutputException(net.parostroj.timetable.output2.OutputException) StationTimetables(net.parostroj.timetable.output2.impl.StationTimetables) JAXBContext(javax.xml.bind.JAXBContext) OutputStreamWriter(java.io.OutputStreamWriter) StationTimetablesExtractor(net.parostroj.timetable.output2.impl.StationTimetablesExtractor) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) OutputException(net.parostroj.timetable.output2.OutputException)

Aggregations

OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 OutputException (net.parostroj.timetable.output2.OutputException)1 StationTimetables (net.parostroj.timetable.output2.impl.StationTimetables)1 StationTimetablesExtractor (net.parostroj.timetable.output2.impl.StationTimetablesExtractor)1