Class IvmlUtils
java.lang.Object
de.iip_ecosphere.platform.configuration.easyProducer.ivml.IvmlUtils
Utilities to access IVML/configuration values.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classFinds variables in IVML expressions.private static classFinds a variable use in IVML projects. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionanalyzeForTemplate(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult res, String varName) Analyzes the given reasoning result for template completion.static booleananalyzeReasoningResult(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult res, boolean emitWarnings, boolean emitMessages) Analyzes/prints the relevant information from reasoning messages.static voidcollectImports(net.ssehub.easy.varModel.model.Project prj, Set<net.ssehub.easy.varModel.model.Project> projects) Collects all imports, i.e., the import hull starting withprj.static booleancontainsVariable(net.ssehub.easy.varModel.model.Project prj, String varName) Returns whetherprjdeclares a variable namedvarName.static net.ssehub.easy.varModel.confModel.IDecisionVariabledereference(net.ssehub.easy.varModel.confModel.IDecisionVariable var) Dereferencesvar.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 usevar.static List<net.ssehub.easy.varModel.model.AbstractVariable> findTemplates(net.ssehub.easy.varModel.model.Project root) Returns all templates in the related projects ofroot.static booleangetBooleanValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, boolean deflt) Returns a Boolean value from the givenvar.static booleangetBooleanValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested, boolean deflt) Returns a Boolean value of thenestedfield ofvar.static net.ssehub.easy.varModel.model.values.ValuegetConstValue(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst) Returns the constant value ofcstifcstis a constant expression.static net.ssehub.easy.varModel.model.values.EnumValuegetEnumValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var) Returns an enum value from the givenvar.static intgetIntValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, int deflt) Returns an integer value from the givenvar.static intgetIntValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested, int deflt) Returns an int value of thenestedfield ofvar.static intgetIntValue(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst, int dflt) Returns the constant int value ofcstifcstis a constant int expression.static net.ssehub.easy.varModel.confModel.IDecisionVariablegetNestedSafe(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested) Returns a nested variable, returning null ifvaris null.static net.ssehub.easy.varModel.model.ProjectgetProject(net.ssehub.easy.varModel.confModel.IDecisionVariable var) Returns the project the outermost variable is declared within.static StringgetStringValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String deflt) Returns a string value from the givenvar.static StringgetStringValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String nested, String deflt) Returns a string value of thenestedfield ofvar.static StringgetVarNameSafe(net.ssehub.easy.varModel.model.AbstractVariable var, String dflt) Returns the name ofvartaking null into account.static booleanhasAnnotation(net.ssehub.easy.varModel.model.Project prj, String name) Returns whether inprjan annotation with givennameis declared/annotated.static booleanisApplication(net.ssehub.easy.varModel.model.AbstractVariable var) Returns whethervarrepresents an application.static booleanisInTemplate(net.ssehub.easy.varModel.confModel.IDecisionVariable var) Returns whethervaris in a template.static booleanisInTemplate(net.ssehub.easy.varModel.model.AbstractVariable var) Returns whethervaris in a template.static booleanisOfCompoundType(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String typeName) Returns whether the givenvaris of compound type with nametypeName.static booleanisOfCompoundType(net.ssehub.easy.varModel.model.AbstractVariable var, String typeName) Returns whether the givenvaris of compound type with nametypeName.static booleanisOfCompoundType(net.ssehub.easy.varModel.model.datatypes.IDatatype type, String typeName) Returns whether the giventypeis of compound type with nametypeName.static booleanisTemplate(net.ssehub.easy.varModel.model.AbstractVariable var) Returns whethervarrepresents an application template.static booleanisTemplate(net.ssehub.easy.varModel.model.Project prj) Returns whetherprjrepresents an application template project.static <E> voiditerElements(net.ssehub.easy.varModel.model.Project prj, Class<E> cls, Consumer<E> consumer) Iterates through specified elements ofprj.static StringTurns an enum value to its name.
-
Constructor Details
-
IvmlUtils
public IvmlUtils()
-
-
Method Details
-
isOfCompoundType
public static boolean isOfCompoundType(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String typeName) Returns whether the givenvaris of compound type with nametypeName.- Parameters:
var- the variabletypeName- the type name of the compound- Returns:
trueifvaris of a compound type withtypeName,falseelse- See Also:
-
isOfCompoundType
public static boolean isOfCompoundType(net.ssehub.easy.varModel.model.AbstractVariable var, String typeName) Returns whether the givenvaris of compound type with nametypeName.- Parameters:
var- the variabletypeName- the type name of the compound- Returns:
trueifvaris of a compound type withtypeName,falseelse- See Also:
-
isOfCompoundType
public static boolean isOfCompoundType(net.ssehub.easy.varModel.model.datatypes.IDatatype type, String typeName) Returns whether the giventypeis of compound type with nametypeName.- Parameters:
type- the typetypeName- the type name of the compound- Returns:
trueifvaris of a compound type withtypeName,falseelse
-
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 ifvaris null.- Parameters:
var- the variablenested- 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 givenvar.- 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 thenestedfield ofvar.- Parameters:
var- the variable (may be null)nested- the nested field to take the value fromdeflt- 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 thenestedfield ofvar.- Parameters:
var- the variable (may be null)nested- the nested field to take the value fromdeflt- 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 thenestedfield ofvar.- Parameters:
var- the variable (may be null)nested- the nested field to take the value fromdeflt- 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 givenvar.- Parameters:
var- the variable (may be null)- Returns:
- the value or null
-
toName
Turns an enum value to its name.- Parameters:
value- the value, may be nulldeflt- 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 givenvar.- 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 givenvar.- 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 ofvartaking null into account.- Parameters:
var- the variabledflt- the default ifvaris 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 ofcstifcstis 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 ofcstifcstis a constant int expression.- Parameters:
cst- the constraint syntax treedflt- the default value ifcstis 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 printemitWarnings- shall warnings be emittedemitMessages- shall messages be emitted- Returns:
truefor conflict,falsefor 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 resultvarName- 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) Dereferencesvar.- 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 ofroot.- Parameters:
root- the root project to start searching- Returns:
- the templates, may be empty
-
containsVariable
Returns whetherprjdeclares a variable namedvarName.- Parameters:
prj- the project to inspectvarName- the variable to look for- Returns:
truefor contained/declared,falseelse
-
isTemplate
public static boolean isTemplate(net.ssehub.easy.varModel.model.Project prj) Returns whetherprjrepresents an application template project.- Parameters:
prj- the project to check- Returns:
truefor template,falseelse
-
isTemplate
public static boolean isTemplate(net.ssehub.easy.varModel.model.AbstractVariable var) Returns whethervarrepresents an application template.- Parameters:
var- the variable to check- Returns:
truefor template,falseelse
-
isApplication
public static boolean isApplication(net.ssehub.easy.varModel.model.AbstractVariable var) Returns whethervarrepresents an application.- Parameters:
var- the variable to check- Returns:
truefor application,falseelse
-
isInTemplate
public static boolean isInTemplate(net.ssehub.easy.varModel.model.AbstractVariable var) Returns whethervaris in a template.- Parameters:
var- the variable to check- Returns:
trueifvaris declared in a template,falseelse
-
isInTemplate
public static boolean isInTemplate(net.ssehub.easy.varModel.confModel.IDecisionVariable var) Returns whethervaris in a template.- Parameters:
var- the variable to check- Returns:
trueifvaris declared in a template,falseelse
-
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 usevar.- Parameters:
root- the project to start looking intovar- 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 withprj.- Parameters:
prj- the project to start the imports withprojects- 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 ofprj.- Type Parameters:
E- the type to select/iterate over- Parameters:
prj- the project to take the elements fromcls- representation of the type/filterconsumer- called for each matching element
-
hasAnnotation
Returns whether inprjan annotation with givennameis declared/annotated.- Parameters:
prj- the projectname- the name of the annotation- Returns:
truefor exists,falseelse
-