Class ModelUtility

  • All Implemented Interfaces:
    net.ssehub.easy.basics.modelManagement.IModelLoader<net.ssehub.easy.varModel.model.Project>

    public class ModelUtility
    extends net.ssehub.easy.dslCore.ModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,​net.ssehub.easy.varModel.model.Project>
    implements net.ssehub.easy.basics.modelManagement.IModelLoader<net.ssehub.easy.varModel.model.Project>
    (Entry points for) Utilities for working with the EMF model.
    Author:
    Holger Eichelberger
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface net.ssehub.easy.basics.modelManagement.IModelLoader

        net.ssehub.easy.basics.modelManagement.IModelLoader.IModelInfoHolder<M extends net.ssehub.easy.basics.modelManagement.IModel>, net.ssehub.easy.basics.modelManagement.IModelLoader.LoadResult<M extends net.ssehub.easy.basics.modelManagement.IModel>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ModelUtility INSTANCE  
      private net.ssehub.easy.dslCore.translation.LogMessageReceiver logReceiver  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ModelUtility()
      Prevents external creation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      net.ssehub.easy.varModel.model.Constraint createConstraint​(java.lang.String text, net.ssehub.easy.varModel.model.Project project, boolean asStatement)
      Parses a text into a constraint in the context of project.
      net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createExpression​(java.lang.String text, net.ssehub.easy.varModel.model.IModelElement parent)
      Parses a text into an expression in the context of project.
      net.ssehub.easy.dslCore.TranslationResult<net.ssehub.easy.varModel.model.Project> createVarModel​(de.uni_hildesheim.sse.ivml.VariabilityUnit root, java.net.URI uri, boolean registerSuccessful)
      Create the variability model from an EMF variability unit.
      java.lang.String getExtension()  
      protected java.lang.ClassLoader getLanguageClassLoader()  
      protected java.lang.String getLanguageName()  
      protected void initializeAfterResourceInitializer()  
      java.util.List<net.ssehub.easy.basics.modelManagement.ModelInfo<net.ssehub.easy.varModel.model.Project>> obtainInfo​(org.eclipse.emf.common.util.URI uri)
      Obtains project info.
      net.ssehub.easy.dslCore.TranslationResult<net.ssehub.easy.varModel.model.Project> parse​(org.eclipse.emf.common.util.URI uri, net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.varModel.model.Project> resolver)  
      void print​(net.ssehub.easy.dslCore.TranslationResult<net.ssehub.easy.varModel.model.Project> result, java.io.Writer out, boolean emitComments, boolean emitImports)
      Prints the var model stored in the result to the console output stream (for debugging).
      static java.lang.String stringValue​(de.uni_hildesheim.sse.ivml.DerivedType type, boolean forSearch)
      Returns the string representation of type.
      static java.lang.String stringValue​(de.uni_hildesheim.sse.ivml.Type type)
      Returns the string representation of type (no search).
      static java.lang.String stringValue​(de.uni_hildesheim.sse.ivml.Type type, boolean forSearch)
      Returns the string representation of type.
      • Methods inherited from class net.ssehub.easy.dslCore.ModelUtility

        append, appendWithNewLine, getGrammar, getInjector, getResourceInitializer, getResourceSet, handles, load, obtainInfo, parse, parse, parse, parseFragment, scan, setInjector, setResourceInitializer, toNetUri
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface net.ssehub.easy.basics.modelManagement.IModelLoader

        load, scan
    • Field Detail

      • logReceiver

        private final net.ssehub.easy.dslCore.translation.LogMessageReceiver logReceiver
    • Constructor Detail

      • ModelUtility

        private ModelUtility()
        Prevents external creation.
    • Method Detail

      • initializeAfterResourceInitializer

        protected void initializeAfterResourceInitializer()
        Specified by:
        initializeAfterResourceInitializer in class net.ssehub.easy.dslCore.ModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,​net.ssehub.easy.varModel.model.Project>
      • getLanguageName

        protected java.lang.String getLanguageName()
        Specified by:
        getLanguageName in class net.ssehub.easy.dslCore.ModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,​net.ssehub.easy.varModel.model.Project>
      • getLanguageClassLoader

        protected java.lang.ClassLoader getLanguageClassLoader()
        Specified by:
        getLanguageClassLoader in class net.ssehub.easy.dslCore.ModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,​net.ssehub.easy.varModel.model.Project>
      • createVarModel

        public net.ssehub.easy.dslCore.TranslationResult<net.ssehub.easy.varModel.model.Project> createVarModel​(de.uni_hildesheim.sse.ivml.VariabilityUnit root,
                                                                                                                java.net.URI uri,
                                                                                                                boolean registerSuccessful)
        Create the variability model from an EMF variability unit.
        Parameters:
        root - the root-level variability unit
        uri - the URI of the project to resolve (in order to find the closest project, may be null)
        registerSuccessful - successfully created models shall be registered
        Returns:
        the created variability model including messages
      • print

        public void print​(net.ssehub.easy.dslCore.TranslationResult<net.ssehub.easy.varModel.model.Project> result,
                          java.io.Writer out,
                          boolean emitComments,
                          boolean emitImports)
        Prints the var model stored in the result to the console output stream (for debugging).
        Parameters:
        result - the result instance
        out - the output writer
        emitComments - whether comments shall be emitted
        emitImports - whether imports shall be emitted
      • parse

        public net.ssehub.easy.dslCore.TranslationResult<net.ssehub.easy.varModel.model.Project> parse​(org.eclipse.emf.common.util.URI uri,
                                                                                                       net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.varModel.model.Project> resolver)
                                                                                                throws java.io.IOException
        Specified by:
        parse in class net.ssehub.easy.dslCore.ModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,​net.ssehub.easy.varModel.model.Project>
        Throws:
        java.io.IOException
      • obtainInfo

        public java.util.List<net.ssehub.easy.basics.modelManagement.ModelInfo<net.ssehub.easy.varModel.model.Project>> obtainInfo​(org.eclipse.emf.common.util.URI uri)
                                                                                                                            throws java.io.IOException
        Obtains project info.
        Specified by:
        obtainInfo in class net.ssehub.easy.dslCore.ModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,​net.ssehub.easy.varModel.model.Project>
        Parameters:
        uri - the URI to read the info from
        Returns:
        the project info instances related to uri
        Throws:
        java.io.IOException - in case that an I/O error happens during parsing
      • stringValue

        public static final java.lang.String stringValue​(de.uni_hildesheim.sse.ivml.Type type)
        Returns the string representation of type (no search).
        Parameters:
        type - the type to be converted into a string
        Returns:
        the type representation
      • stringValue

        public static final java.lang.String stringValue​(de.uni_hildesheim.sse.ivml.Type type,
                                                         boolean forSearch)
        Returns the string representation of type.
        Parameters:
        type - the type to be converted into a string
        forSearch - is the result intended for type searching
        Returns:
        the type representation
      • stringValue

        public static final java.lang.String stringValue​(de.uni_hildesheim.sse.ivml.DerivedType type,
                                                         boolean forSearch)
        Returns the string representation of type.
        Parameters:
        type - the type to be converted into a string
        forSearch - is the result intended for type searching
        Returns:
        the type representation
      • createConstraint

        public net.ssehub.easy.varModel.model.Constraint createConstraint​(java.lang.String text,
                                                                          net.ssehub.easy.varModel.model.Project project,
                                                                          boolean asStatement)
                                                                   throws net.ssehub.easy.varModel.cst.CSTSemanticException,
                                                                          ConstraintSyntaxException
        Parses a text into a constraint in the context of project. Project is not modified!
        Parameters:
        text - the text to be parsed containing the constraint
        project - the project
        asStatement - true then parse text as a statement, else as an expression
        Returns:
        the constraint, null in case of internal instantiation errors
        Throws:
        net.ssehub.easy.varModel.cst.CSTSemanticException - in case of semantic problems in text
        ConstraintSyntaxException - in case of syntax problems in text
      • createExpression

        public net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createExpression​(java.lang.String text,
                                                                                  net.ssehub.easy.varModel.model.IModelElement parent)
                                                                           throws net.ssehub.easy.varModel.cst.CSTSemanticException,
                                                                                  ConstraintSyntaxException
        Parses a text into an expression in the context of project. Project is not modified!
        Parameters:
        text - the text to be parsed containing the constraint
        parent - the intended parent model element (turned into Compound or Project depending on nesting
        Returns:
        the expression, null in case of internal instantiation errors
        Throws:
        net.ssehub.easy.varModel.cst.CSTSemanticException - in case of semantic problems in text
        ConstraintSyntaxException - in case of syntax problems in text
      • getExtension

        public java.lang.String getExtension()
        Specified by:
        getExtension in class net.ssehub.easy.dslCore.ModelUtility<de.uni_hildesheim.sse.ivml.VariabilityUnit,​net.ssehub.easy.varModel.model.Project>