Search in sources :

Example 11 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class Output method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag, FunctionLib[] flibs) throws EvaluatorException {
    TagOutput output = (TagOutput) tag;
    // check if inside a query tag
    TagOutput parent = output;
    // encodeFor
    Attribute encodeFor = tag.getAttribute("encodefor");
    if (encodeFor != null) {
        Expression encodeForValue = CastString.toExprString(encodeFor.getValue());
        if (encodeForValue instanceof Literal) {
            Literal l = (Literal) encodeForValue;
            short df = (short) -1;
            short encType = ESAPIEncode.toEncodeType(l.getString(), df);
            if (encType != df)
                encodeForValue = encodeForValue.getFactory().createLitInteger(encType);
        }
        addEncodeToChildren(tag.getBody().getStatements().iterator(), encodeForValue, getEncodeForFunction(flibs));
    }
    // query
    boolean hasParentWithGroup = false;
    boolean hasParentWithQuery = false;
    boolean hasQuery = tag.containsAttribute("query");
    while ((parent = getParentTagOutput(parent)) != null) {
        if (!hasParentWithQuery)
            hasParentWithQuery = parent.hasQuery();
        if (!hasParentWithGroup)
            hasParentWithGroup = parent.hasGroup();
        if (hasParentWithQuery && hasParentWithGroup)
            break;
    }
    if (hasQuery && hasParentWithQuery)
        throw new EvaluatorException("Nesting of tags cfoutput with attribute query is not allowed");
    if (hasQuery)
        output.setType(TagOutput.TYPE_QUERY);
    else if (tag.containsAttribute("group") && hasParentWithQuery)
        output.setType(TagOutput.TYPE_GROUP);
    else if (hasParentWithQuery) {
        if (hasParentWithGroup)
            output.setType(TagOutput.TYPE_INNER_GROUP);
        else
            output.setType(TagOutput.TYPE_INNER_QUERY);
    } else
        output.setType(TagOutput.TYPE_NORMAL);
    // attribute maxrows and endrow not allowd at the same time
    if (tag.containsAttribute("maxrows") && tag.containsAttribute("endrow"))
        throw new EvaluatorException("Wrong Context, you cannot use attribute maxrows and endrow at the same time.");
}
Also used : TagOutput(lucee.transformer.bytecode.statement.tag.TagOutput) Attribute(lucee.transformer.bytecode.statement.tag.Attribute) Expression(lucee.transformer.expression.Expression) EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) Literal(lucee.transformer.expression.literal.Literal)

Example 12 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class ProcParam method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    String ns = libTag.getTagLib().getNameSpaceAndSeparator();
    String name = ns + "storedproc";
    // check if tag is direct inside if
    if (!ASMUtil.hasAncestorTag(tag, name))
        throw new EvaluatorException("Wrong Context, tag " + libTag.getFullName() + " must be inside a " + name + " tag");
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException)

Example 13 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class ProcResult method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    String ns = libTag.getTagLib().getNameSpaceAndSeparator();
    String name = ns + "storedproc";
    // check if tag is direct inside if
    if (!ASMUtil.hasAncestorTag(tag, name))
        throw new EvaluatorException("Wrong Context, tag " + libTag.getFullName() + " must be inside a " + name + " tag");
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException)

Example 14 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class Property method getComponentName.

public static String getComponentName(Tag tag) throws EvaluatorException {
    Page page;
    try {
        page = ASMUtil.getAncestorPage(tag);
    } catch (TransformerException e) {
        throw new EvaluatorException(e.getMessage());
    }
    String ns = tag.getTagLibTag().getTagLib().getNameSpaceAndSeparator();
    String compName = ns + (page.getSourceCode().getDialect() == CFMLEngine.DIALECT_CFML ? Constants.CFML_COMPONENT_TAG_NAME : Constants.LUCEE_COMPONENT_TAG_NAME);
    return compName;
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) Page(lucee.transformer.bytecode.Page) TransformerException(lucee.transformer.TransformerException)

Example 15 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class QueryParam method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    String ns = libTag.getTagLib().getNameSpaceAndSeparator();
    String queryName = ns + "query";
    if (!ASMUtil.hasAncestorTag(tag, queryName))
        throw new EvaluatorException("Wrong Context, tag " + libTag.getFullName() + " must be inside a " + queryName + " tag");
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException)

Aggregations

EvaluatorException (lucee.transformer.cfml.evaluator.EvaluatorException)28 LitString (lucee.transformer.expression.literal.LitString)10 Attribute (lucee.transformer.bytecode.statement.tag.Attribute)9 Tag (lucee.transformer.bytecode.statement.tag.Tag)6 Body (lucee.transformer.bytecode.Body)5 Statement (lucee.transformer.bytecode.Statement)5 ExprString (lucee.transformer.expression.ExprString)5 Expression (lucee.transformer.expression.Expression)5 TagLibTag (lucee.transformer.library.tag.TagLibTag)5 TemplateException (lucee.runtime.exp.TemplateException)4 Page (lucee.transformer.bytecode.Page)4 TransformerException (lucee.transformer.TransformerException)3 StaticBody (lucee.transformer.bytecode.StaticBody)3 Literal (lucee.transformer.expression.literal.Literal)3 TagIf (lucee.transformer.bytecode.statement.tag.TagIf)2 TagLoop (lucee.transformer.bytecode.statement.tag.TagLoop)2 LitBoolean (lucee.transformer.expression.literal.LitBoolean)2 TagLib (lucee.transformer.library.tag.TagLib)2 SourceCode (lucee.transformer.util.SourceCode)2 Iterator (java.util.Iterator)1