Class SessionWriter


  • public class SessionWriter
    extends java.lang.Object
    Writes a .jos session file from current supported layers.
    Since:
    4685
    • Constructor Detail

      • SessionWriter

        public SessionWriter​(java.util.List<Layer> layers,
                             int active,
                             java.util.Map<Layer,​SessionLayerExporter> exporters,
                             MultiMap<Layer,​Layer> dependencies,
                             boolean zip)
        Constructs a new SessionWriter.
        Parameters:
        layers - The ordered list of layers to save
        active - The index of active layer in layers (starts at 0). Ignored if set to -1
        exporters - The exporters to use to save layers
        dependencies - layer dependencies
        zip - true if a joz archive has to be created, false otherwise
        Since:
        6271
      • SessionWriter

        public SessionWriter​(java.util.List<Layer> layers,
                             int active,
                             java.util.Map<Layer,​SessionLayerExporter> exporters,
                             MultiMap<Layer,​Layer> dependencies,
                             SessionWriter.SessionWriterFlags... flags)
        Constructs a new SessionWriter.
        Parameters:
        layers - The ordered list of layers to save
        active - The index of active layer in layers (starts at 0). Ignored if set to -1
        exporters - The exporters to use to save layers
        dependencies - layer dependencies
        flags - The flags to use when writing data
        Since:
        18833
    • Method Detail

      • registerSessionLayerExporter

        public static void registerSessionLayerExporter​(java.lang.Class<? extends Layer> layerClass,
                                                        java.lang.Class<? extends SessionLayerExporter> exporter)
        Register a session layer exporter.

        The exporter class must have a one-argument constructor with layerClass as formal parameter type.

        Parameters:
        layerClass - layer class
        exporter - exporter for this layer class
      • getSessionLayerExporter

        public static SessionLayerExporter getSessionLayerExporter​(Layer layer)
        Returns the session layer exporter for the given layer.
        Parameters:
        layer - layer to export
        Returns:
        session layer exporter for the given layer
        Throws:
        java.lang.IllegalArgumentException - if layer cannot be exported
      • createJosDocument

        public org.w3c.dom.Document createJosDocument()
                                               throws java.io.IOException
        Creates XML (.jos) session document.
        Returns:
        new document
        Throws:
        java.io.IOException - if any I/O error occurs
      • writeViewPort

        private static void writeViewPort​(org.w3c.dom.Element root)
      • writeProjection

        private static void writeProjection​(org.w3c.dom.Element root)
      • writeJos

        public void writeJos​(org.w3c.dom.Document doc,
                             java.io.OutputStream out)
                      throws java.io.IOException
        Writes given .jos document to an output stream.
        Parameters:
        doc - session document
        out - output stream
        Throws:
        java.io.IOException - if any I/O error occurs
      • write

        public void write​(java.io.File f)
                   throws java.io.IOException
        Writes session to given file.
        Parameters:
        f - output file
        Throws:
        java.io.IOException - if any I/O error occurs
      • write

        public void write​(java.io.OutputStream out)
                   throws java.io.IOException
        Writes session to given output stream.
        Parameters:
        out - output stream
        Throws:
        java.io.IOException - if any I/O error occurs