001 package railo.transformer.cfml.evaluator.impl; 002 003 import java.util.Iterator; 004 import java.util.List; 005 006 import railo.transformer.bytecode.Body; 007 import railo.transformer.bytecode.Statement; 008 import railo.transformer.bytecode.cast.CastString; 009 import railo.transformer.bytecode.expression.ExprString; 010 import railo.transformer.bytecode.literal.LitString; 011 import railo.transformer.bytecode.statement.PrintOut; 012 import railo.transformer.bytecode.statement.tag.Attribute; 013 import railo.transformer.bytecode.statement.tag.Tag; 014 import railo.transformer.bytecode.statement.tag.TagFunction; 015 import railo.transformer.bytecode.statement.tag.TagImport; 016 import railo.transformer.cfml.evaluator.EvaluatorException; 017 import railo.transformer.library.tag.TagLibTag; 018 019 public class Interface extends Component { 020 /** 021 * @see railo.transformer.cfml.evaluator.EvaluatorSupport#evaluate(org.w3c.dom.Element, railo.transformer.library.tag.TagLibTag) 022 */ 023 public void evaluate(Tag tag,TagLibTag libTag) throws EvaluatorException { 024 super.evaluate(tag,libTag); 025 Body body = tag.getBody(); 026 List statments = body.getStatements(); 027 Statement stat; 028 Iterator it = statments.iterator(); 029 Tag t; 030 while(it.hasNext()) { 031 stat=(Statement) it.next(); 032 033 if(stat instanceof PrintOut) { 034 //body.remove(stat); 035 } 036 else if(stat instanceof Tag) { 037 t=(Tag) stat; 038 if(stat instanceof TagImport) { 039 // ignore 040 } 041 else if(stat instanceof TagFunction) { 042 043 Function.throwIfNotEmpty(t); 044 Attribute attr = t.getAttribute("access"); 045 046 if(attr!=null) { 047 ExprString expr = CastString.toExprString(attr.getValue()); 048 049 if(!(expr instanceof LitString)) 050 throw new EvaluatorException( 051 "the attribute access of the Tag function inside an interface must contain a constant value"); 052 String access = ((LitString)expr).getString().trim(); 053 if(!"public".equalsIgnoreCase(access)) 054 throw new EvaluatorException( 055 "the attribute access of the tag function inside an interface definition can only have the value [public] not ["+access+"]"); 056 } 057 else t.addAttribute(new Attribute(false,"access",LitString.toExprString("public"),"string")); 058 059 } 060 else throw new EvaluatorException("tag "+libTag.getFullName()+" can only contain function definitions."); 061 } 062 } 063 064 065 } 066 067 }