Search in sources :

Example 1 with DriverCycles

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

the class XmlDriverCyclesOutput method writeTo.

@Override
protected void writeTo(OutputParams params, OutputStream stream, TrainDiagram diagram) throws OutputException {
    try {
        DriverCyclesExtractor dce = new DriverCyclesExtractor(diagram, SelectionHelper.selectCycles(params, diagram, diagram.getDriverCycleType()), true);
        DriverCycles cycles = dce.getDriverCycles();
        JAXBContext context = JAXBContext.newInstance(DriverCycles.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(cycles, writer);
    } catch (Exception e) {
        throw new OutputException(e);
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) OutputException(net.parostroj.timetable.output2.OutputException) JAXBContext(javax.xml.bind.JAXBContext) OutputStreamWriter(java.io.OutputStreamWriter) DriverCyclesExtractor(net.parostroj.timetable.output2.impl.DriverCyclesExtractor) DriverCycles(net.parostroj.timetable.output2.impl.DriverCycles) 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 DriverCycles (net.parostroj.timetable.output2.impl.DriverCycles)1 DriverCyclesExtractor (net.parostroj.timetable.output2.impl.DriverCyclesExtractor)1