2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2015-2015 - Scilab Enterprises - Clement DAVID
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
12 package org.scilab.modules.xcos.io.writer;
14 import java.util.logging.Level;
15 import java.util.logging.Logger;
17 import javax.xml.stream.XMLStreamException;
18 import javax.xml.stream.XMLStreamWriter;
20 import org.scilab.modules.types.ScilabList;
21 import org.scilab.modules.xcos.JavaController;
22 import org.scilab.modules.xcos.Kind;
23 import org.scilab.modules.xcos.utils.Stack;
26 * Implement an XML writer for any kind of model object
28 public class XcosWriter {
29 protected static final Logger LOG = Logger.getLogger("org.scilab.modules.xcos.io.writer");
34 protected final JavaController controller;
35 protected final ScilabList dictionary;
36 protected final RawDataWriter rawDataWriter;
37 protected final XMLStreamWriter stream;
38 protected final Stack<String> layers;
40 public XcosWriter(ScilabList dictionary, XMLStreamWriter writer) {
41 this.controller = new JavaController();
42 this.dictionary = dictionary;
43 this.rawDataWriter = new RawDataWriter(this);
46 this.layers = new Stack<>();
49 public void write(long uid, Kind kind) throws XMLStreamException {
51 if (LOG.isLoggable(Level.FINER)) {
52 LOG.entering(XcosWriter.class.getName(), "write");
58 new BlockWriter(this).write(uid, kind);
61 new CustomWriter(this).write(uid, kind);
64 new LinkWriter(this).write(uid, kind);
67 // this will be managed by the BlockWriter
71 if (LOG.isLoggable(Level.FINER)) {
72 LOG.exiting(XcosWriter.class.getName(), "write");