Package sg.edu.nus.comp.simTL.engine.exceptions

Examples of sg.edu.nus.comp.simTL.engine.exceptions.ValidationException


  public TIfStatement(EObject tElement, IContext context, ITemplate template) throws SimTLException {
    super(tElement);
    condition = new TMethodStatement(methodStatementEO, context, template);
    if(!(condition.getReferenceFromParent()
        instanceof Reference2Attribute)){
      throw new ValidationException(condition.toString() + "is no reference to an attribute in the parameter model!");
    } else if(!(condition.getReferenceFromParent().getReferencedValue()
        instanceof Boolean)){
      throw new ValidationException(condition.toString() + "doesn't reference a boolean value in parameter model!");
    }
  }
View Full Code Here


 
  private final EObject tElement;
 
  public TElement(EObject tElement) throws SimTLException {
    this.tElement = tElement;
    if(tElement ==null) throw new ValidationException("The wrapped eObject cannot be empty");
    if(!isTElement(tElement)) throw new ValidationException("The wrapped eObject is not part of the XFrame language");
    load();
  }
View Full Code Here

   */
  public TForLoop(EObject tElement, IContext context, ITemplate template) throws SimTLException {
    super(tElement);
    setToBeIterated = new TMethodStatement(methodStatementEO, context, template);
    if(setToBeIterated.getReferenceFromParent() instanceof Reference2Attribute){
      throw new ValidationException("For-loop references an attribute and no list of elements! " + Util.getFullName(getTElement()));
    } else if(!((Reference2Element)setToBeIterated.getReferenceFromParent()).getReferenceToChildren().isMany()){
      throw new ValidationException("For-loop doesn't reference a list of elements! " + Util.getFullName(getTElement()));
    }
   
  }
View Full Code Here

 
  public TPlaceholder(EObject wrapped, IContext context, ITemplate template) throws SimTLException {
    super(wrapped);
    methodStatement = new TMethodStatement(methodStatementEO, context, template);
    if(methodStatement.getReferenceFromParent() instanceof Reference2Element){
      throw new ValidationException("Placeholder " + toString() + " references an element and no attribute!");
    }
//    if(pValue instanceof EObject||pValue instanceof List<?>){
//      throw new ValidationException("Placeholder " + phe.toString() + " references EObject or List!");
//    }
    //resolveVariable();
View Full Code Here

    }
    URI objectLanguageURI = null;
    try{
      objectLanguageURI = URI.createURI(olS);
    } catch (Exception e){
      throw new ValidationException(ANNOTATION_OBJECT_LANGUAGE + " must be an URI!");
    }

    EPackage oLPackage = (EPackage)EPackage.Registry.INSTANCE.get(objectLanguageURI.toString());
    if(oLPackage==null){
      throw new ValidationException("Object Language " + objectLanguageURI + " hasn't been registered at EPackage-registry!");
    }
    return oLPackage;
   
  }
View Full Code Here

    //FIXME use Eclipse class loader and remove dependency to object language
    Class<?> factoryClass=null;
    try {
      factoryClass = Class.forName(olS);
    } catch (ClassNotFoundException e) {
      throw new ValidationException("No such class found:"+ olS+". Please make this language available",e);
    }
    Object factoryO=null;
    try {
      factoryO = factoryClass.getConstructor().newInstance();
    } catch (Exception e){
View Full Code Here

  private void resolveEmbeddedMethodStatement(IContext context, ITemplate template) throws SimTLException{
    embeddedMethodStatement = new TMethodStatement(embeddedMethodStatementEO,context,template);
    //TODO since we have only negation no checks are needed
    ReferenceFromParent temp = embeddedMethodStatement.getReferenceFromParent();
    if(!(temp instanceof Reference2Attribute)){
      throw new ValidationException("Negation Operation only for referenced attributes!");
    }
    Reference2Attribute temp2 = (Reference2Attribute)temp;
    temp2.setNegateValue(!temp2.isNegateValue());
  }
View Full Code Here

  private void resolvePointer(IContext context, ITemplate template) throws SimTLException{
    //For printing purposes
    StringBuffer callSoFar = new StringBuffer();
    EObject firstCall = methodCalls.get(0);
    if(firstCall == null){
      throw new ValidationException("FirstCall in statement ("+caller+") is null!");
    }
    callSoFar.append(caller);
    callSoFar.append("."+loadAttribute(firstCall, REF_METHODNAME));
    //Check whether caller is a model
    IModel inputModel = template.getInputModel(caller);
    PlaceHolderReturnContainer firstCallPhrc = null;
    if(inputModel!=null){
      //load model
      if(!inputModel.getModelResource().isLoaded()){
        try {
          inputModel.getModelResource().load(Collections.EMPTY_MAP);
        } catch (IOException e) {
          throw new ValidationException("Cannot load InputModel",e);
        }
      }
      //first call needs to interpret model-resource
      firstCallPhrc = evaluatePlaceHolderModelCall(inputModel,firstCall);
    } else {
      //caller is variable
      Object variable = context.getVariableValue(caller);
      if(variable == null){
        throw new ValidationException("No such variable nor model with name: " + caller + " imported!");
      }
      //first call needs to interpret model-resource
      firstCallPhrc = evaluatePlaceHolderVariableCall(variable, firstCall,callSoFar.toString());
    }
   
View Full Code Here

   * @return
   */
  private PlaceHolderReturnContainer evaluatePlaceHolderVariableCall (
        Object o, EObject methodCall, String method) throws SimTLException{
    if(o == null){
      throw new ValidationException("Calling method on object with null value ("+method+")!");
    }
    if(!(o instanceof EObject)){
      throw new ValidationException("No such element in " + method + "(might also be a list of instead of one model element)");
    }
    //Type check
    if(!methodCall.eClass().getName().matches(CLASS_TMETHODCALL)){
      throw new InterpreterException("EObject is no methodCall, but "+methodCall.eClass().getName()+" (evaluatePlaceHolderVariableCall)!");
    }
   
    EObject eo = (EObject)o;
    //#methodCall.methodName
    String methodName = loadAttribute(methodCall, REF_METHODNAME);
   
    for(EStructuralFeature sf : eo.eClass().getEAllStructuralFeatures()){
      String sfName =sf.getName();
      sfName = sfName.substring(0,1).toLowerCase() + sfName.substring(1);
      if(sfName.matches(methodName))
        return new PlaceHolderReturnContainer(eo,sf,eo.eGet(sf));
    }
    throw new ValidationException("Couldn't find " + methodName + " in "+Util.getFullName(eo)+" (" + method+")");
  }
View Full Code Here

      //log.info("compare " + methodName + " with " + className);
      //className = className.substring(0,1).toLowerCase() + className.substring(1);
      if(className.matches(methodName))
        return new PlaceHolderReturnContainer(null,null,eo);
    }
    throw new ValidationException("Couldn't find \"" + methodName + "\" in model " + inputModel.getName());
   
  }
View Full Code Here

TOP

Related Classes of sg.edu.nus.comp.simTL.engine.exceptions.ValidationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.