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


Java Project.getElement方法代码示例

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


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

示例1: addTopLevelValues

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Adds top level values configured for <code>source</code> to <code>target</code>.
 * 
 * @param cfg the actual configuration holding the values
 * @param source the source project
 * @param target the target project
 * @param exclude the variable names to exclude
 * @return the changed top-level variables ready for freezing
 * @throws CSTSemanticException in case of CST errors
 */
private static List<IFreezable> addTopLevelValues(Configuration cfg, Project source, Project target, 
    String... exclude) throws CSTSemanticException {
    List<IFreezable> result = new ArrayList<IFreezable>();
    for (int e = 0; e < source.getElementCount(); e++) {
        ContainableModelElement elt = source.getElement(e);
        if (elt instanceof DecisionVariableDeclaration) {
            DecisionVariableDeclaration decl = (DecisionVariableDeclaration) elt;
            if (!Arrays.contains(exclude, decl.getName())) {
                IDecisionVariable decVar = cfg.getDecision(decl);
                Value value = decVar.getValue();
                if (null != value && !ConstraintType.isConstraint(decVar.getDeclaration().getType())) {
                    ConstraintSyntaxTree cst = new OCLFeatureCall(new Variable(decl), IvmlKeyWords.ASSIGNMENT, 
                        new ConstantValue(decVar.getValue().clone()));
                    cst.inferDatatype();
                    Constraint constraint = new Constraint(cst, target);
                    target.addConstraint(constraint);
                    result.add(decl);
                }
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:34,代码来源:AlgorithmProfileHelper.java

示例2: put

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Puts the variables of project into <code>data</code> if they comply with <code>selector</code>.
 * 
 * @param project the project to be iterated over
 * @param data the data to be modified as a side effect (fqn-instance mapping)
 * @param cfg the underlying IVML configuration
 * @param selector the selector instance
 */
private void put(Project project, Map<String, IDecisionVariable> data, 
    net.ssehub.easy.varModel.confModel.Configuration cfg, IVariableSelector selector) {
    for (int i = 0; i < project.getImportsCount(); i++) {
        ProjectImport imp = project.getImport(i);
        if (null != imp.getResolved()) {
            put(imp.getResolved(), data, cfg, selector);
        }
    }
    for (int e = 0; e < project.getElementCount(); e++) {
        ContainableModelElement elt = project.getElement(e);
        if (elt instanceof AbstractVariable) {
            IDecisionVariable var = cfg.getDecision((AbstractVariable) elt);
            if (null != var && AssignmentState.FROZEN == var.getState() && selector.select(var)) {
                data.put(var.getDeclaration().getQualifiedName(), var);
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:27,代码来源:ConfigurationTests.java

示例3: testPartialEvaluationCopyWithInternallyDeclaredVariable

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests a copying of an evaluation block containing a constraining, which uses a
 * {@link DecisionVariableDeclaration} declared inside of the block.
 * @throws CSTSemanticException If {@link Constraint#setConsSyntax(ConstraintSyntaxTree)} is not working.
 */
@Test
public void testPartialEvaluationCopyWithInternallyDeclaredVariable() throws CSTSemanticException {
    Project orgProject = new Project("testPartialEvaluationCopyWithInternallyDeclaredVariable");
    PartialEvaluationBlock evalBlock = new PartialEvaluationBlock("evalBlock", orgProject);
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", BooleanType.TYPE, evalBlock);
    Constraint constraint = new Constraint(evalBlock);
    OCLFeatureCall equality = new OCLFeatureCall(new Variable(decl), OclKeyWords.EQUALS,
        new ConstantValue(BooleanValue.TRUE));
    constraint.setConsSyntax(equality);
    evalBlock.setEvaluables(new IPartialEvaluable[] {constraint});
    orgProject.add(evalBlock);
    evalBlock.addModelElement(decl);
    
    java.util.Set<Project> copiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, copiedProjects);
    PartialEvaluationBlock copiedBlock = (PartialEvaluationBlock) copiedProject.getElement(0);
    assertEvalBlock(evalBlock, copiedBlock, copiedProject, copiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:ProjectCopyVisitorTest.java

示例4: testAssignBlockCopySimple

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests that simple {@link AttributeAssignment}s can be copied without outstanding dependencies.
 */
@Test
public void testAssignBlockCopySimple() {
    Project orgProject = new Project("testAssignBlockCopySimple");
    Attribute annoDecl = new Attribute("anno", BooleanType.TYPE, orgProject, orgProject);
    orgProject.add(annoDecl);
    orgProject.attribute(annoDecl);
    AttributeAssignment assignBlock = new AttributeAssignment(orgProject);
    ConstantValue constTrue = new ConstantValue(BooleanValue.TRUE);
    Assignment assignment = new Assignment(annoDecl.getName(), OclKeyWords.EQUALS, constTrue);
    assignBlock.add(assignment);
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", StringType.TYPE, assignBlock);
    assignBlock.add(decl);
    orgProject.add(assignBlock);
    
    java.util.Set<Project> allCopiedProject = new HashSet<Project>();
    Project copy = copyProject(orgProject, allCopiedProject);
    AttributeAssignment copiedBlock = (AttributeAssignment) copy.getElement(1);
    assertAssignBlock(assignBlock, copiedBlock, copy, allCopiedProject);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:ProjectCopyVisitorTest.java

示例5: testOperationDependingCSTCopy

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests whether a {@link OperationDefinition}, with a depending CST could be copied.
 */
@Test
public void testOperationDependingCSTCopy() {
    Project original = new Project("testOperationDependingCSTCopy");
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", RealType.TYPE, original);
    OperationDefinition operation = new OperationDefinition(original);
    ExplicitTypeVariableDeclaration parameterDecl = new ExplicitTypeVariableDeclaration("param1", RealType.TYPE,
            operation);
    OCLFeatureCall comparison = new OCLFeatureCall(new Variable(parameterDecl), OclKeyWords.GREATER,
        new Variable(decl));
    CustomOperation func = new CustomOperation(BooleanType.TYPE, "returnsTrue", original.getType(), comparison,
            new DecisionVariableDeclaration[] {parameterDecl});
    operation.setOperation(func);
    original.add(operation);
    original.add(decl);
    
    Project copy = copyProject(original);
    OperationDefinition copiedOp = (OperationDefinition) copy.getElement(1);
    assertUserOperation(operation, copiedOp, copy);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:ProjectCopyVisitorTest.java

示例6: testFreezeBlockKnownDeclarationSimpleBut

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests copying a {@link FreezeBlock}. It tests:
 * <ul>
 *   <li>A known declaration</li>
 *   <li>Simple but block (constant expression)</li>
 * </ul>
 */
@Test
public void testFreezeBlockKnownDeclarationSimpleBut() {
    Project orgProject = new Project("testFreezeBlockKnownDeclarationSimpleBut");
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", RealType.TYPE, orgProject);
    orgProject.add(decl);
    DecisionVariableDeclaration itrDecl = new DecisionVariableDeclaration("i", BooleanType.TYPE, orgProject);
    ConstantValue trueExpr = new ConstantValue(BooleanValue.TRUE);
    FreezeBlock freeze = new FreezeBlock(new IFreezable[] {decl}, itrDecl, trueExpr, orgProject);
    orgProject.add(freeze);
    
    java.util.Set<Project> allCopiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, allCopiedProjects);
    // Attention: Ordering has changed
    FreezeBlock copiedBlock = (FreezeBlock) copiedProject.getElement(1);
    assertFreezeBlock(freeze, copiedBlock, copiedProject, allCopiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:ProjectCopyVisitorTest.java

示例7: testFreezeBlockDependingCompoundAccess

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests copying a {@link FreezeBlock}. It tests:
 * <ul>
 *   <li>A compound access, which is defined at a alter point</li>
 *   <li>No But expression</li>
 * </ul>
 */
@Test
public void testFreezeBlockDependingCompoundAccess() {
    Project orgProject = new Project("testFreezeBlockDependingCompoundAccess");
    Compound cType = new Compound("CP", orgProject);
    DecisionVariableDeclaration slotDecl = new DecisionVariableDeclaration("slot", StringType.TYPE, cType);
    cType.add(slotDecl);
    orgProject.add(cType);
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", cType, orgProject);
    CompoundAccessStatement cpAccess = new CompoundAccessStatement(decl, slotDecl.getName(), orgProject);
    FreezeBlock freeze = new FreezeBlock(new IFreezable[] {cpAccess}, null, null, orgProject);
    orgProject.add(freeze);
    orgProject.add(decl);
    
    java.util.Set<Project> allCopiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, allCopiedProjects);
    // Attention: Ordering has changed
    FreezeBlock copiedBlock = (FreezeBlock) copiedProject.getElement(2);
    assertFreezeBlock(freeze, copiedBlock, copiedProject, allCopiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:27,代码来源:ProjectCopyVisitorTest.java

示例8: testSimpleConstraintCopy

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Copies a constraint, which has no outstanding dependencies.
 * @throws ValueDoesNotMatchTypeException If String values cannot be created.
 * @throws CSTSemanticException If a string constraint cannot be created
 */
@Test
public void testSimpleConstraintCopy() throws ValueDoesNotMatchTypeException, CSTSemanticException {
    Project original = new Project("testSimpleConstraintCopy");
    IDatatype basisType = StringType.TYPE;
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", basisType, original);
    original.add(decl);
    Constraint constraint = new Constraint(original);
    ConstantValue helloWorldVal = new ConstantValue(ValueFactory.createValue(basisType, "Hello World"));
    OCLFeatureCall equality = new OCLFeatureCall(new Variable(decl), OclKeyWords.EQUALS, helloWorldVal);
    constraint.setConsSyntax(equality);
    original.add(constraint);
    
    java.util.Set<Project> copiedProjects = new HashSet<Project>();
    Project copy = copyProject(original, copiedProjects);
    Constraint copiedConstraint = (Constraint) copy.getElement(1);
    assertConstraint(constraint, copiedConstraint, copy, copiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:ProjectCopyVisitorTest.java

示例9: testFreezeBlockDependingCompoundAccessType

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests copying a {@link FreezeBlock}. It tests:
 * <ul>
 *   <li>A compound access, which <b>type</b> is defined at a alter point</li>
 *   <li>No But expression</li>
 * </ul>
 */
@Test
public void testFreezeBlockDependingCompoundAccessType() {
    Project orgProject = new Project("testFreezeBlockDependingCompoundAccessType");
    Compound cType = new Compound("CP", orgProject);
    DecisionVariableDeclaration slotDecl = new DecisionVariableDeclaration("slot", StringType.TYPE, cType);
    cType.add(slotDecl);
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", cType, orgProject);
    orgProject.add(decl);
    CompoundAccessStatement cpAccess = new CompoundAccessStatement(decl, slotDecl.getName(), orgProject);
    FreezeBlock freeze = new FreezeBlock(new IFreezable[] {cpAccess}, null, null, orgProject);
    orgProject.add(freeze);
    orgProject.add(cType);
    
    java.util.Set<Project> allCopiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, allCopiedProjects);
    // Attention: Ordering has changed
    FreezeBlock copiedBlock = (FreezeBlock) copiedProject.getElement(2);
    assertFreezeBlock(freeze, copiedBlock, copiedProject, allCopiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:27,代码来源:ProjectCopyVisitorTest.java

示例10: testFreezeBlockKnownDeclarationAnnotationBut

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests copying a {@link FreezeBlock}. It tests:
 * <ul>
 *   <li>A known declaration</li>
 *   <li>But expression on annotation</li>
 * </ul>
 */
@Test
public void testFreezeBlockKnownDeclarationAnnotationBut() {
    Project orgProject = new Project("testFreezeBlockKnownDeclarationAnnotationBut");
    Attribute annoDecl = new Attribute("anno", BooleanType.TYPE, orgProject, orgProject);
    orgProject.add(annoDecl);
    orgProject.attribute(annoDecl);
    Compound cType = new Compound("CP", orgProject);
    DecisionVariableDeclaration slotDecl = new DecisionVariableDeclaration("slot", StringType.TYPE, cType);
    cType.add(slotDecl);
    orgProject.add(cType);
    DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", cType, orgProject);
    orgProject.add(decl);
    
    DecisionVariableDeclaration itrDecl = new DecisionVariableDeclaration("i", BooleanType.TYPE, orgProject);
    AttributeVariable annotationAccess = new AttributeVariable(new Variable(itrDecl), annoDecl);
    ConstantValue trueExpr = new ConstantValue(BooleanValue.TRUE);
    OCLFeatureCall equality = new OCLFeatureCall(annotationAccess, OclKeyWords.EQUALS, trueExpr); 
    FreezeBlock freeze = new FreezeBlock(new IFreezable[] {decl}, itrDecl, equality, orgProject);
    orgProject.add(freeze);
    
    java.util.Set<Project> allCopiedProjects = new HashSet<Project>();
    Project copiedProject = copyProject(orgProject, allCopiedProjects);
    FreezeBlock copiedBlock = (FreezeBlock) copiedProject.getElement(3);
    assertFreezeBlock(freeze, copiedBlock, copiedProject, allCopiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:33,代码来源:ProjectCopyVisitorTest.java

示例11: testCopyDerivedType

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests whether a simple {@link DerivedDatatype} without any dependencies can be copied.
 * @throws CSTSemanticException If <tt>true</tt>  cannot be created as constraint for a boolean type
 */
@Test
public void testCopyDerivedType() throws CSTSemanticException {
    Project original = new Project("testCopyDerivedType");
    IDatatype basisType = BooleanType.TYPE;
    DerivedDatatype dType = new DerivedDatatype("posType", basisType, original);
    Constraint constraint = new Constraint(dType);
    OCLFeatureCall equality = new OCLFeatureCall(new Variable(dType.getTypeDeclaration()), OclKeyWords.EQUALS,
            new ConstantValue(BooleanValue.TRUE));
    constraint.setConsSyntax(equality);
    dType.setConstraints(new Constraint[] {constraint});
    original.add(dType);
    
    java.util.Set<Project> copiedProjects = new HashSet<Project>();
    Project copy = copyProject(original, copiedProjects);
    DerivedDatatype copiedType = (DerivedDatatype) copy.getElement(0);
    assertDerivedType(dType, copiedType, copy, copiedProjects);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:22,代码来源:ProjectCopyVisitorTest.java

示例12: searchSequenceValue

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Searches the given <code>project</code> for a sequence that contains <code>value</code> and returns the sequence
 * index access expression if successful. This method shall not be called directly. Use 
 * {@link #searchSequenceValue(Project, Value, Configuration)} instead.
 * 
 * @param project the project to start searching
 * @param value the value to be used as reference
 * @param config the actual configuration
 * @param done all the projects that have been searched so far
 * @return the access expression or <b>null</b> if none can be created
 */
private ConstraintSyntaxTree searchSequenceValue(Project project, Value value, Configuration config, 
    Set<Object> done) {
    ConstraintSyntaxTree result = null;
    if (!done.contains(project)) {
        done.add(project);
        IDatatype valueType = value.getType();
        // search for a sequence that has the value type as generic type, try to access the value
        // and if this works, create a index access expression
        for (int e = 0; e < project.getElementCount(); e++) {
            ContainableModelElement elt = project.getElement(e);
            if (elt instanceof DecisionVariableDeclaration) {
                DecisionVariableDeclaration decl = (DecisionVariableDeclaration) elt;
                IDatatype declType = decl.getType();
                if (Sequence.isSequence(declType, valueType)) {
                    IDecisionVariable candidateVar = config.getDecision(decl);
                    result = createIndexAccess(decl, candidateVar.getValue(), value);
                }
            }
        }
        // if not found, search in related projects
        if (null == result) {
            for (int i = 0; null == result && i < project.getImportsCount(); i++) {
                Project imp = project.getImport(i).getResolved();
                if (null != imp) {
                    result = searchSequenceValue(imp, value, config, done);
                }
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:43,代码来源:QualiMasterConfigurationSaver.java

示例13: obtainPipelineElementByName

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Obtains a pipeline element.
 * 
 * @param pipeline the pipeline
 * @param type the type of the element (may be <b>null</b>)
 * @param name the name of the element
 * @return the element or <b>null</b> if it does not exist for some reason
 */
@QMInternal
public static IDecisionVariable obtainPipelineElementByName(IDecisionVariable pipeline, IDatatype type, 
    String name) {
    IDecisionVariable result = null;
    net.ssehub.easy.varModel.confModel.Configuration config = null;
    Project project = null;
    if (null != pipeline) {
        config = pipeline.getConfiguration();
        AbstractVariable var = pipeline.getDeclaration();
        project = var.getProject();
    }
    if (null != project) { // implies config != null
        for (int e = 0, n = project.getElementCount(); null == result && e < n; e++) {
            ContainableModelElement elt = project.getElement(e);
            if (elt instanceof DecisionVariableDeclaration) {
                DecisionVariableDeclaration decl = (DecisionVariableDeclaration) elt;
                if (null == type || type.isAssignableFrom(decl.getType())) {
                    IDecisionVariable decVar = config.getDecision(decl);
                    if (VariableHelper.hasName(decVar, name) || decVar.getDeclaration().getName().equals(name)) {
                        result = decVar;
                    }
                }
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:36,代码来源:PipelineHelper.java

示例14: createFreezeBlock

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Adds a freeze block to the project containing all elements.
 * 
 * @param project
 *            the IVML project to freeze
 * @return the created freeze block
 * @throws CSTSemanticException
 *             in case of CST errors
 * @throws ValueDoesNotMatchTypeException
 *             in case of unmatching values
 * @throws ModelQueryException
 *             in case of model access problems
 */
public static FreezeBlock createFreezeBlock(Project project)
        throws CSTSemanticException, ValueDoesNotMatchTypeException, ModelQueryException {
    List<IFreezable> freezables = new ArrayList<IFreezable>();
    for (int e = 0; e < project.getElementCount(); e++) {
        ContainableModelElement elt = project.getElement(e);
        if (elt instanceof IFreezable) {
            freezables.add((IFreezable) elt);
        }
    }
    FreezeBlock result = createFreezeBlock(freezables, project, project);
    project.add(result);
    return result;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:27,代码来源:Utils.java

示例15: IvmlTypeResolver

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Creates an IVML type resolver.
 * 
 * @param project the IVML model
 * @param typeRegistry the type registry this resolver is working for
 */
public IvmlTypeResolver(Project project, TypeRegistry typeRegistry) {
    this.project = project;
    this.typeRegistry = typeRegistry;
    
    int eCount = project.getElementCount();
    for (int e = 0; e < eCount; e++) {
        ContainableModelElement elt = project.getElement(e);
        if (elt instanceof DecisionVariableDeclaration) {
            cacheVariable((DecisionVariableDeclaration) elt);
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:19,代码来源:IvmlTypeResolver.java


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