Package railo.runtime.exp

Examples of railo.runtime.exp.TemplateException


    comments(data);
    Expression expr = super.expression(data);
    comments(data);
    // end )
    if(!data.cfml.forwardIfCurrent(')'))
      throw new TemplateException(data.cfml,"switch statement must end with a [)]");
    comments(data);

    if(!data.cfml.forwardIfCurrent('{'))
      throw new TemplateException(data.cfml,"switch statement must have a starting  [{]");

    Switch swit=new Switch(expr,line,null);
   
    //  cases
     //Node child=null;
     comments(data);
     while(caseStatement(data,swit)) {
       comments(data);
     }
     // default
      if(defaultStatement(data,swit)) {
      comments(data);
      }
     
      while(caseStatement(data,swit)) {
         comments(data);
       }
     
     
    // }
    if(!data.cfml.forwardIfCurrent('}'))
      throw new TemplateException(data.cfml,"invalid construct in switch statement");
    swit.setEnd(data.cfml.getPosition());
    return swit;
  }
View Full Code Here


    comments(data);
    Expression expr = super.expression(data);
    comments(data);
   
    if(!data.cfml.forwardIfCurrent(':'))
      throw new TemplateException(data.cfml,"case body must start with [:]");
   
    Body body=new BodyBase();
    switchBlock(data,body);
    swit.addCase(expr, body);
    return true;
View Full Code Here

    statement(data,body,CTX_DO_WHILE);
   
   
    comments(data);
    if(!data.cfml.forwardIfCurrent("while",'('))
      throw new TemplateException(data.cfml,"do statement must have a while at the end");
   
    DoWhile doWhile=new DoWhile(condition(data),body,line,data.cfml.getPosition(),id);
   
    if(!data.cfml.forwardIfCurrent(')'))
      throw new TemplateException(data.cfml,"do statement must end with a [)]");
   
   
    return doWhile;
  }
View Full Code Here

            cont=condition(data);
            comments(data);
          }
        // middle
        if(!data.cfml.forwardIfCurrent(';'))
          throw new TemplateException(data.cfml,"invalid syntax in for statement");
        // update
          comments(data);
          if(!data.cfml.isCurrent(')')) {
            update=expression(data);
            comments(data);
          }
        // start )
        if(!data.cfml.forwardIfCurrent(')'))
          throw new TemplateException(data.cfml,"invalid syntax in for statement, for statement must end with a [)]");
        // ex block
        statement(data,body,CTX_FOR);
   
        return new For(left,cont,update,body,line,data.cfml.getPosition(),id);         
      }
    // middle foreach
      else if(data.cfml.forwardIfCurrent("in")) {
        // condition
          comments(data);
          Expression value = expression(data);
          comments(data);
        if(!data.cfml.forwardIfCurrent(')'))
          throw new TemplateException(data.cfml,"invalid syntax in for statement, for statement must end with a [)]");
       
        // ex block
        statement(data,body,CTX_FOR);
        if(!(left instanceof Variable))
          throw new TemplateException(data.cfml,"invalid syntax in for statement, left value is invalid");
       
        if(!(value instanceof Variable))
          throw new TemplateException(data.cfml,"invalid syntax in for statement, right value is invalid");
        return new ForEach((Variable)left,(Variable)value,body,line,data.cfml.getPosition(),id)
      }
      else
        throw new TemplateException(data.cfml,"invalid syntax in for statement");
  }
View Full Code Here

    // check access returntype
    int access=Component.ACCESS_PUBLIC;
    if(strAccess!=null && rtnType!=null){
      access = ComponentUtil.toIntAccess(strAccess,-1);
      if(access==-1)
        throw new TemplateException(data.cfml,"invalid access type ["+strAccess+"], access types are remote, public, package, private");
    }
    if(strAccess!=null && rtnType==null){
      access = ComponentUtil.toIntAccess(strAccess,-1);
      if(access==-1){
        rtnType=strAccess;
        strAccess=null;
        access=Component.ACCESS_PUBLIC;
      }
    }
   
   
   
    Position line = data.cfml.getPosition();
   
    comments(data);
   
    // Name
      String id=identifier(data,false);
     
     
      if(id==null) {
        if(data.cfml.isCurrent('(')) {
          data.cfml.setPos(pos);
          return null;
        }
        throw new TemplateException(data.cfml,"invalid name for a function");
      }
     
      if(!data.isCFC && !data.isInterface){
        FunctionLibFunction flf = getFLF(data,id);
        if(flf!=null && flf.getClazz()!=CFFunction.class)throw new TemplateException(data.cfml,"The name ["+id+"] is already used by a built in Function");
      }
      return closurePart(data, id,access,rtnType,line,false);
  }
View Full Code Here

        new Closure(data.page,id,access,rtnType,body,line,null)
        :new FunctionImpl(data.page,id,access,rtnType,body,line,null);
   
      comments(data);
      if(!data.cfml.forwardIfCurrent('('))
        throw new TemplateException(data.cfml,"invalid syntax in function head, missing begin [(]");
   
      // arguments
      LitBoolean passByRef;
      Expression displayName;
      Expression hint;
      Map<String,Attribute> meta;
      String _name;
      do  {
        comments(data);
        // finish
        if(data.cfml.isCurrent(')'))break;
       
        // attribute
       
        // name
        //String idName=identifier(data,false,true);
        boolean required=false;
       
        String idName = variableDec(data, false);
        // required
        if("required".equalsIgnoreCase(idName)){
          comments(data);
          String idName2=variableDec(data, false);
          if(idName2!=null){
            idName=idName2;
            required=true;
          }
        }
       
       
        String typeName="any";
        if(idName==null) throw new TemplateException(data.cfml,"invalid argument definition");
        comments(data);
        if(!data.cfml.isCurrent(')') && !data.cfml.isCurrent('=') && !data.cfml.isCurrent(':') && !data.cfml.isCurrent(',')) {
          typeName=idName.toLowerCase();
          idName=identifier(data,false); // MUST was upper case before, is this a problem?
        }
        else if(idName.indexOf('.')!=-1 || idName.indexOf('[')!=-1) {
          throw new TemplateException(data.cfml,"invalid argument name ["+idName+"] definition");
        }
       
        comments(data);
        Expression defaultValue;
        if(data.cfml.isCurrent('=') || data.cfml.isCurrent(':')) {
          data.cfml.next();
          comments(data);
          defaultValue=expression(data);
        }
        else defaultValue=null;
       
        // assign meta data defined in doc comment
        passByRef = LitBoolean.TRUE;
        displayName=LitString.EMPTY;
        hint=LitString.EMPTY;
        meta=null;
        if(data.docComment!=null){
          Map<String, Attribute> params = data.docComment.getParams();
          Attribute[] attrs = params.values().toArray(new Attribute[params.size()]);
          Attribute attr;
          String name;
         
          for(int i=0;i<attrs.length;i++){
            attr=attrs[i];
            name=attr.getName();
            // hint
            if(idName.equalsIgnoreCase(name) || name.equalsIgnoreCase(idName+".hint")) {
              hint=CastString.toExprString(attr.getValue());
              params.remove(name);
            }
            //meta
            if(StringUtil.startsWithIgnoreCase(name, idName+".")) {
              if(name.length()>idName.length()+1){
                if(meta==null) meta=new HashMap<String, Attribute>();
                _name=name.substring(idName.length()+1);
                meta.put(_name, new Attribute(attr.isDynamicType(), _name,attr.getValue(), attr.getType()));
              }
              params.remove(name);
            }
          }
         
        }
       
        // argument attributes
        Attribute[] _attrs = attributes(null,null,data,COMMA_ENDBRACKED,LitString.EMPTY,Boolean.TRUE,null,false);
        Attribute _attr;
        if(!ArrayUtil.isEmpty(_attrs)){
          if(meta==null) meta=new HashMap<String, Attribute>();
          for(int i=0;i<_attrs.length;i++){
            _attr=_attrs[i];
            meta.put(_attr.getName(), _attr);
          }
        }
       
        func.addArgument(
            LitString.toExprString(idName),
            LitString.toExprString(typeName),
            LitBoolean.toExprBoolean(required),
            defaultValue,passByRef,displayName,hint,meta);
       
        comments(data);
      }
      while(data.cfml.forwardIfCurrent(','));

   
    // end )
      comments(data);
      if(!data.cfml.forwardIfCurrent(')'))
        throw new TemplateException(data.cfml,"invalid syntax in function head, missing ending [)]");
   
    //TagLibTag tlt = CFMLTransformer.getTLT(data.cfml,"function");
   
    // doc comment
    if(data.docComment!=null){
View Full Code Here

   
    if(!hasType)
      property.addAttribute(ANY);
   
    if(!hasName)
      throw new TemplateException(data.cfml,"missing name declaration for property");

    /*Tag property=new TagBase(line);
    property.setTagLibTag(tlt);
    property.addAttribute(new Attribute(false,"name",LitString.toExprString(name),"string"));
    property.addAttribute(new Attribute(false,"type",LitString.toExprString(type),"string"));
View Full Code Here

   
    //if(!hasType)
    //  param.addAttribute(ANY);
   
    if(!hasName)
      throw new TemplateException(data.cfml,"missing name declaration for param");

    param.setEnd(data.cfml.getPosition());
    return param;
  }
View Full Code Here


  private TemplateException attrNotSupported(CFMLString cfml, TagLibTag tag, String id) {
    String names=tag.getAttributeNames();
    if(StringUtil.isEmpty(names))
      return new TemplateException(cfml,"Attribute "+id+" is not allowed for tag "+tag.getFullName());
   
    return new TemplateException(cfml,
      "Attribute "+id+" is not allowed for statement "+tag.getName(),
      "valid attribute names are ["+names+"]");
  }
View Full Code Here

  private final void eval(TagLibTag tlt, railo.transformer.cfml.expression.CFMLExprTransformer.ExprData data, Tag tag) throws TemplateException {
    if(!StringUtil.isEmpty(tlt.getTteClassName())){
      try {
        tlt.getEvaluator().execute(data.config, tag, tlt,data.flibs, data);
      } catch (EvaluatorException e) {
        throw new TemplateException(e.getMessage());
      }
      data.ep.add(tlt, tag, data.flibs, data.cfml);
    }
  }
View Full Code Here

TOP

Related Classes of railo.runtime.exp.TemplateException

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.