Package railo.transformer.library.tag

Examples of railo.transformer.library.tag.TagLib


   */
  public void evaluate(Tag tag,TagLibTag libTag) throws EvaluatorException {
    if(tag.containsAttribute("query")) {
       
     
        TagLib lib = libTag.getTagLib();
        TagLibTag outputTag = lib.getTag("output");
       
        TagOutput output=new TagOutput(tag.getStart(),null);
        output.setFullname(outputTag.getFullName());
        output.setTagLibTag(outputTag);
        output.addAttribute(new Attribute(false,"output",LitBoolean.TRUE,"boolean"));
View Full Code Here


            }
        }
       
        try {
         
            TagLib taglib = TagLibFactory.loadFromFile(fileTagLib);
            taglib.setNameSpace(nameSpace);
            taglib.setNameSpaceSeperator(nameSpaceSeparator);
            return taglib;
        }
        catch (TagLibException e) {
         
            throw new TemplateException(cfml,e.getMessage());
View Full Code Here

        for(int i=0;i<tlds.length;i++) {
          key=getKey(tlds[i]);
          map.put(key,tlds[i]);
        }
     
        TagLib tl;
       
        // now overwrite with new data
        if(fileTld.isDirectory()) {
          Resource[] files=fileTld.listResources(new ExtensionResourceFilter("tld"));
            for(int i=0;i<files.length;i++) {
View Full Code Here

    protected void setTagDirectory(Resource tagDirectory) {
      this.tagDirectory=tagDirectory;
     
      this.tagMapping= new MappingImpl(this,"/mapping-tag/",tagDirectory.getAbsolutePath(),null,ConfigImpl.INSPECT_NEVER,true,true,true,true,false,true,null);
     
      TagLib tl=getCoreTagLib();
     
        // now overwrite with new data
        if(tagDirectory.isDirectory()) {
          String[] files=tagDirectory.list(new ExtensionResourceFilter(new String[]{"cfm","cfc"}));
            for(int i=0;i<files.length;i++) {
View Full Code Here

    return p;
  }
 

  public static TagLibTag getTLT(CFMLString cfml,String name) throws TemplateException {
    TagLib tl;
    try {
      // this is already loaded, oherwise we where not here
      tl = TagLibFactory.loadFromSystem();
      return tl.getTag(name);
    }
    catch (TagLibException e) {
      throw new TemplateException(cfml,e);
    }
  }
View Full Code Here

        body(data,page,false,null);
       
        if(data.cfml.isAfterLast()) break;
        if(data.cfml.forwardIfCurrent("</")){
          int pos = data.cfml.getPos();
          TagLib tagLib=nameSpace(data);
          if(tagLib==null){
            page.addPrintOut("</", null,null);
          }
          else {
            String name = identifier(data.cfml,true);
            if(tagLib.getIgnoreUnknowTags()) {
              TagLibTag tlt = tagLib.getTag(name);
              if(tlt==null) {
                data.cfml.setPos(pos);
                page.addPrintOut("</", null,null);
              }
            }
            else throw new TemplateException(cfml,"no matching start tag for end tag ["+tagLib.getNameSpaceAndSeparator()+name+"]");
     
          }
        }
        else
          throw new TemplateException(cfml,"Error while transforming CFML File");
View Full Code Here

    //int column=data.cfml.getColumn();
    int start=data.cfml.getPos();
    data.cfml.next();
   
    // read in namesapce of tag
    TagLib tagLib=nameSpace(data);
   
    // return if no matching tag lib
    if(tagLib==null)  {
      data.cfml.previous();
      return false;
    }
       
    // Get matching tag from tag lib
    String strNameNormal=identifier(data.cfml,false);
    if(strNameNormal==null) {
      data.cfml.setPos((data.cfml.getPos()-tagLib.getNameSpaceAndSeparator().length())-1);
      return false;
    }
   
    String strName=strNameNormal.toLowerCase();
    String appendix=null;
    TagLibTag tagLibTag=tagLib.getTag(strName);
   
    // get taglib
    if(tagLibTag==null)  {
      tagLibTag=tagLib.getAppendixTag(strName);
       if(tagLibTag==null) {
         if(tagLib.getIgnoreUnknowTags()){
           data.cfml.setPos(start);
           return false;
         }
         throw new TemplateException(data.cfml,"undefined tag ["+tagLib.getNameSpaceAndSeparator()+strName+"]");
       }
      appendix=StringUtil.removeStartingIgnoreCase(strNameNormal,tagLibTag.getName());
     }
   
    // CFXD Element
    Tag tag;
    try {
      tag = tagLibTag.getTag(line,data.cfml.getPosition());
    }
    catch (Exception e) {
      throw new TemplateException(data.cfml,e);
    }
    parent.addStatement(tag);
   
    // get tag from tag library
     if(appendix!=null)  {
      tag.setAppendix(appendix);
      tag.setFullname(tagLibTag.getFullName().concat(appendix));
     }
     else {
       tag.setFullname(tagLibTag.getFullName());    
     }
     if(tag.getFullname().equalsIgnoreCase("cfcomponent"))data.page.setIsComponent(true)// MUST to hardcoded, to better
     else if(tag.getFullname().equalsIgnoreCase("cfinterface"))data.page.setIsInterface(true)// MUST to hardcoded, to better
      
    tag.setTagLibTag(tagLibTag);
    comment(data.cfml,true);
   
    // Tag Translator Evaluator
    if(tagLibTag.hasTteClass())  {
      data.ep.add(tagLibTag,tag,data.flibs,data.cfml);
    }
   
    //get Attributes
    attributes(data,tagLibTag,tag);
   
    if(tagLibTag.hasAttributeEvaluator()) {
      try {
        tagLibTag=tagLibTag.getAttributeEvaluator().evaluate(tagLibTag,tag);
      } catch (AttributeEvaluatorException e) {
       
        throw new TemplateException(data.cfml, e);
      }
    }
   
   
   
    // End of begin Tag
//    TODO muss erlaubt sein
    if(data.cfml.forwardIfCurrent('>'))  {
      hasBody=tagLibTag.getHasBody();
    }
    else if(data.cfml.forwardIfCurrent('/','>')) {
      if(tagLibTag.getHasBody())tag.setBody(new BodyBase());
    }
    else {
      throw createTemplateException(data.cfml, "tag ["+tagLibTag.getFullName()+"] is not closed",tagLibTag);
    }
   

    // Body
    if(hasBody)  {

       
      // get Body
      if(tagLibTag.isTagDependent()) {
        // get TagDependentBodyTransformer
        TagDependentBodyTransformer tdbt=null;
        try {
          tdbt=tagLibTag.getBodyTransformer();
        } catch (TagLibException e) {
          throw new TemplateException(data.cfml,e);
        }
        if(tdbt==null) throw createTemplateException(data.cfml,"Tag dependent body Transformer is invalid for Tag ["+tagLibTag.getFullName()+"]",tagLibTag);
        tdbt.transform(data.page,this,data.ep,data.flibs,tag,tagLibTag,data.scriptTags,data.cfml,data.settings);
       
        //  get TagLib of end Tag
        if(!data.cfml.forwardIfCurrent("</")) {
          // MUST this is a patch, do a more proper implementation
          TemplateException te = new TemplateException(data.cfml,"invalid construct");
          if(tdbt instanceof CFMLScriptTransformer && ASMUtil.containsComponent(tag.getBody())) {
            throw new CFMLScriptTransformer.ComponentTemplateException(te);
          }
          throw te;
        }
       
        TagLib tagLibEnd=nameSpace(data);
        // same NameSpace
        if(!(tagLibEnd!=null && tagLibEnd.getNameSpaceAndSeparator().equals(tagLib.getNameSpaceAndSeparator())))
          throw new TemplateException(data.cfml,"invalid construct");
        // get end Tag
        String strNameEnd=identifier(data.cfml,true).toLowerCase();

        // not the same name Tag
        if(!strName.equals(strNameEnd)) {
          data.cfml.setPos(start);
          throw new TemplateException(data.cfml,"Start and End Tag has not the same Name ["+tagLib.getNameSpaceAndSeparator()+strName+"-"+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"]");       
         }
         data.cfml.removeSpace();
         if(!data.cfml.forwardIfCurrent('>'))
           throw new TemplateException(data.cfml,"End Tag ["+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"] not closed");
      }
      else {
        // get body of Tag
        BodyBase body=new BodyBase();
        body.setParent(tag);
        //tag.setBody(body);
          //parseExpression=(tagLibTag.getParseBody())?true:parseExpression;
        if(tagLibTag.getParseBody())parseExpression=true;
       
        while(true)  {
         
          // Load Expession Transformer from TagLib
          ExprTransformer transfomer=null;
          if(parseExpression) {
            try {
              transfomer = tagLibTag.getTagLib().getExprTransfomer();
            } catch (TagLibException e) {
              throw new TemplateException(data.cfml,e);
            }
          }
         

          // call body
         
            body(data,body,parseExpression,transfomer);
          
           
            // no End Tag
          if(data.cfml.isAfterLast()) {
             
            if(tagLibTag.isBodyReq()) {
                data.cfml.setPos(start);
              throw createTemplateException(data.cfml,"No matching end tag found for tag ["+tagLibTag.getFullName()+"]",tagLibTag);
            }
            body.moveStatmentsTo(parent);
            return executeEvaluator(data,tagLibTag, tag);
          }
         
          // Invalid Construct
          int posBeforeEndTag=data.cfml.getPos();
          if(!data.cfml.forwardIfCurrent('<','/'))
            throw createTemplateException(data.cfml,"Missing end tag for ["+tagLibTag.getFullName()+"]",tagLibTag);
         
          // get TagLib of end Tag
          int _start = data.cfml.getPos();
          TagLib tagLibEnd=nameSpace(data);
         
          // same NameSpace
          if(tagLibEnd!=null)  {
              String strNameEnd="";
              //railo.print.ln(data.cfml.getLine()+" - "+data.cfml.getColumn()+" - "+tagLibEnd.getNameSpaceAndSeperator()+".equals("+tagLib.getNameSpaceAndSeperator()+")");
              if(tagLibEnd.getNameSpaceAndSeparator().equals(tagLib.getNameSpaceAndSeparator())) {
                 
                // get end Tag
              strNameEnd=identifier(data.cfml,true).toLowerCase();
              // not the same name Tag
             
              // new part
              data.cfml.removeSpace();
              if(strName.equals(strNameEnd)) {
                  if(!data.cfml.forwardIfCurrent('>'))
                  throw new TemplateException(data.cfml,"End Tag ["+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"] not closed");
                break;
              }
             
              }
              // new part
              if(tagLibTag.isBodyReq()) {
              TagLibTag endTag = tagLibEnd.getTag(strNameEnd);
              if(endTag!=null && !endTag.getHasBody())
                throw new TemplateException(data.cfml,
                    "End Tag ["+
                    tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"] is not allowed, for this tag only a Start Tag is allowed");
              data.cfml.setPos(start);
              if(tagLibEnd.getIgnoreUnknowTags() && (tagLibEnd.getTag(strNameEnd))==null){
                data.cfml.setPos(_start);
              }
              else throw new TemplateException(data.cfml,
                  "Start and End Tag has not the same Name ["+
                  tagLib.getNameSpaceAndSeparator()+strName+"-"+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"]");
            }
              else {
              body.moveStatmentsTo(parent);
              data.cfml.setPos(posBeforeEndTag);
              return executeEvaluator(data,tagLibTag, tag);
View Full Code Here

  }
 
  private boolean executeEvaluator(TagData data,TagLibTag tagLibTag, Tag tag) throws TemplateException {
    if(tagLibTag.hasTteClass())  {
      try {
        TagLib lib=tagLibTag.getEvaluator().execute(data.config,tag,tagLibTag,data.flibs,data);
        if(lib!=null) {
          // set
          for(int i=0;i<data.tlibs[TAG_LIB_PAGE].length;i++) {
                    if(data.tlibs[TAG_LIB_PAGE][i].getNameSpaceAndSeparator().equalsIgnoreCase(lib.getNameSpaceAndSeparator())){
                      boolean extIsCustom=data.tlibs[TAG_LIB_PAGE][i] instanceof CustomTagLib;
                      boolean newIsCustom=lib instanceof CustomTagLib;
                      // TagLib + CustomTagLib (visa/versa)
                      if(extIsCustom){
                        ((CustomTagLib)data.tlibs[TAG_LIB_PAGE][i]).append(lib);
View Full Code Here

   * @return TagLib Passende Tag Lirary oder null.
   */
  private TagLib nameSpace(TagData data) {
    boolean hasTag=false;
    int start = data.cfml.getPos();
    TagLib tagLib=null;
   
    // loop over NameSpaces
    for(int i=1;i>=0;i--)  {
      for(int ii=0;ii<data.tlibs[i].length;ii++)  {
        tagLib= data.tlibs[i][ii];
        char[] c=tagLib.getNameSpaceAndSeperatorAsCharArray();
        // Loop over char of NameSpace and Sepearator
        hasTag=true;
        for(int y=0;y<c.length;y++)  {
          if(!(data.cfml.isValidIndex() && c[y]==data.cfml.getCurrentLower())) {
            //hasTag=true;
View Full Code Here

    // condition loop
    if(tag.containsAttribute("condition")){
      if(tag.isScriptBase())
        throw new EvaluatorException("tag loop-condition is not supported within cfscript, use instead a while statement.");
     
      TagLib tagLib=tagLibTag.getTagLib();
      ExprTransformer transformer;
      String text=ASMUtil.getAttributeString(tag, "condition");

      try {
        ConfigImpl config=(ConfigImpl) ThreadLocalPageContext.getConfig();
        transformer = tagLib.getExprTransfomer();
        Expression expr=transformer.transform(ASMUtil.getAncestorPage(tag),null,flibs,config.getCoreTagLib().getScriptTags(),new CFMLString(text,"UTF-8"),TransfomerSettings.toSetting(ThreadLocalPageContext.getConfig(),null));
        tag.addAttribute(new Attribute(false,"condition",CastBoolean.toExprBoolean(expr),"boolean"));
      }
      catch (Exception e) {
        throw new EvaluatorException(e.getMessage());
View Full Code Here

TOP

Related Classes of railo.transformer.library.tag.TagLib

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.