Search in sources :

Example 1 with TrainTimetables

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

the class XmlTrainTimetablesOutput method writeTo.

@Override
protected void writeTo(OutputParams params, OutputStream stream, TrainDiagram diagram) throws OutputException {
    try {
        // extract tts
        List<Train> trains = SelectionHelper.selectTrains(params, diagram);
        List<Route> routes = SelectionHelper.getRoutes(params, diagram, trains);
        TrainsCycle cycle = SelectionHelper.getDriverCycle(params);
        TrainTimetablesExtractor te = new TrainTimetablesExtractor(diagram, trains, routes, cycle, this.getLocale());
        TrainTimetables tt = te.getTrainTimetables();
        JAXBContext context = JAXBContext.newInstance(TrainTimetables.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(tt, writer);
    } catch (Exception e) {
        throw new OutputException(e);
    }
}
Also used : TrainsCycle(net.parostroj.timetable.model.TrainsCycle) Marshaller(javax.xml.bind.Marshaller) JAXBContext(javax.xml.bind.JAXBContext) OutputStreamWriter(java.io.OutputStreamWriter) TrainTimetablesExtractor(net.parostroj.timetable.output2.impl.TrainTimetablesExtractor) TrainTimetables(net.parostroj.timetable.output2.impl.TrainTimetables) Train(net.parostroj.timetable.model.Train) Route(net.parostroj.timetable.model.Route) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 Route (net.parostroj.timetable.model.Route)1 Train (net.parostroj.timetable.model.Train)1 TrainsCycle (net.parostroj.timetable.model.TrainsCycle)1 TrainTimetables (net.parostroj.timetable.output2.impl.TrainTimetables)1 TrainTimetablesExtractor (net.parostroj.timetable.output2.impl.TrainTimetablesExtractor)1