本文整理匯總了Java中net.ssehub.easy.instantiation.core.model.common.VilException.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java VilException.getId方法的具體用法?Java VilException.getId怎麽用?Java VilException.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.ssehub.easy.instantiation.core.model.common.VilException
的用法示例。
在下文中一共展示了VilException.getId方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: evaluateContentExpression
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Evaluates a content expression.
*
* @param iter the expression iterator
* @return the evaluation result
* @throws VilException if expression evaluation fails
*/
protected String evaluateContentExpression(IExpressionIterator iter) throws VilException {
String result = "";
for (int e = 0; e < iter.getExpressionsCount(); e++) {
Expression expression = iter.getExpression(e);
Object value;
try {
value = expression.accept(this);
} catch (VilException e1) {
if (e1.getId() == VilException.ID_NOT_FOUND) {
result = null;
break;
} else {
throw e1;
}
}
if (value != null) {
result += StringValueHelper.getStringValueInReplacement(value, null);
} else {
result = null;
break;
}
}
return result;
}
示例2: startUp
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Starts up the test by calling {@link #resourceInitialization()}.
*/
@BeforeClass
public static void startUp() {
resourceInitialization();
BuiltIn.initialize();
ExtensionClassLoaders.registerLoader(AbstractTest.class.getClassLoader());
try {
TypeRegistry.DEFAULT.registerType(StringArtifact.class);
} catch (VilException e) {
if (VilException.ID_ALREADY_REGISTERED != e.getId()) {
Assert.fail("unexpected exception: " + e.getMessage());
}
}
initializeInfrastructure();
initializeLocations(TESTDATA_DIR);
// TODO clean temp
}
示例3: substitute
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Substitutes the variable and expression placeholders in <code>text</code>.
*
* @param <I> the variable declaration type
* @param <R> the resolver type
* @param text
* the text to be analyzed
* @param resolver
* the resolver instance containing the variables
* @param expressionParser
* an instance for parsing strings into expression (may be <b>null</b> but then expression replacement
* will not work)
* @param expressionEvaluator
* the expression visitor for evaluating expressions (may be <b>null</b> but then expression replacement
* will not work)
* @param factory a factory turning in-place commands into language-specific expressions (may be <b>null</b>, then
* in-place commands are not resolved but remain as string expressions)
* @return the modified <code>text</code>
* @throws VilException
* in case that something goes wrong while resolving variables
*/
public static <I extends VariableDeclaration, R extends Resolver<I>> String substitute(String text,
R resolver, IExpressionParser<R> expressionParser, IExpressionVisitor expressionEvaluator,
IStringParserFactory<I> factory)
throws VilException {
String result;
if (null != text) {
try {
StringReplacer<I, R> replacer = new StringReplacer<I, R>(text, resolver, expressionParser,
expressionEvaluator, factory);
result = replacer.parse();
} catch (VilException e) {
if (VilException.ID_NULL_VALUE == e.getId()) {
result = null;
} else {
throw e;
}
}
} else {
result = null;
}
return result;
}
示例4: copy
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
@Override
public IVersionRestriction copy(IModel model) throws RestrictionEvaluationException {
try {
Map<VariableDeclaration, VariableDeclaration> mapping
= new HashMap<VariableDeclaration, VariableDeclaration>();
net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration decl =
new net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration(
"version", TypeRegistry.versionType());
mapping.put(getVersionVariable(), decl);
ExpressionCopyVisitor visitor = new ExpressionCopyVisitor(mapping, true);
Expression expr = (Expression) getExpression().accept(visitor);
return new ExpressionVersionRestriction(expr, decl);
} catch (VilException e) {
throw new RestrictionEvaluationException(e.getMessage(), e.getId());
}
}
示例5: copy
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
@Override
public IVersionRestriction copy(IModel model) throws RestrictionEvaluationException {
try {
Map<VariableDeclaration, VariableDeclaration> mapping
= new HashMap<VariableDeclaration, VariableDeclaration>();
net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration decl
= new net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration(
"version", TypeRegistry.versionType());
mapping.put(getVersionVariable(), decl);
ExpressionCopyVisitor visitor = new ExpressionCopyVisitor(mapping, true);
Expression expr = (Expression) getExpression().accept(visitor);
return new ExpressionVersionRestriction(expr, decl);
} catch (VilException e) {
throw new RestrictionEvaluationException(e.getMessage(), e.getId());
}
}
示例6: createExpressionVersionRestriction
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
@Override
protected ExpressionVersionRestriction createExpressionVersionRestriction(Expression expr,
net.ssehub.easy.instantiation.core.model.common.VariableDeclaration decl,
EObject cause, EStructuralFeature feature) throws RestrictionEvaluationException {
try {
ExpressionVersionRestrictionValidator validator = new ExpressionVersionRestrictionValidator(
new MessageHandler(this, cause, feature));
expr.accept(validator);
return new net.ssehub.easy.instantiation.core.model.buildlangModel.
ExpressionVersionRestriction(expr, decl);
} catch (VilException e) {
throw new RestrictionEvaluationException(e.getMessage(), e.getId());
}
}
示例7: evaluateContentExpression
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Evaluates <code>iter</code> as a content expression.
*
* @param iter the iterator
* @return the evaluation result
* @throws VilException if evaluation fails
*/
protected String evaluateContentExpression(IExpressionIterator iter) throws VilException {
String result = "";
Expression lastEx = null;
Object lastValue = null;
for (int e = 0; e < iter.getExpressionsCount(); e++) {
Expression expression = iter.getExpression(e);
Object value;
try {
value = expression.accept(this);
} catch (VilException e1) {
if (e1.getId() == VilException.ID_NOT_FOUND) {
result = null;
break;
} else {
throw e1;
}
}
if (value != null) {
result = appendInCompositeExpression(result, lastEx, lastValue,
StringValueHelper.getStringValueInReplacement(value, null), expression);
} else {
result = null;
break;
}
lastEx = expression;
lastValue = value;
}
return result;
}
示例8: ExpressionVersionRestriction
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Creates a new expression version restriction.
*
* @param expr the version restriction expression
* @param versionVariable the variable representing the actual version of the project to be imported
* @throws RestrictionEvaluationException in case of type compliance problems
*/
public ExpressionVersionRestriction(Expression expr, VariableDeclaration versionVariable)
throws RestrictionEvaluationException {
this.expr = expr;
this.versionVariable = versionVariable;
try {
TypeDescriptor<?> type = expr.inferType();
if (!TypeRegistry.booleanType().isAssignableFrom(type)) {
throw new RestrictionEvaluationException("restriction expression must be of type Boolean",
CSTSemanticException.TYPE_MISMATCH);
}
} catch (VilException e) {
throw new RestrictionEvaluationException(e.getMessage(), e.getId(), e);
}
}
示例9: substitute
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Substitutes a given text and returns a CompositeExpression.
*
* @param <I> the variable declaration type
* @param <R> the resolver type
* @param <E> the expression statement type
* @param text the text to be analyzed
* @param resolver the resolver to be used.
* @param translator the translator to be used.
* @param warnings an optional (may be <b>null</b> buffer to collect warnings
* @param factory a factory turning in-place commands into language-specific expressions (may be <b>null</b>, then
* in-place commands are not resolved but remain as string expressions)
*
* @throws VilException delegates the exception
*
* @return a {@link CompositeExpression}
*/
public static <I extends VariableDeclaration, R extends Resolver<I>,
E extends ExpressionStatement> Expression substitute(String text, R resolver,
IExpressionTranslator<I, R> translator, StringBuilder warnings, IStringParserFactory<I> factory)
throws VilException {
CompositeExpression result;
if (null != text) {
try {
StringResolver<I, R, E> replacer = new StringResolver<I, R, E>(text, resolver, translator,
warnings, factory);
if (text.contains("$")) {
result = replacer.parse();
} else {
List<Expression> list = replacer.handleConstant(text);
result = new CompositeExpression(list);
}
} catch (VilException e) {
if (VilException.ID_NULL_VALUE == e.getId()) {
result = null;
} else {
throw e;
}
}
} else {
result = null;
}
return result;
}
示例10: createSingleRestriction
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Creates a single restriction.
*
* @param parent the parent object (usually the script)
* @param operation the operation name to be executed
* @param version the version to be compared
* @return the restriction object
* @throws RestrictionEvaluationException in case of expression problems
*/
public static ExpressionVersionRestriction createSingleRestriction(Script parent, String operation,
Version version) throws RestrictionEvaluationException {
try {
TypeDescriptor<?> versionType = TypeRegistry.versionType();
VariableDeclaration var = new VariableDeclaration("version", versionType);
Expression verExpr = new ConstantExpression(versionType, version, TypeRegistry.DEFAULT);
Expression expr = new CallExpression(parent, operation, new VariableExpression(var), verExpr);
expr.inferType();
return new ExpressionVersionRestriction(expr, var);
} catch (VilException e) {
throw new RestrictionEvaluationException(e.getMessage(), e.getId());
}
}
示例11: registerTypeAnyway
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Registers the given type ignoring a previous registration.
*
* @param cls the type to be registered
*/
protected static void registerTypeAnyway(Class<? extends IVilType> cls) {
try {
TypeRegistry.DEFAULT.registerType(cls);
} catch (VilException e) {
if (VilException.ID_ALREADY_REGISTERED != e.getId()) {
Assert.fail("unexpected exception: " + e.getMessage());
}
}
}
示例12: dynamicCall
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Executes a dynamic rule call, i.e., a call that is composed and resolved at runtime.
*
* @param name the name of the rule to be called
* @param fallback an optional fallback instance in case that the call cannot be resolved
* @param args the rule arguments
* @return the rule execution result
* @throws VilException in case that constructing, resolving or executing the VIL rule fails
*/
private Object dynamicCall(String name, IDynamicCallFallback fallback, CallArgument... args) throws VilException {
Object result;
try {
result = dynamicCall(getCurrentScript(), name, args);
} catch (VilException e) {
if (null != fallback && VilException.ID_CANNOT_RESOLVE == e.getId()) {
result = fallback.call(this, args);
} else {
throw e;
}
}
return result;
}
示例13: createExpressionVersionRestriction
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
@Override
protected ExpressionVersionRestriction createExpressionVersionRestriction(Expression expr,
net.ssehub.easy.instantiation.core.model.common.VariableDeclaration decl,
EObject cause, EStructuralFeature feature)
throws RestrictionEvaluationException {
try {
ExpressionVersionRestrictionValidator validator = new ExpressionVersionRestrictionValidator(
new MessageHandler(this, cause, feature));
expr.accept(validator);
return new net.ssehub.easy.instantiation.core.model.templateModel.
ExpressionVersionRestriction(expr, decl);
} catch (VilException e) {
throw new RestrictionEvaluationException(e.getMessage(), e.getId());
}
}
示例14: continueResolution
import net.ssehub.easy.instantiation.core.model.common.VilException; //導入方法依賴的package包/類
/**
* Returns whether resolution shall be continued in case of multiple similar call expressions.
*
* @param semanticException the exception being thrown by the (partial) call resolution
* @return <code>true</code> if resolution shall be continued (there was an exception and it points to a resolution
* or a semantic problem), <code>false</code> else
*/
protected boolean continueResolution(VilException semanticException) {
return null != semanticException && (semanticException.getId() == VilException.ID_CANNOT_RESOLVE
|| semanticException.getId() == VilException.ID_SEMANTIC); // legacy
}