001 package railo.transformer.cfml.evaluator.impl; 002 003 import railo.transformer.bytecode.Statement; 004 import railo.transformer.bytecode.statement.tag.Tag; 005 import railo.transformer.bytecode.statement.tag.TagOutput; 006 import railo.transformer.cfml.evaluator.EvaluatorException; 007 import railo.transformer.cfml.evaluator.EvaluatorSupport; 008 import railo.transformer.library.tag.TagLibTag; 009 010 011 /** 012 * Pr�ft den Kontext des Tag output. 013 * Das Tag output darf nicht innerhalb eines output Tag verschachtelt sein, 014 * ausser das �ussere Tag besitzt ein group Attribute. Das innere Tag darf jedoch kein group Attribute besitzen. 015 016 */ 017 public final class Output extends EvaluatorSupport { 018 019 /** 020 * @see railo.transformer.cfml.evaluator.EvaluatorSupport#evaluate(org.w3c.dom.Element, railo.transformer.library.tag.TagLibTag) 021 */ 022 public void evaluate(Tag tag,TagLibTag libTag) throws EvaluatorException { 023 024 TagOutput output=(TagOutput) tag; 025 026 // check if inside a query tag 027 TagOutput parent = output; 028 boolean hasParentWithGroup=false; 029 boolean hasParentWithQuery=false; 030 boolean hasQuery=tag.containsAttribute("query"); 031 032 while((parent=getParentTagOutput(parent))!=null) { 033 if(!hasParentWithQuery)hasParentWithQuery=parent.hasQuery(); 034 if(!hasParentWithGroup)hasParentWithGroup=parent.hasGroup(); 035 if(hasParentWithQuery && hasParentWithGroup)break; 036 } 037 038 //� 039 040 if(hasQuery && hasParentWithQuery) 041 throw new EvaluatorException("Nesting of tags cfoutput with attribute query is not allowed"); 042 043 if(hasQuery) 044 output.setType(TagOutput.TYPE_QUERY); 045 //ASMUtil.replace(tag, new TagOutputQuery(tag)); 046 else if(tag.containsAttribute("group") && hasParentWithQuery) 047 output.setType(TagOutput.TYPE_GROUP); 048 //ASMUtil.replace(tag, new TagOutputGroup(tag)); 049 else if(hasParentWithQuery) { 050 if(hasParentWithGroup) output.setType(TagOutput.TYPE_INNER_GROUP); 051 else output.setType(TagOutput.TYPE_INNER_QUERY); 052 //ASMUtil.replace(tag, new TagOutputInner(tag,hasParentWithGroup)); 053 } 054 else 055 output.setType(TagOutput.TYPE_NORMAL); 056 //ASMUtil.replace(tag, new TagOutputNormal(tag)); 057 058 //if(hasParentWithQuery)tag.addAttribute(new Attribute("inner",LitBoolean.toExprBoolean(true, -1),"boolean")); 059 //if(hasParentWithGroup)tag.addAttribute(new Attribute("hasGroup",LitBoolean.toExprBoolean(true, -1),"boolean")); 060 061 } 062 063 public static TagOutput getParentTagOutput(TagOutput stat) { 064 Statement parent = stat; 065 066 067 while(true) { 068 parent=parent.getParent(); 069 if(parent==null)return null; 070 if(parent instanceof TagOutput) return (TagOutput) parent; 071 } 072 } 073 } 074 075 076 077