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


Java VilException类代码示例

本文整理汇总了Java中net.ssehub.easy.instantiation.core.model.common.VilException的典型用法代码示例。如果您正苦于以下问题:Java VilException类的具体用法?Java VilException怎么用?Java VilException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VilException类属于net.ssehub.easy.instantiation.core.model.common包,在下文中一共展示了VilException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getParameterValue

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Returns a typed parameter value.
 * 
 * @param <T> the parameter type
 * @param script the script to return the parameter for
 * @param index the 0-based index
 * @param environment the environment holding the actual values
 * @param type the target type
 * @return the parameter value, <b>null</b> if the parameter does not exist or cannot be casted
 */
private static <T> T getParameterValue(Script script, int index, RuntimeEnvironment<?, ?> environment, 
    Class<T> type) {
    T result = null;
    if (script.getParameterCount() >= index + 1) {
        try {
            Object obj = environment.getValue(script.getParameter(index));
            if (type.isInstance(obj)) {
                result = type.cast(obj);
            }
        } catch (VilException e) {
            // undefined
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:26,代码来源:DelegatingLogTracer.java

示例2: initializePipeline

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Initializes the model for the given pipeline based on registered algorithm changed events.
 * 
 * @param pipelineName the pipeline name
 */
private static void initializePipeline(String pipelineName) {
    Models models = RepositoryConnector.getModels(Phase.ADAPTATION);
    Map<String, AlgorithmChangedMonitoringEvent> evts = startupAlgorithmChangedEvents.remove(pipelineName);
    if (null != evts && null != models) { // may be the case if InitializationMode != DYNAMIC
        Configuration config = models.getConfiguration();
        for (AlgorithmChangedMonitoringEvent event : evts.values()) {
            String pipeline = event.getPipeline();
            String pipelineElement = event.getPipelineElement();
            String algorithm = event.getAlgorithm();
            try {
                PipelineHelper.setActual(config, pipeline, pipelineElement, algorithm);
            } catch (VilException e) {
                LOGGER.error("While setting initial actual algorithm " + algorithm + " on " 
                    + pipelineElement + " in " + pipeline + ": " + e.getMessage());
            }
        }
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:24,代码来源:AdaptationEventQueue.java

示例3: handleImport

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Handles an import command.
 * 
 * @param line the line to be parsed
 * @param result the parse result to be modified as a side effect
 * @param profile the profile data
 * @throws IOException if parsing fails
 */
private void handleImport(String line, ParseResult result, IProfile profile) throws IOException {
    boolean dataOnly = false;
    String artifact = line.substring(IMPORT.length(), line.length()).trim();
    if (artifact.startsWith(DATA + " ")) {
        dataOnly = true;
        artifact = artifact.substring(DATA.length(), artifact.length()).trim();
    }
    File base = Files.createTempDirectory("qmProfiling").toFile();
    try {
        AlgorithmProfileHelper.extractProfilingArtifact(artifact, profile.getAlgorithmName(), base);
        File cf = AlgorithmProfileHelper.getControlFile(base);
        getLogger().info("Considering imported control file " + cf);
        if (cf.exists()) {
            getLogger().info("Parsing imported control file " + cf);
            ParseResult pResult = parseControlFile(cf, false, profile);
            if (!dataOnly) {
                result.merge(pResult, false);
            }
            addDataFiles(base, result, profile, true);
        }
    } catch (VilException e) {
        throw new IOException(e);
    }
    base.delete();
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:34,代码来源:SimpleParser.java

示例4: testObtainPipelineElement

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Tests to obtain a pipeline element.
 * 
 * @param vil use VIL or IVML access
 * @throws VilException in case that accessing the pipeline or a type fails
 */
private void testObtainPipelineElement(boolean vil) throws VilException {
    assertVarEquals(VAR_FAM1, VAR_FAM1, vil);
    String varName = getDecision(qmCfg, VAR_FAM1).getDeclaration().getName();
    assertVarEquals(VAR_FAM1, varName, vil);

    // qualified with cfg name
    assertVarEquals(VAR_FAM1, PRJ_MYPIP_CFG + IvmlKeyWords.NAMESPACE_SEPARATOR + VAR_FAM1, vil);
    assertVarEquals(VAR_FAM1, PRJ_MYPIP_CFG + IvmlKeyWords.NAMESPACE_SEPARATOR + varName, vil);

    assertVarEquals(VAR_FAM1, PRJ_MYPIP_CFG + IvmlKeyWords.NAMESPACE_SEPARATOR + VAR_FAM1 
        + IvmlKeyWords.NAMESPACE_SEPARATOR + "name", vil);
    
    assertVarEquals(VAR_FAM1, PRJ_MYPIP_CFG + IvmlKeyWords.NAMESPACE_SEPARATOR + varName
        + IvmlKeyWords.NAMESPACE_SEPARATOR + "name", vil);
    
    assertVarEquals(VAR_FAM1, PRJ_MYPIP_CFG + IvmlKeyWords.NAMESPACE_SEPARATOR + VAR_FAM1 
        + IvmlKeyWords.COMPOUND_ACCESS + "name", vil);

    assertVarEquals(VAR_FAM1, PRJ_MYPIP_CFG + IvmlKeyWords.NAMESPACE_SEPARATOR + varName 
        + IvmlKeyWords.COMPOUND_ACCESS + "name", vil);

    assertVarEquals(null, null, vil);
    assertVarEquals(null, PRJ_MYPIP_CFG + IvmlKeyWords.NAMESPACE_SEPARATOR + "?bla?" 
        + IvmlKeyWords.COMPOUND_ACCESS + "name", vil);
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:32,代码来源:PipelineHelperTest.java

示例5: assertVarEquals

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Asserts variable equality.
 * 
 * @param expectedVarName the name of the expected variable (may be <b>null</b>)
 * @param givenVarName the name of the actual variable (may be <b>null</b>)
 * @param vil use VIL or IVML way
 * @throws VilException in case that accessing the pipeline or a type fails
 */
private void assertVarEquals(String expectedVarName, String givenVarName, boolean vil) throws VilException {
    if (null != givenVarName && givenVarName.indexOf(IvmlKeyWords.NAMESPACE_SEPARATOR) < 0) {
        givenVarName = getVariableInstanceName(qmCfg, givenVarName);
    } 
    IDecisionVariable actualVar = null;
    if (vil) {
        DecisionVariable actual = PipelineElementHelper.obtainPipelineElement(qmCfg, givenVarName);
        if (null != actual) {
            actualVar = actual.getVariable();
        }
    } else {
        actualVar = PipelineElementHelper.findPipelineElement(qmCfg.getConfiguration(), givenVarName);
    }
    
    if (null == expectedVarName) {
        Assert.assertNull(actualVar);
    } else {
        IDecisionVariable expected = getDecision(qmCfg, expectedVarName);
        Assert.assertNotNull(actualVar);
        Assert.assertTrue(expected == actualVar);
    }
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:31,代码来源:PipelineHelperTest.java

示例6: testSetActual

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Tests setting the actual value.
 * 
 * @throws ConfigurationException shall not occur
 */
@Test
public void testSetActual() throws ConfigurationException {
    IDecisionVariable pip = PipelineHelper.obtainPipelineByName(qmCfg.getConfiguration(), VAR_PIP);
    Assert.assertNotNull(pip);
    IDecisionVariable family1 = PipelineHelper.obtainFamilyByName(pip, VAR_FAM1);
    Assert.assertNotNull(family1);
    IDecisionVariable actual = family1.getNestedElement(SLOT_ACTUAL);
    Assert.assertNotNull(actual);
    actual.setValue(NullValue.INSTANCE, AssignmentState.USER_ASSIGNED);
    Assert.assertEquals(NullValue.INSTANCE, actual.getValue());
    IDecisionVariable alg1 = PipelineHelper.obtainAlgorithmFromFamilyByName(family1, VAR_ALG1);
    Assert.assertNotNull(alg1);
    
    try {
        PipelineHelper.setActual(qmCfg.getConfiguration(), VAR_PIP, VAR_FAM1, VAR_ALG1);
    } catch (VilException e) {
        Assert.fail(e.getMessage());
    }
    Value val = actual.getValue();
    Assert.assertNotNull(val);
    Assert.assertNotEquals(NullValue.INSTANCE, val);
    Assert.assertTrue(val instanceof ReferenceValue);
    ReferenceValue refVal = (ReferenceValue) val;
    Assert.assertEquals(alg1.getDeclaration(), refVal.getValue());
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:31,代码来源:PipelineHelperTest.java

示例7: obtainPipelineElement

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Obtains a pipeline element.
 * 
 * @param config the configuration
 * @param variableName the name of the (element) variable
 * @return the element or <b>null</b> if it does not exist for some reason
 * @throws VilException in case of resolution problems
 */
public static DecisionVariable obtainPipelineElement(Configuration config, String variableName) 
    throws VilException {
    DecisionVariable result = null;
    DecisionVariable pip = null;
    if (null != variableName && null != config) {
        variableName = variableName.replace(String.valueOf(IvmlKeyWords.COMPOUND_ACCESS), 
            IvmlKeyWords.NAMESPACE_SEPARATOR); // compensate instanceName
        pip = PipelineHelper.obtainPipeline(config, variableName);
    }
    if (null != pip) {
        IDecisionVariable tmp = obtainPipelineElement(pip.getDecisionVariable(), variableName);
        if (null != tmp) { // top-level var
            // better: config.findVariable
            result = config.getByName(net.ssehub.easy.varModel.confModel.Configuration.getInstanceName(tmp));
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:27,代码来源:PipelineElementHelper.java

示例8: scanTypes

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Scans types in order to figure out whether they already have been registered.
 * 
 * @param annotation the annotation to scan
 * @return the types in the annotation
 */
private Class<?>[] scanTypes(QMGenerics annotation) {
    Class<?>[] result;
    if (null == annotation) {
        result = null;
    } else {
        result = annotation.types();
        if (null != result) {
            RtVilTypeRegistry registry = RtVilTypeRegistry.INSTANCE;
            for (int t = 0; t < result.length; t++) {
                Class<?> cls = result[t];
                if (IMPORTING.contains(cls) && !registry.hasType(getVilName(cls))) { // don't care for the others
                    try {
                        RtVilTypeRegistry.registerRtType(cls);
                    } catch (VilException e) {
                        // ignore if this fails
                    }
                }
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:29,代码来源:TypeAnalyzer.java

示例9: obtainPipeline

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Returns all pipelines mentioned in <code>clauses</code>.
 * 
 * @param configuration the configuration as basis for the lookup
 * @param clauses the clauses to look into
 * @return the pipelines (may be empty)
 * @throws VilException in case that accessing a pipeline fails
 */
@OperationMeta(returnGenerics = DecisionVariable.class)
public static Set<DecisionVariable> obtainPipeline(Configuration configuration, Iterator<?> clauses) 
    throws VilException {
    java.util.Set<String> done = new HashSet<String>();
    java.util.Set<DecisionVariable> result = new HashSet<DecisionVariable>();
    if (null != clauses) {
        while (clauses.hasNext()) {
            Object cl = clauses.next();
            if (cl instanceof ViolatingClause) {
                String variableName = ((ViolatingClause) cl).getVariable();
                if (!done.contains(variableName)) {
                    done.add(variableName);
                    DecisionVariable var = obtainPipeline(configuration, variableName);
                    if (null != var) {
                        result.add(var);
                    }
                }
            }
        }
    }
    return new SetSet<DecisionVariable>(result, DecisionVariable.class);
}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:31,代码来源:PipelineHelper.java

示例10: testDeleteMethods

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Test if methods can be deleted.
 * 
 * @throws IOException
 *             shall not occur
 */
@Test
public void testDeleteMethods() throws IOException {
    formatFile(mainWithNoMethods);
    copyFile(originalFile, tempFile);
    try {
        JavaFileArtifact javaFileArtefact = (JavaFileArtifact) CREATOR.createArtifactInstance(tempFile, null);
        Set<JavaClass> classes = javaFileArtefact.classes();
        for (JavaClass javaClass : classes) {
            Set<JavaMethod> methods = javaClass.methods();
            for (JavaMethod javaMethod : methods) {
                Assert.assertEquals(0, javaMethod.annotations().size());
                javaMethod.delete();
            }
        }
        javaFileArtefact.store();
        assertFileEqualitySafe(tempFile, mainWithNoMethods);
    } catch (VilException e) {
        logger.exception(e);
    }

}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:28,代码来源:JavaFileArtifactTest.java

示例11: create

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Creates a new XmlComment as child of given parent.
 * @param parent The parent of the new XmlComment.
 * @param contents optional initial contents, ignored if empty
 * @return The created XmlElement.
 * @throws VilException if element could not be created.
 */
public static XmlComment create(XmlElement parent, @ParameterMeta(name = "contents") String contents) 
    throws VilException {
    XmlComment newElement = null;
    if (null == parent) {
        throw new VilException("Can not append child from NULL element!", VilException.ID_IS_NULL);
    }
    try {
        Comment newNode = parent.getNode().getOwnerDocument().createComment(contents);
        parent.getNode().appendChild(newNode); // notifies change
        newElement = new XmlComment(parent, newNode);
        parent.addChild(newElement); // notifies change
    } catch (DOMException exc) {
        throw new VilException("Invalid character, name or ID!", VilException.ID_INVALID);
    }
    if (null != contents && contents.length() > 0) {
        newElement.setCdata(contents);
    }
    return newElement;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:27,代码来源:XmlComment.java

示例12: appendChild

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Appends a new child. Default position is after last child of the parent.
 * 
 * @param child The new child XmlElement.
 * @param childNode The new child Node.
 * @return The created XmlElement.
 * @throws VilException If child could not be appended.
 */
XmlElement appendChild(XmlElement child, Node childNode) throws VilException {
    if (null == child || null == childNode) {
        throw new VilException("NULL can not be added as a child of an XmlElement!", 
            VilException.ID_IS_NULL);
    }
    this.insertElement(child, this.nodes[this.nodes.length - 1]);
    try {
        getNode().appendChild(childNode);
    } catch (DOMException exc) {
        throw new VilException("Unable to append a child from a " + getNode().getNodeName() + " Node!", 
            VilException.ID_INVALID);
    }
    notifyChange();
    return child;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:XmlElement.java

示例13: ensureType

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
/**
 * Ensures a collection type for <code>type</code>.
 * @param type the type to be checked and ensured
 * @return the collection type
 * @throws VilException in case that <code>type</code> cannot be converted into a collection type
 */
@SuppressWarnings("unchecked")
protected static TypeDescriptor<? extends Collection<? extends IArtifact>> ensureType(
    TypeDescriptor<?> type) throws VilException {
    if (!type.isCollection()) {
        throw new VilException(type.getVilName() + "is not a collection", 
            VilException.ID_SEMANTIC);
    }
    if (type.getGenericParameterCount() != 1) {
        throw new VilException("collection in " + type.getVilName() + "is not generic over one type", 
            VilException.ID_SEMANTIC);
    }
    if (!ArtifactTypes.artifactType().isAssignableFrom(type.getGenericParameterType(0))) {
        throw new VilException("collection in " + type.getVilName() + "is not generic over one type", 
            VilException.ID_SEMANTIC);
    }
    TypeDescriptor<? extends Collection<? extends IArtifact>> result;
    try {
        result = (TypeDescriptor<? extends Collection<? extends IArtifact>>) type;
    } catch (ClassCastException e) { // just to be sure
        throw new VilException(e.getMessage(), VilException.ID_SEMANTIC);
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:30,代码来源:AbstractRuleMatchExpression.java

示例14: processProperties

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
@Override
protected void processProperties(
    net.ssehub.easy.instantiation.core.model.buildlangModel.Script script, File base) 
    throws VilException {
    callInitialize();
    callBindValues();
    if (!stopAfterBindValues) {
        super.processProperties(script, base);
        RtVilStorage storage = RtVilStorage.getInstance();
        if (null != storage) { // check whether this position is correct
            String scriptName = script.getName();
            for (int v = 0; v < script.getVariableDeclarationCount(); v++) {
                VariableDeclaration varDecl = script.getVariableDeclaration(v);
                if (varDecl.hasModifier(VariableDeclarationModifier.PERSISTENT)) {
                    Object value = storage.getValue(scriptName, varDecl.getName());
                    if (null != value) {
                        getRuntimeEnvironment().setValue(varDecl, value);
                        getTracer().valueDefined(varDecl, null, value);
                    }
                }
            }
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:25,代码来源:RtVilExecution.java

示例15: visitContainerInitializerExpression

import net.ssehub.easy.instantiation.core.model.common.VilException; //导入依赖的package包/类
@Override
public Object visitContainerInitializerExpression(ContainerInitializerExpression ex) throws VilException {
    if (!ex.isImplicit()) { // has then only one init expression
        print("{");
    }
    for (int e = 0; e < ex.getInitExpressionsCount(); e++) {
        if (e > 0) {
            print(", ");
        }
        ex.getInitExpression(e).accept(this);
    }
    if (!ex.isImplicit()) { 
        print("}");
    }
    return null;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:17,代码来源:ExpressionWriter.java


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