java.lang.Object
de.iip_ecosphere.platform.configuration.easyProducer.ivml.IvmlUtils

public class IvmlUtils extends Object
Utilities to access IVML/configuration values.
Author:
Holger Eichelberger, SSE
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    Finds variables in IVML expressions.
    private static class 
    Finds a variable use in IVML projects.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Set<String>
    analyzeForTemplate(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult res, String varName)
    Analyzes the given reasoning result for template completion.
    static boolean
    analyzeReasoningResult(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult res, boolean emitWarnings, boolean emitMessages)
    Analyzes/prints the relevant information from reasoning messages.
    static void
    collectImports(net.ssehub.easy.varModel.model.Project prj, Set<net.ssehub.easy.varModel.model.Project> projects)
    Collects all imports, i.e., the import hull starting with prj.
    static boolean
    containsVariable(net.ssehub.easy.varModel.model.Project prj, String varName)
    Returns whether prj declares a variable named varName.
    static net.ssehub.easy.varModel.confModel.IDecisionVariable
    dereference(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
    Dereferences var.
    static Set<net.ssehub.easy.varModel.model.Project>
    findProjectsUsingVariable(net.ssehub.easy.varModel.model.Project root, net.ssehub.easy.varModel.model.AbstractVariable var)
    Returns the projects that use var.
    static List<net.ssehub.easy.varModel.model.AbstractVariable>
    findTemplates(net.ssehub.easy.varModel.model.Project root)
    Returns all templates in the related projects of root.
    static boolean
    getBooleanValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, boolean deflt)
    Returns a Boolean value from the given var.
    static boolean
    getBooleanValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested, boolean deflt)
    Returns a Boolean value of the nested field of var.
    static net.ssehub.easy.varModel.model.values.Value
    getConstValue(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst)
    Returns the constant value of cst if cst is a constant expression.
    static net.ssehub.easy.varModel.model.values.EnumValue
    getEnumValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
    Returns an enum value from the given var.
    static int
    getIntValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, int deflt)
    Returns an integer value from the given var.
    static int
    getIntValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested, int deflt)
    Returns an int value of the nested field of var.
    static int
    getIntValue(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst, int dflt)
    Returns the constant int value of cst if cst is a constant int expression.
    static net.ssehub.easy.varModel.confModel.IDecisionVariable
    getNestedSafe(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested)
    Returns a nested variable, returning null if var is null.
    static net.ssehub.easy.varModel.model.Project
    getProject(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
    Returns the project the outermost variable is declared within.
    static String
    getStringValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String deflt)
    Returns a string value from the given var.
    static String
    getStringValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested, String deflt)
    Returns a string value of the nested field of var.
    static String
    getVarNameSafe(net.ssehub.easy.varModel.model.AbstractVariable var, String dflt)
    Returns the name of var taking null into account.
    static boolean
    hasAnnotation(net.ssehub.easy.varModel.model.Project prj, String name)
    Returns whether in prj an annotation with given name is declared/annotated.
    static boolean
    isApplication(net.ssehub.easy.varModel.model.AbstractVariable var)
    Returns whether var represents an application.
    static boolean
    isInTemplate(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
    Returns whether var is in a template.
    static boolean
    isInTemplate(net.ssehub.easy.varModel.model.AbstractVariable var)
    Returns whether var is in a template.
    static boolean
    isOfCompoundType(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String typeName)
    Returns whether the given var is of compound type with name typeName.
    static boolean
    isOfCompoundType(net.ssehub.easy.varModel.model.AbstractVariable var, String typeName)
    Returns whether the given var is of compound type with name typeName.
    static boolean
    isOfCompoundType(net.ssehub.easy.varModel.model.datatypes.IDatatype type, String typeName)
    Returns whether the given type is of compound type with name typeName.
    static boolean
    isTemplate(net.ssehub.easy.varModel.model.AbstractVariable var)
    Returns whether var represents an application template.
    static boolean
    isTemplate(net.ssehub.easy.varModel.model.Project prj)
    Returns whether prj represents an application template project.
    static <E> void
    iterElements(net.ssehub.easy.varModel.model.Project prj, Class<E> cls, Consumer<E> consumer)
    Iterates through specified elements of prj.
    static String
    toName(net.ssehub.easy.varModel.model.values.EnumValue value, String deflt)
    Turns an enum value to its name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IvmlUtils

      public IvmlUtils()
  • Method Details

    • isOfCompoundType

      public static boolean isOfCompoundType(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String typeName)
      Returns whether the given var is of compound type with name typeName.
      Parameters:
      var - the variable
      typeName - the type name of the compound
      Returns:
      true if var is of a compound type with typeName, false else
      See Also:
    • isOfCompoundType

      public static boolean isOfCompoundType(net.ssehub.easy.varModel.model.AbstractVariable var, String typeName)
      Returns whether the given var is of compound type with name typeName.
      Parameters:
      var - the variable
      typeName - the type name of the compound
      Returns:
      true if var is of a compound type with typeName, false else
      See Also:
    • isOfCompoundType

      public static boolean isOfCompoundType(net.ssehub.easy.varModel.model.datatypes.IDatatype type, String typeName)
      Returns whether the given type is of compound type with name typeName.
      Parameters:
      type - the type
      typeName - the type name of the compound
      Returns:
      true if var is of a compound type with typeName, false else
    • getNestedSafe

      public static net.ssehub.easy.varModel.confModel.IDecisionVariable getNestedSafe(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested)
      Returns a nested variable, returning null if var is null.
      Parameters:
      var - the variable
      nested - the name of the nested variable
      Returns:
      the nested variable or null
    • getStringValue

      public static String getStringValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String deflt)
      Returns a string value from the given var.
      Parameters:
      var - the variable (may be null)
      deflt - the default value to return if no value can be obtained
      Returns:
      the value or deflt
    • getStringValue

      public static String getStringValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested, String deflt)
      Returns a string value of the nested field of var.
      Parameters:
      var - the variable (may be null)
      nested - the nested field to take the value from
      deflt - the default value to return if no value can be obtained
      Returns:
      the value or deflt
    • getIntValue

      public static int getIntValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested, int deflt)
      Returns an int value of the nested field of var.
      Parameters:
      var - the variable (may be null)
      nested - the nested field to take the value from
      deflt - the default value to return if no value can be obtained
      Returns:
      the value or deflt
    • getBooleanValue

      public static boolean getBooleanValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested, boolean deflt)
      Returns a Boolean value of the nested field of var.
      Parameters:
      var - the variable (may be null)
      nested - the nested field to take the value from
      deflt - the default value to return if no value can be obtained
      Returns:
      the value or deflt
    • getEnumValue

      public static net.ssehub.easy.varModel.model.values.EnumValue getEnumValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
      Returns an enum value from the given var.
      Parameters:
      var - the variable (may be null)
      Returns:
      the value or null
    • toName

      public static String toName(net.ssehub.easy.varModel.model.values.EnumValue value, String deflt)
      Turns an enum value to its name.
      Parameters:
      value - the value, may be null
      deflt - the default value to return if no value can be obtained
      Returns:
      the name of the enum literal or deflt
    • getIntValue

      public static int getIntValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, int deflt)
      Returns an integer value from the given var.
      Parameters:
      var - the variable (may be null)
      deflt - the default value to return if no value can be obtained
      Returns:
      the value or deflt
    • getBooleanValue

      public static boolean getBooleanValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, boolean deflt)
      Returns a Boolean value from the given var.
      Parameters:
      var - the variable (may be null)
      deflt - the default value to return if no value can be obtained
      Returns:
      the value or deflt
    • getVarNameSafe

      public static String getVarNameSafe(net.ssehub.easy.varModel.model.AbstractVariable var, String dflt)
      Returns the name of var taking null into account.
      Parameters:
      var - the variable
      dflt - the default if var is null
      Returns:
      the name or dflt
    • getConstValue

      public static net.ssehub.easy.varModel.model.values.Value getConstValue(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst)
      Returns the constant value of cst if cst is a constant expression.
      Parameters:
      cst - the constraint syntax tree
      Returns:
      the constant value or null
    • getIntValue

      public static int getIntValue(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst, int dflt)
      Returns the constant int value of cst if cst is a constant int expression.
      Parameters:
      cst - the constraint syntax tree
      dflt - the default value if cst is not a constant int expression
      Returns:
      the constant value or dflt
    • analyzeReasoningResult

      public static boolean analyzeReasoningResult(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult res, boolean emitWarnings, boolean emitMessages)
      Analyzes/prints the relevant information from reasoning messages.
      Parameters:
      res - the reasoning result to print
      emitWarnings - shall warnings be emitted
      emitMessages - shall messages be emitted
      Returns:
      true for conflict, false for ok
    • analyzeForTemplate

      public static Set<String> analyzeForTemplate(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult res, String varName)
      Analyzes the given reasoning result for template completion.
      Parameters:
      res - the reasoning result
      varName - the variable representing the application
      Returns:
      the names of the open variables
    • dereference

      public static net.ssehub.easy.varModel.confModel.IDecisionVariable dereference(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
      Dereferences var.
      Parameters:
      var - the variable to dereference
      Returns:
      the dereferenced variable
    • findTemplates

      public static List<net.ssehub.easy.varModel.model.AbstractVariable> findTemplates(net.ssehub.easy.varModel.model.Project root)
      Returns all templates in the related projects of root.
      Parameters:
      root - the root project to start searching
      Returns:
      the templates, may be empty
    • containsVariable

      public static boolean containsVariable(net.ssehub.easy.varModel.model.Project prj, String varName)
      Returns whether prj declares a variable named varName.
      Parameters:
      prj - the project to inspect
      varName - the variable to look for
      Returns:
      true for contained/declared, false else
    • isTemplate

      public static boolean isTemplate(net.ssehub.easy.varModel.model.Project prj)
      Returns whether prj represents an application template project.
      Parameters:
      prj - the project to check
      Returns:
      true for template, false else
    • isTemplate

      public static boolean isTemplate(net.ssehub.easy.varModel.model.AbstractVariable var)
      Returns whether var represents an application template.
      Parameters:
      var - the variable to check
      Returns:
      true for template, false else
    • isApplication

      public static boolean isApplication(net.ssehub.easy.varModel.model.AbstractVariable var)
      Returns whether var represents an application.
      Parameters:
      var - the variable to check
      Returns:
      true for application, false else
    • isInTemplate

      public static boolean isInTemplate(net.ssehub.easy.varModel.model.AbstractVariable var)
      Returns whether var is in a template.
      Parameters:
      var - the variable to check
      Returns:
      true if var is declared in a template, false else
    • isInTemplate

      public static boolean isInTemplate(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
      Returns whether var is in a template.
      Parameters:
      var - the variable to check
      Returns:
      true if var is declared in a template, false else
    • getProject

      public static net.ssehub.easy.varModel.model.Project getProject(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
      Returns the project the outermost variable is declared within.
      Parameters:
      var - the variable to return the project for
      Returns:
      the project or null
    • findProjectsUsingVariable

      public static Set<net.ssehub.easy.varModel.model.Project> findProjectsUsingVariable(net.ssehub.easy.varModel.model.Project root, net.ssehub.easy.varModel.model.AbstractVariable var)
      Returns the projects that use var.
      Parameters:
      root - the project to start looking into
      var - the variable to search for
      Returns:
      the projects using var
    • collectImports

      public static void collectImports(net.ssehub.easy.varModel.model.Project prj, Set<net.ssehub.easy.varModel.model.Project> projects)
      Collects all imports, i.e., the import hull starting with prj.
      Parameters:
      prj - the project to start the imports with
      projects - the imported projects
    • iterElements

      public static <E> void iterElements(net.ssehub.easy.varModel.model.Project prj, Class<E> cls, Consumer<E> consumer)
      Iterates through specified elements of prj.
      Type Parameters:
      E - the type to select/iterate over
      Parameters:
      prj - the project to take the elements from
      cls - representation of the type/filter
      consumer - called for each matching element
    • hasAnnotation

      public static boolean hasAnnotation(net.ssehub.easy.varModel.model.Project prj, String name)
      Returns whether in prj an annotation with given name is declared/annotated.
      Parameters:
      prj - the project
      name - the name of the annotation
      Returns:
      true for exists, false else