001    package railo.transformer.cfml.attributes.impl;
002    
003    import railo.transformer.bytecode.cast.CastBoolean;
004    import railo.transformer.bytecode.expression.Expression;
005    import railo.transformer.bytecode.literal.LitBoolean;
006    import railo.transformer.bytecode.statement.tag.Attribute;
007    import railo.transformer.bytecode.statement.tag.Tag;
008    import railo.transformer.cfml.attributes.AttributeEvaluator;
009    import railo.transformer.cfml.attributes.AttributeEvaluatorException;
010    import railo.transformer.library.tag.TagLibTag;
011    
012    /**
013     * Attribute Evaluator for the tag Function
014     */
015    public final class Function implements AttributeEvaluator {
016    
017            /**
018             * @see railo.transformer.cfml.attributes.AttributeEvaluator#evaluate(railo.transformer.library.tag.TagLibTag, org.w3c.dom.Element)
019             */
020            public TagLibTag evaluate( TagLibTag tagLibTag, Tag tag) throws AttributeEvaluatorException {
021                    tagLibTag.setParseBody(false);
022                    
023                    Attribute attrOutput = tag.getAttribute("output");
024                    if(attrOutput==null) return tagLibTag;
025                    
026                    Expression expr = CastBoolean.toExprBoolean(attrOutput.getValue());
027                    
028                    if(!(expr instanceof LitBoolean))
029                            throw new AttributeEvaluatorException("Attribute output of the Tag Function, must be a literal boolean value (true or false)");
030                    boolean output = ((LitBoolean)expr).getBooleanValue();
031                    if(output)
032                            tagLibTag.setParseBody(true);
033                    
034                    return tagLibTag;
035            }
036    }