当前位置: 首页>>代码示例>>Java>>正文


Java AbstractVariable.getType方法代码示例

本文整理汇总了Java中net.ssehub.easy.varModel.model.AbstractVariable.getType方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractVariable.getType方法的具体用法?Java AbstractVariable.getType怎么用?Java AbstractVariable.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.ssehub.easy.varModel.model.AbstractVariable的用法示例。


在下文中一共展示了AbstractVariable.getType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCompoundNameAndType

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Returns a map which key is the variable name, value is the variable type.
 * 
 * @param decisionDeclaration
 *            the compound decisionVariable
 * @return a map with variableName and variableType
 */
public static Map<String, IDatatype> getCompoundNameAndType(AbstractVariable decisionDeclaration) {

    String compoundName = null;
    Map<String, IDatatype> map = new HashMap<String, IDatatype>();
    Compound compoundType = (Compound) decisionDeclaration.getType();
    for (int i = 0; i < compoundType.getInheritedElementCount(); i++) {
        DecisionVariableDeclaration nestedDecl = compoundType.getInheritedElement(i);
        compoundName = nestedDecl.getName();
        IDatatype type = nestedDecl.getType();
        if (type instanceof Reference) {
            Reference refType = (Reference) type;
            map.put(compoundName, refType);
        } else {
            map.put(compoundName, type);

        }
    }
    return map;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:27,代码来源:BasicIVMLModelOperations.java

示例2: isSavingEnabled

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
@Override
protected boolean isSavingEnabled(Project destProject, IDecisionVariable var) {
    // avoid that all imported config is saved over and over again
    // role separation
    boolean enabled;
    AbstractVariable decl = var.getDeclaration();
    IDatatype type = decl.getType();
    // QualiMaster convention
    if (ConstraintType.isConstraint(type)) {
        enabled = false;
    } else if (var.getParent() instanceof Configuration) {
        String decisionNamespace = var.getDeclaration().getNameSpace();
        String dstProjectNamespace = destProject.getName();
        enabled = dstProjectNamespace.equals(decisionNamespace);

        if (!enabled && dstProjectNamespace.endsWith(QmConstants.CFG_POSTFIX)) {
            String defProjectNamespace = dstProjectNamespace.substring(0, 
                dstProjectNamespace.length() - QmConstants.CFG_POSTFIX.length());
            enabled = defProjectNamespace.equals(decisionNamespace);
        }
    } else {
        enabled = true;
    }
    return enabled;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:26,代码来源:QualiMasterConfigurationSaver.java

示例3: obtainPipeline

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Returns the pipeline decision for the given pipeline <code>element</code>.
 * 
 * @param configuration the configuration for the lookup
 * @param element the pipeline element (may be <b>null</b>, leads to <b>null</b>)
 * @return the pipeline, may be <b>null</b> if the pipeline was not found
 * @throws ModelQueryException if accessing type information fails
 */
@Invisible
public static IDecisionVariable obtainPipeline(net.ssehub.easy.varModel.confModel.Configuration configuration, 
    IDecisionVariable element) throws ModelQueryException {
    IDecisionVariable result = null;
    if (null != element) {
        AbstractVariable elementDecl = element.getDeclaration();
        IDatatype elementType = elementDecl.getType();
        IModelElement par = elementDecl.getTopLevelParent();
        if (par instanceof Project) {
            Project prj = (Project) par;
            IDatatype pipelineElementType = ModelQuery.findType(prj, QmConstants.TYPE_PIPELINE_ELEMENT, null);
            if (null != pipelineElementType && pipelineElementType.isAssignableFrom(elementType)) {
                IDatatype pipelineType = ModelQuery.findType(prj, QmConstants.TYPE_PIPELINE, null);
                if (null != pipelineType) {
                    result = searchScope(configuration, prj, pipelineType);
                }
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:30,代码来源:PipelineHelper.java

示例4: checkDeclarationIsInList

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Checks whether a given declaration is in a given project.
 * @param declarations A List of declarations, retrieved by a
 * {@link net.ssehub.easy.varModel.model.filter.DeclarationFinder}.
 * @param decl The desired variable Declaration, which should (not) be included in the given list.
 * @param shouldBeFound <tt>true</tt> if the given declaration should be found in the given project,
 *     <tt>false</tt> otherwise.
 */
private void checkDeclarationIsInList(List<AbstractVariable> declarations, AbstractVariable decl,
    boolean shouldBeFound) {
    
    boolean found = false;
    for (int i = 0; i < declarations.size(); i++) {
        AbstractVariable declarationOfList = declarations.get(i);
        if (declarationOfList.getName().equals(decl.getName())) {
            found = declarationOfList.getType() == decl.getType();
            break;
        }
    }
    
    if (shouldBeFound) {
        Assert.assertTrue("Declaration " + decl + " should be included in project, but is not.", found);
    } else {
        Assert.assertFalse("Declaration " + decl + " must not be included in project, but was found.", found);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:27,代码来源:ConfigurationTest.java

示例5: checkDeclaration

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Check whether the {@link IDatatype} of an {@link AbstractVariable} is part of the {@link Project}.
 * @param decl The declaration to check, must be part of the project.
 */
private void checkDeclaration(AbstractVariable decl) {
    IDatatype type = decl.getType();
    // Test IDatatypes, which must be added to the project separately
    if ((type instanceof Enum || type instanceof Compound) && !customTypes.contains(type)) {
        addError("datatype '" + type.getName() + "' of '" + decl.getName() + "' is not part of the project", decl,
            ValidationMessage.MISSING_CUSTOM_DATATYPE);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:13,代码来源:IvmlValidationVisitor.java

示例6: bind

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Binds the given <code>type</code> to the first matching decision variable. Rationale: Static (all-quantized)
 * variable access needs to be bound automatically. In that case, there is an implicitly created enclosing quantor
 * (rewritten expression), and only one, i.e., the first one can be bound.
 * 
 * @param type the type to bind to
 * @param context the evaluation context
 * @return the bound value (may be <b>null</b> if there is none)
 */
Value bind(IDatatype type, EvaluationContext context) {
    Value result = null;
    // is this unique??
    for (IDecisionVariable var : map.values()) {
        AbstractVariable decl = var.getDeclaration();
        if (!LocalDecisionVariable.ITERATOR_RESULT_VARNAME.equals(decl.getName())) {
            IDatatype varType = decl.getType();
            if (TypeQueries.sameTypes(type, varType)) {
                result = var.getValue();
                break;
            } else {
                if (varType instanceof Reference) { // explicitly only 1 step dereference due to allInstances
                    varType = ((Reference) varType).getType();
                    if (TypeQueries.sameTypes(type, varType)) {
                        ReferenceValue ref = (ReferenceValue) var.getValue();
                        if (null != ref) {
                            result = context.getDecision(ref.getValue()).getValue();
                            break;
                        }
                    } 
                }
            }
        }
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:36,代码来源:LocalConfiguration.java

示例7: collectNestedConstraintVariables

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Finds all nested constraint variables in the given {@link ConstraintSyntaxTree} and adds them to the
 * {@link VariableLookUpTable}.
 * @param cst The {@link ConstraintSyntaxTree} to analyze, should be part of <tt>element</tt>. Nothing will
 * be done if it is <tt>null</tt>.
 * @param element The element to add (should be the parent of <tt>cst</tt>).
 */
private void collectNestedConstraintVariables(ConstraintSyntaxTree cst, ContainableModelElement element) {
    if (null != cst) {
        DeclrationInConstraintFinder finder = new DeclrationInConstraintFinder(cst);
        java.util.Set<AbstractVariable> usedDeclarations = finder.getDeclarations();
        for (AbstractVariable usedDecl : usedDeclarations) {
            if (null != usedDecl && usedDecl.getType() == ConstraintType.TYPE) {
                table.putConstraintOccurrence(usedDecl, element);
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:19,代码来源:InitialStructureCollector.java

示例8: findType

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Finds the definition of a data type within the model represented by <code>model</code>.
 * 
 * @param model the node representing the ECore Xtext model
 * @param typeDef the containing type (may be <b>null</b> for the project represented by <code>typeDef</code>)
 * @param name the name of the type (may be <b>null</b> to search for the type of <code>typeDef</code>
 * @return the type definition or <b>null</b> if not found
 * @see #getVarModel(EObject)
 */
protected IDatatype findType(EObject model, TypedefCompound typeDef, String name) {
    IDatatype result = null;
    String typeName = null == typeDef ? null : typeDef.getName();
    net.ssehub.easy.varModel.model.Project prj = getVarModel(model);
    if (null != prj) {
        IResolutionScope scope = prj;
        if (null != typeName) {
            try {
                IDatatype type = ModelQuery.findElementByTypeName(prj, typeName, null);
                if (null == name) {
                    result = type;
                }
                if (type instanceof IResolutionScope) {
                    scope = (IResolutionScope) type;
                }
            } catch (ModelQueryException e) {
                // ignore
            }
        }
        if (null != name) {
            try {
                AbstractVariable var = ModelQuery.findVariable(scope, name, null);
                if (null != var) {
                    result = var.getType();
                }
            } catch (ModelQueryException e1) {
                // ignore
            }
        }
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:42,代码来源:ExpressionProposalProvider.java

示例9: translateContainerCompoundConstraints

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Method for retrieving constraints from compounds initialized in containers.
 * 
 * @param decl AbstractVariable.
 * @param variable the instance of <tt>decl</tt>.
 * @param topcmpAccess {@link CompoundAccess} if container is a nested element.
 * @param results the resulting constraints
 */
private void translateContainerCompoundConstraints(AbstractVariable decl, IDecisionVariable variable, 
    CompoundAccess topcmpAccess, List<Constraint> results) {
    IDatatype type = decl.getType();
    if (TypeQueries.isContainer(type)) {
        IDatatype containedType = ((Container) type).getContainedType();
        for (IDatatype tmp : identifyContainedTypes(variable, containedType)) {
            if (TypeQueries.isCompound(tmp)) {
                translateContainerCompoundConstraints((Compound) tmp, containedType, decl, topcmpAccess, results);
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:21,代码来源:Resolver.java

示例10: assertDeclaration

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Checks that the original and copied declaration are basically equal.
 * @param decl The original declaration
 * @param copieddecl The copied declaration to test
 * @param copyMapping Tuple of (original declaration, copied project parent) to verify parents (recursive
 * function for nested annotations).
 */
private void assertDeclaration(AbstractVariable decl, AbstractVariable copieddecl,
    Map<AbstractVariable, IModelElement> copyMapping) {
    
    assertCopiedElement(decl, copieddecl, copyMapping.get(decl));
    
    // Data type
    IDatatype orgType = decl.getType();
    IDatatype copiedType = copieddecl.getType();
    if (orgType.isPrimitive()) {
        Assert.assertSame("Copied declaration does not have the same type", orgType, copieddecl.getType());
    } else if (orgType instanceof Reference) {
        assertReferenceType((Reference) orgType, (Reference) copiedType, copieddecl.getProject());
    } else if (orgType instanceof DerivedDatatype) {
        java.util.Set<Project> copiedProjects = new HashSet<Project>();
        copiedProjects.add(copieddecl.getProject());
        assertDerivedType((DerivedDatatype) orgType, (DerivedDatatype) copiedType, copieddecl.getProject(),
            copiedProjects);
    } else if (orgType instanceof Container) {
        assertCopiedElement((CustomDatatype) orgType, (CustomDatatype) copiedType, copieddecl.getProject());
    }
    
    // Default value
    Assert.assertEquals("Copied type has not the same default value.", decl.getDefaultValue(),
        copieddecl.getDefaultValue());
    
    if (decl instanceof Attribute) {
        Attribute orgAnnoatation = (Attribute) decl;
        Attribute copiedAnnoatation = (Attribute) copieddecl;
        IAttributableElement orgAnnotatedElement = orgAnnoatation.getElement();
        IAttributableElement copiedAnnotatedElement = copiedAnnoatation.getElement();
        Assert.assertEquals(orgAnnotatedElement.getQualifiedName(), copiedAnnotatedElement.getQualifiedName());
        Assert.assertNotSame(orgAnnotatedElement, copiedAnnotatedElement);
    }
    
    // Annotations
    Assert.assertEquals(decl.isAttribute(), copieddecl.isAttribute());
    Assert.assertEquals("Copied declaration has not the same attribute count", decl.getAttributesCount(),
        copieddecl.getAttributesCount());
    for (int i = 0, end = decl.getAttributesCount(); i < end; i++) {
        AbstractVariable orgAnnotation = decl.getAttribute(i);
        if (null == copyMapping.get(orgAnnotation)) {
            copyMapping.put(orgAnnotation, copieddecl.getProject());
        }
        assertDeclaration(decl.getAttribute(i), copieddecl.getAttribute(i), copyMapping);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:54,代码来源:ProjectCopyVisitorTest.java

示例11: translateDeclarationDefaults

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Translates the (transitive) defaults and type constraints for a declaration. 
 * 
 * @param decl The {@link AbstractVariable} for which the default value should be resolved.
 * @param var the instance of <tt>decl</tt>.
 * @param cAcc if variable is a nested compound.
 * 
 * @see #translateDefaults()
 */
protected void translateDeclarationDefaults(AbstractVariable decl, IDecisionVariable var, CompoundAccess cAcc) {
    List<Constraint> defltCons = defaultConstraints; 
    variablesCounter++;
    IDatatype type = decl.getType();
    translateDerivedDatatypeConstraints(decl, type);
    if (!incremental) {
        translateAnnotationDefaults(decl, var, cAcc);
    }
    ConstraintSyntaxTree defaultValue = decl.getDefaultValue();
    if (TypeQueries.isCompound(type)) {
        if (null != defaultValue) { // try considering the actual type, not only the base type
            type = inferTypeSafe(defaultValue, type);
        }
        translateCompoundDefaults(decl, var, cAcc, type); 
        if (null != defaultValue) {
            defaultValue = substituteVariables(defaultValue, new Variable(decl));
        }
    } else if (null != defaultValue && !incremental) {
        if (TypeQueries.isContainer(type)) {
            Set<Compound> used = getUsedTypes(defaultValue, Compound.class);
            if (null != used && !used.isEmpty()) {
                for (Compound uType : used) {
                    translateDefaultsCompoundContainer(decl, uType, new HashSet<Compound>());
                }
            }
        } else if (null != cAcc) { // defer self/override init constraints to prevent accidental init override
            copyVisitor.setSelf(cAcc.getCompoundExpression());
            defaultValue = copyVisitor.accept(defaultValue);
            inferTypeSafe(defaultValue, null);
            if (copyVisitor.containsSelf() || isOverriddenSlot(decl)) {
                defltCons = deferredDefaultConstraints;
            }
            copyVisitor.clear();
        }
    } else {
        defaultValue = null;
    } // containerCompoundConstraints
    translateContainerCompoundConstraints(decl, var, null, otherConstraints); 
    if (TypeQueries.isContainer(type)) {            
        IDatatype containedType = ((Container) type).getContainedType();
        if (containedType instanceof DerivedDatatype) {
            translateContainerDerivedDatatypeConstraints((DerivedDatatype) containedType, decl, null);
        }
    }
    if (null != defaultValue) {
        try {
            if (TypeQueries.isConstraint(type)) {
                if (cAcc == null) {
                    variablesCounter--;
                    // use closest parent instead of project -> runtime analysis
                    Constraint constraint = new Constraint(defaultValue, var.getDeclaration());
                    addConstraint(otherConstraints, constraint, true); // constraintVariablesConstraints
                    constraintVariableMap.put(constraint, var); // just for reasoning messages
                    if (Descriptor.LOGGING) {
                        LOGGER.debug(var.getDeclaration().getName() + " project constraint variable " 
                            + toIvmlString(defaultValue));
                    }
                } 
            } else { // Create default constraint
                ConstraintSyntaxTree cst = new OCLFeatureCall(
                    defltCons == deferredDefaultConstraints ? cAcc : new Variable(decl), 
                    OclKeyWords.ASSIGNMENT, defaultValue);
                cst = substituteVariables(cst, null);
                addConstraint(defltCons, new DefaultConstraint(cst, project), true);
            }                
        } catch (CSTSemanticException e) {
            LOGGER.exception(e); // should not occur, ok to log
        }            
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:80,代码来源:Resolver.java

示例12: constraintRetrievalTest

import net.ssehub.easy.varModel.model.AbstractVariable; //导入方法依赖的package包/类
/**
 * Test whether all constraints are retrieved correctly. At this moment only normal and internal constraints.
 */
@Test
public void constraintRetrievalTest() {     
    Project project = loadProject("ConstraintRetrievalCheck.ivml");
    Configuration config = new Configuration(project, true);
    ReasonerModel rModel = new ReasonerModel(config, null);
   
    // Normal Constraints
    List<ConstraintSyntaxTree> normalConstaintList
        = new ArrayList<ConstraintSyntaxTree>(rModel.getNormalConstraintCount());
    for (int i = 0; i < rModel.getNormalConstraintCount(); i++) {
        normalConstaintList.add(rModel.getNormalConstraint(i));
    }
    printConstraints(normalConstaintList);
    
    // Test normal constraints
    System.out.println("Normal constraint count: " + normalConstaintList.size());
    Assert.assertEquals("Number of normal constraints", 9, normalConstaintList.size());

    //Internal Constraints
    List<ConstraintSyntaxTree> internalConstaintList
        = new ArrayList<ConstraintSyntaxTree>(rModel.getInternalConstraintCount());
    for (int i = 0; i < rModel.getInternalConstraintCount(); i++) {
        internalConstaintList.add(rModel.getInternalConstraint(i));
    }
    printConstraints(internalConstaintList);
    
    
    // Test internal constraints
    System.out.println("Internal constraint count: " + internalConstaintList.size());
    Assert.assertEquals("Number of internal constraints", 3, internalConstaintList.size());
    for (int i = 0; i < internalConstaintList.size(); i++) {            
        OCLFeatureCall constraint = (OCLFeatureCall) internalConstaintList.get(i);
        Variable variable = (Variable) constraint.getOperand();
        AbstractVariable decl = variable.getVariable();
        IDatatype type = decl.getType();
        Assert.assertEquals(DerivedDatatype.class, type.getClass());
    }
    
    // Test ReasonerDatatypes
    int nDatatypes = 0;
    Iterator<ReasonerDatatype> datatypeIterator = rModel.datatypeIterator();
    while (datatypeIterator.hasNext()) {
        nDatatypes++;
        ReasonerDatatype customType = datatypeIterator.next();
        if (customType instanceof EnumType) {
            EnumType enumType = (EnumType) customType;
            if (enumType.getName().equals("View")) {
                Assert.assertEquals(0, enumType.getMinOrdinal());
                Assert.assertEquals(2, enumType.getMaxOrdinal());
                Assert.assertTrue(enumType.isValidOrdinal(1));
                Assert.assertFalse(enumType.isValidOrdinal(enumType.getMaxOrdinal() + 1));
                Assert.assertFalse(enumType.isValidOrdinal(enumType.getMinOrdinal() - 1));
            } else if (enumType.getName().equals("ContentType")) {
                Assert.assertEquals(1, enumType.getMinOrdinal());
                Assert.assertEquals(8, enumType.getMaxOrdinal());
                Assert.assertFalse(enumType.isValidOrdinal(3));
                Assert.assertTrue(enumType.isValidOrdinal(4));
                Assert.assertFalse(enumType.isValidOrdinal(5));
                Assert.assertFalse(enumType.isValidOrdinal(enumType.getMaxOrdinal() + 1));
                Assert.assertFalse(enumType.isValidOrdinal(enumType.getMinOrdinal() - 1));
            }
        } else {
            CompoundType cmpType = (CompoundType) customType;
            Assert.assertEquals(3, cmpType.getConstraintCount());
        }
    }
    Assert.assertEquals(3, nDatatypes);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:72,代码来源:ReasonerModelTest.java


注:本文中的net.ssehub.easy.varModel.model.AbstractVariable.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。