Class XmlIo


  • public class XmlIo
    extends java.lang.Object
    Supports storing projects (and referenced projects) into XML format. Please note that the XML format is intended for temporary storage of models, in particular in environments where xText or Eclipse dependency must not be used. Further, this class does not rely on VarModel, i.e. the related mechanisms, loaders and listeners there are not considered by this class (this would require a specific XML loader). [req SAP, TUV]
    Author:
    Holger Eichelberger, Aike Sass
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  XmlIo.Model
      Defines the top level element in the XML.
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlIo()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static com.thoughtworks.xstream.XStream createStream()
      Creates a stream instance for reading and writing.
      private static void printMap​(java.util.Map<java.lang.String,​java.lang.String> classes, java.io.File target)
      Print map to properties file.
      static java.util.List<IModel> read​(java.io.File source, boolean isIvmlFile)
      Reads a list of IModel from an input stream.
      private static void readMap​(java.io.File target)
      Read map from properties file.
      static void write​(java.util.List<IModel> list, java.io.File target, boolean isIvmlFile)
      Writes a list of IModel to the given output stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CLASSES

        public static final java.util.Map<java.lang.String,​java.lang.String> CLASSES
    • Constructor Detail

      • XmlIo

        public XmlIo()
    • Method Detail

      • write

        public static final void write​(java.util.List<IModel> list,
                                       java.io.File target,
                                       boolean isIvmlFile)
                                throws java.io.IOException
        Writes a list of IModel to the given output stream. IF YOU WANT TO WRITE IVML THEN CALL #isIvmlFile() TO DISABLE CERTAIN CONVERTERS!
        Parameters:
        list - the list to be written
        target - the target where to write the list to
        isIvmlFile - switch to enable specific converter
        Throws:
        java.io.IOException
      • printMap

        private static void printMap​(java.util.Map<java.lang.String,​java.lang.String> classes,
                                     java.io.File target)
                              throws java.io.IOException
        Print map to properties file.
        Parameters:
        classes - map to be printed
        target - target
        Throws:
        java.io.IOException
      • readMap

        private static void readMap​(java.io.File target)
                             throws java.io.IOException
        Read map from properties file.
        Parameters:
        target - target file
        Throws:
        java.io.IOException
      • read

        public static final java.util.List<IModel> read​(java.io.File source,
                                                        boolean isIvmlFile)
                                                 throws java.io.IOException
        Reads a list of IModel from an input stream. IF YOU WANT TO WRITE IVML THEN CALL #isIvmlFile() TO DISABLE CERTAIN CONVERTERS!
        Parameters:
        source - the source to read the project definition from
        isIvmlFile - switch to enable specific converter
        Returns:
        the instantiated IModel
        Throws:
        java.io.IOException
      • createStream

        private static final com.thoughtworks.xstream.XStream createStream()
        Creates a stream instance for reading and writing.
        Returns:
        the stream instance