use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.
the class ReThrow method evaluate.
@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
String ns = libTag.getTagLib().getNameSpaceAndSeparator();
String queryName = ns + "catch";
if (!ASMUtil.hasAncestorTryStatement(tag)) {
if (tag.isScriptBase())
throw new EvaluatorException("Wrong Context, statement " + libTag.getName() + " must be inside a " + queryName + " tag or catch statement");
throw new EvaluatorException("Wrong Context, tag " + libTag.getFullName() + " must be inside a " + queryName + " tag");
}
// ASMUtil.replace(tag,new TagReThrow(tag));
}
use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.
the class Retry method evaluate.
@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
String ns = libTag.getTagLib().getNameSpaceAndSeparator();
String name = ns + "catch";
if (getAncestorCatch(libTag.getTagLib(), tag) == null)
throw new EvaluatorException("Wrong Context, tag " + libTag.getFullName() + " must be inside a " + name + " tag");
}
use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.
the class TreeItem method evaluate.
/**
* @see lucee.transformer.cfml.evaluator.EvaluatorSupport#evaluate(org.w3c.dom.Element, lucee.transformer.library.tag.TagLibTag)
*/
@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
String ns = libTag.getTagLib().getNameSpaceAndSeparator();
String name = ns + "tree";
// 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");
}
use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.
the class Function method addAttribute.
public final void addAttribute(Attribute attr) throws TemplateException {
String name = attr.getName().toLowerCase();
// name
if ("name".equals(name)) {
throw new TransformerException("name cannot be defined twice", getStart());
} else if ("returntype".equals(name)) {
this.returnType = toLitString(name, attr.getValue());
} else if ("access".equals(name)) {
LitString ls = toLitString(name, attr.getValue());
String strAccess = ls.getString();
int acc = ComponentUtil.toIntAccess(strAccess, -1);
if (acc == -1)
throw new TransformerException("invalid access type [" + strAccess + "], access types are remote, public, package, private", getStart());
access = acc;
} else if ("output".equals(name))
this.output = toLitBoolean(name, attr.getValue());
else if ("bufferoutput".equals(name))
this.bufferOutput = toLitBoolean(name, attr.getValue());
else if ("displayname".equals(name))
this.displayName = toLitString(name, attr.getValue());
else if ("hint".equals(name))
this.hint = toLitString(name, attr.getValue());
else if ("description".equals(name))
this.description = toLitString(name, attr.getValue());
else if ("returnformat".equals(name))
this.returnFormat = toLitString(name, attr.getValue());
else if ("securejson".equals(name))
this.secureJson = toLitBoolean(name, attr.getValue());
else if ("verifyclient".equals(name))
this.verifyClient = toLitBoolean(name, attr.getValue());
else if ("localmode".equals(name)) {
Expression v = attr.getValue();
if (v != null) {
String str = ASMUtil.toString(v, null);
if (!StringUtil.isEmpty(str)) {
int mode = AppListenerUtil.toLocalMode(str, -1);
if (mode != -1)
this.localMode = v.getFactory().createLitInteger(mode);
else
throw new TransformerException("Attribute localMode of the Tag Function, must be a literal value (modern, classic, true or false)", getStart());
}
}
} else if ("cachedwithin".equals(name)) {
try {
// ASMUtil.timeSpanToLong(attr.getValue());
this.cachedWithin = ASMUtil.cachedWithinValue(attr.getValue());
} catch (EvaluatorException e) {
throw new TemplateException(e.getMessage());
}
} else if ("modifier".equals(name)) {
Expression val = attr.getValue();
if (val instanceof Literal) {
Literal l = (Literal) val;
String str = StringUtil.emptyIfNull(l.getString()).trim();
if ("abstract".equalsIgnoreCase(str))
modifier = Component.MODIFIER_ABSTRACT;
else if ("final".equalsIgnoreCase(str))
modifier = Component.MODIFIER_FINAL;
}
} else {
// needed for testing
toLitString(name, attr.getValue());
if (metadata == null)
metadata = new HashMap<String, Attribute>();
metadata.put(attr.getName(), attr);
}
}
use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.
the class CFMLTransformer method executeEvaluator.
private boolean executeEvaluator(TagData data, TagLibTag tagLibTag, Tag tag) throws TemplateException {
if (tagLibTag.hasTTE()) {
try {
TagLib lib = tagLibTag.getEvaluator().execute(data.config, tag, tagLibTag, data.flibs, data);
if (lib != null) {
// set
for (int i = 0; i < data.tlibs[TAG_LIB_PAGE].length; i++) {
if (data.tlibs[TAG_LIB_PAGE][i].getNameSpaceAndSeparator().equalsIgnoreCase(lib.getNameSpaceAndSeparator())) {
boolean extIsCustom = data.tlibs[TAG_LIB_PAGE][i] instanceof CustomTagLib;
boolean newIsCustom = lib instanceof CustomTagLib;
// TagLib + CustomTagLib (visa/versa)
if (extIsCustom) {
((CustomTagLib) data.tlibs[TAG_LIB_PAGE][i]).append(lib);
return true;
} else if (newIsCustom) {
((CustomTagLib) lib).append(data.tlibs[TAG_LIB_PAGE][i]);
data.tlibs[TAG_LIB_PAGE][i] = lib;
return true;
}
}
}
// TODO make sure longer namespace ar checked firts to support subsets, same for core libs
// insert
TagLib[] newTlibs = new TagLib[data.tlibs[TAG_LIB_PAGE].length + 1];
for (int i = 0; i < data.tlibs[TAG_LIB_PAGE].length; i++) {
newTlibs[i] = data.tlibs[TAG_LIB_PAGE][i];
}
newTlibs[data.tlibs[TAG_LIB_PAGE].length] = lib;
data.tlibs[TAG_LIB_PAGE] = newTlibs;
}
} catch (EvaluatorException e) {
throw new TemplateException(data.srcCode, e);
}
}
return true;
}
Aggregations