Search in sources :

Example 1 with EngineCyclesExtractor

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

the class XmlEngineCyclesOutput method writeTo.

@Override
protected void writeTo(OutputParams params, OutputStream stream, TrainDiagram diagram) throws OutputException {
    try {
        EngineCyclesExtractor tuce = new EngineCyclesExtractor(SelectionHelper.selectCycles(params, diagram, diagram.getEngineCycleType()));
        EngineCycles cycles = new EngineCycles(tuce.getEngineCycles());
        JAXBContext context = JAXBContext.newInstance(EngineCycles.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 : EngineCyclesExtractor(net.parostroj.timetable.output2.impl.EngineCyclesExtractor) Marshaller(javax.xml.bind.Marshaller) OutputException(net.parostroj.timetable.output2.OutputException) EngineCycles(net.parostroj.timetable.output2.impl.EngineCycles) JAXBContext(javax.xml.bind.JAXBContext) OutputStreamWriter(java.io.OutputStreamWriter) 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 EngineCycles (net.parostroj.timetable.output2.impl.EngineCycles)1 EngineCyclesExtractor (net.parostroj.timetable.output2.impl.EngineCyclesExtractor)1