001 package railo.transformer.cfml.evaluator.impl; 002 003 import railo.transformer.bytecode.statement.tag.Tag; 004 import railo.transformer.bytecode.statement.tag.TagIf; 005 import railo.transformer.bytecode.util.ASMUtil; 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 /** 013 * 014 * Pr�ft den Kontext des Tag else. 015 * Das Tag <code>else</code> darf nur direkt innerhalb des Tag <code>if</code> liegen. 016 * Dem Tag <code>else</code> darf, innerhalb des Tag <code>if</code>, kein Tag <code>if</code> nachgestellt sein. 017 * Das Tag darf auch nur einmal vorkommen innerhalb des Tag if. 018 */ 019 public final class Else extends EvaluatorSupport { 020 021 /** 022 * @see railo.transformer.cfml.evaluator.EvaluatorSupport#evaluate(org.w3c.dom.Element, railo.transformer.library.tag.TagLibTag) 023 */ 024 public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException { 025 String ns=libTag.getTagLib().getNameSpaceAndSeparator(); 026 String ifName=ns+"if"; 027 028 // check if tag is direct inside if 029 if(!ASMUtil.isParentTag(tag, TagIf.class)) { 030 throw new EvaluatorException("Wrong Context, tag "+libTag.getFullName()+" must be direct inside a "+ifName+" tag"); 031 } 032 033 // check if is there a elseif tag after this tag 034 if(ASMUtil.hasSisterTagAfter(tag,"elseif")) 035 throw new EvaluatorException("Wrong Context, tag cfelseif can't be after tag else"); 036 // check if tag else is unique 037 if(ASMUtil.hasSisterTagWithSameName(tag)) 038 throw new EvaluatorException("Wrong Context, tag else must be once inside the tag if"); 039 040 } 041 042 }