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


Java Project.getElementCount方法代码示例

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


在下文中一共展示了Project.getElementCount方法的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: addOperations

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Adds all operations of <code>project</code> and its imports to <code>operations</code>.
 * 
 * @param operations the name-operation mapping to be filled as a side effect
 * @param fields the name-field mapping to be filled as a side effect
 * @param project the project the operations shall be added for
 * @param done already done projects
 */
private void addOperations(Map<String, OperationDescriptor> operations, Map<String, FieldDescriptor> fields, 
    Project project, Set<Project> done) {
    if (!done.contains(project)) {
        done.add(project);
        int eCount = project.getElementCount();
        for (int e = 0; e < eCount; e++) {
            ContainableModelElement elt = project.getElement(e);
            if (elt instanceof DecisionVariableDeclaration) {
                addOperations((DecisionVariableDeclaration) elt, operations, fields);
            } else if (elt instanceof AttributeAssignment) {
                addOperations((AttributeAssignment) elt, operations, fields);
            }
        }
        for (int i = 0; i < project.getImportsCount(); i++) {
            Project imp = project.getImport(i).getResolved();
            if (null != imp) {
                addOperations(operations, fields, imp, done);
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:30,代码来源:IvmlProjectTypeDescriptor.java

示例3: getCopiedElements

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Searches for the copied elements inside the given projects and returns them in the same order as the passed
 * originals.
 * @param project The project for which the copied elements shall be returned.
 * @param originals The originals for which the copied elements shall be returned.
 * @return The elements of the given project with the same name as the specified orignals, in the same order.
 */
private ContainableModelElement[] getCopiedElements(Project project, ContainableModelElement... originals) {
    ContainableModelElement[] copiedElements = new ContainableModelElement[originals.length];
    for (int i = 0; i < project.getElementCount(); i++) {
        ContainableModelElement copiedElement = project.getElement(i);
        boolean found = false;
        for (int j = 0; j < originals.length && !found; j++) {
            if (originals[j].getName().equals(copiedElement.getName())) {
                copiedElements[j] = copiedElement;
                found = true;
            }
        }
    }
    
    return copiedElements;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:23,代码来源:ProjectRewriteVisitorTest.java

示例4: freezeValues

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Sets {@link AssignmentState#FROZEN} state to already frozen variables. 
 * 
 * @param project the project to be frozen
 * @param filter the filter type
 */
public void freezeValues(Project project, FilterType filter) {
    FrozenElementsFinder finder = new FrozenElementsFinder(project, filter);
    List<IFreezable> frozenElements = finder.getFrozenElements();
    
    FreezeEvaluator selector = new FreezeEvaluator(this);
    for (int i = 0; i < frozenElements.size(); i++) {
        IFreezable frozenElement = frozenElements.get(i);
        selector.setFreeze(finder.getFreezeBlock(frozenElement));
        if (frozenElement instanceof AbstractVariable) {
            freezeValues((AbstractVariable) frozenElement, selector);
        } else if (frozenElement instanceof Project) {
            Project prj = (Project) frozenElement;
            for (int e = 0; e < prj.getElementCount(); e++) {
                ContainableModelElement elt = prj.getElement(e);
                if (elt instanceof AbstractVariable) {
                    freezeValues((AbstractVariable) elt, selector);
                }
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:28,代码来源:Configuration.java

示例5: createModelContent

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Creates the model content based on the given <code>project</code>.
 * 
 * @param project the IVML project instance
 */
private void createModelContent(Project project) {
    if (null != project) {
        int elementCount = project.getElementCount();
        for (int c = 0; c < elementCount; c++) {
            collect(project.getElement(c));
        }
        int importCount = project.getImportsCount();
        if (importCount > 0) {
            for (int i = 0; i < importCount; i++) {
                System.err.println("imports found!");
                resolveImports(project.getImport(i));
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:21,代码来源:Model.java

示例6: visitProject

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
public void visitProject(Project project) {
    abortReasoning = false;
    String name = project.getName();
    dPrinter = new DroolsPrinter();
    if (evaluationChecking) {
        name += "_eval";
    }
    (new DroolsDelegationVisitor()).addDroolsGlobals(name, dPrinter);
    
    
    for (int i = 0; i < project.getElementCount(); i++) {
        if (project.getElement(i) instanceof DecisionVariableDeclaration
                && ((DecisionVariableDeclaration) project.getElement(i)).getType() instanceof Compound) {
            DecisionVariableDeclaration decl = (DecisionVariableDeclaration) project.getElement(i);
            if (compMap2.containsKey(decl.getType().getName())) {
                compMap2.get(decl.getType().getName()).add(decl.getName());
            } else {
                compMap2.put(decl.getType().getName(), new ArrayList<String>());
                compMap2.get(decl.getType().getName()).add(decl.getName());
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:25,代码来源:DroolsVisitor.java

示例7: visitProject

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override // iterate over all elements declared in project, implicitly skipping not implemented elements
public void visitProject(Project project) {
    for (int e = 0; e < project.getElementCount(); e++) {
        project.getElement(e).accept(this);
    }
    if (null != evals) {
        // prioritize top-level project contents over eval blocks
        for (PartialEvaluationBlock block : evals) {
            for (int i = 0; i < block.getNestedCount(); i++) {
                block.getNested(i).accept(this);
            }
            for (int i = 0; i < block.getEvaluableCount(); i++) {
                block.getEvaluable(i).accept(this);
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:18,代码来源:Resolver.java

示例8: getTypeDefRestriction

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
public String getTypeDefRestriction (String typeName) {
	String typeDefRestrictionString = "";
	Constraint typeDefRestriction = null;
	Project varModelProject = getVarModelProject();
	
	int elementCounter = varModelProject.getElementCount();
	
	for (int i=0; i<elementCounter; i++) {
		if (varModelProject.getElement(i).getName() != null
				&& varModelProject.getElement(i).getName().equals(typeName)) {
			
			DerivedDatatype typeDef = (DerivedDatatype) varModelProject.getElement(i);
			
			typeDefRestriction = typeDef.getConstraint(0);
			
			if (typeDefRestriction != null) {
				typeDefRestrictionString = StringProvider.toIvmlString(typeDefRestriction.getConsSyntax());
			}
		}
	}
	
	return typeDefRestrictionString;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:ModelConnector.java

示例9: 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

示例10: 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

示例11: 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

示例12: visitProjectImport

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
    public void visitProjectImport(ProjectImport pImport) {
        
        Project importedProject = pImport.getResolved();
//        logger.info("name of the project import " + importedProject.getName());
//        logger.info("\ttotal elements " + importedProject.getElementCount());
//        logger.info("\ttotal internal constraints " + importedProject.getInternalConstraintCount());
        
        importedProjectName = pImport.getProjectName();
        int count = ruleCount;
        for (int i = 0; i < importedProject.getElementCount(); i++) { 
            this.ruleMapper.put(new Integer(ruleCount), importedProject.getElement(i));
            importedProject.getElement(i).accept((IModelVisitor) this);
            ruleCount++;
            count++;
        }
        
        for (int j = 0; j < importedProject.getInternalConstraintCount(); j++) {
            this.ruleMapper.put(new Integer(ruleCount), importedProject.getInternalConstraint(j));
            importedProject.getInternalConstraint(j).accept((IModelVisitor) this); 
            this.ruleCount++;
            count++;
        } 
        importedProjectMap.put(importedProjectName, count);
        variablesAssigned.removeAll(variablesAssigned);
        importedProjectName = "";
    }
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:28,代码来源:DroolsVisitor.java

示例13: 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

示例14: visitProject

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
public void visitProject(Project project) {
    for (int i = 0; i < project.getImportsCount(); i++) {
        project.getImport(i).accept(this);
    }
    int eSize = project.getElementCount();
    for (int e = 0; e < eSize; e++) {
        project.getElement(e).accept(this);
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:11,代码来源:VariableCollector.java

示例15: assertProjectContainment

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Helpermethod: Tests whether the copied projects contain the expected elements.
 * @param testProject The copied and modified project.
 * @param element An element which shall (not) be contained.
 * @param shallbeContained <tt>true</tt> the specified element must still exist inside the copied project,
 *     <tt>false</tt> the copied project must <b>not</b> contain the specified element.
 * @param nElementsExpected The number of expected {@link ContainableModelElement}s, which shall still be part of
 *     the test {@link Project}. 
 */
private void assertProjectContainment(Project testProject, ContainableModelElement element,
    boolean shallbeContained, int nElementsExpected) {
    
    boolean elementFound = false;
    int nElementsFound = testProject.getElementCount();

    Assert.assertEquals("Error: Copied project does not contain the expected number of items.", nElementsExpected,
        nElementsFound);
    
    /*
     * Test whether the element is part of the project.
     * equals/toString cannot be used.
     * StringProvider creates a sufficient String, which could be unambiguously parsed by Xtext.
     */
    String elementAsString = StringProvider.toIvmlString(element);
    for (int i = 0; i < nElementsFound && !elementFound; i++) {
        String currentElementAsString = StringProvider.toIvmlString(testProject.getElement(i));
        elementFound = elementAsString.equals(currentElementAsString);
    }
    
    String errMsgName = (element instanceof Constraint) ? elementAsString.trim() : element.getName();
    if (shallbeContained) {
        Assert.assertTrue("Expected element \"" + errMsgName + "\" not found.", elementFound);
    } else {
        Assert.assertFalse("Forbidden element \"" + errMsgName + "\" found.", elementFound);            
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:37,代码来源:ProjectRewriteVisitorTest.java


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