
js.template.xhtml.ExcludeOperator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of js-xhtml-template Show documentation
Show all versions of js-xhtml-template Show documentation
Reference implementation for j(s)-lib template API, declarative, natural and based on X(HT)ML language.
The newest version!
package js.template.xhtml;
import js.dom.Element;
/**
* Exclude element and its descendants from resulting document. What exclusion means is implementation dependent: one may choose
* to hide somehow - maybe display:none, another to simple remove the branch completely from resulting document. The point is,
* the marked branch must not be visible to end user. This operator is not so much a conditional one since test is performed on
* a boolean literal rather than some content value. Branch exclusion is actually decided on development phase. A good usage
* example may be email template: head meta is used for email initialization but not included into delivery.
*
*
* <head data-exclude="true">
* <meta name="from" content="[email protected]" />
* <meta name="subject" content="subject" />
* </head>
*
*
* Operand is a boolean literal. Nothing special: true or false.
*
* @author Iulian Rotaru
*/
public class ExcludeOperator extends Operator
{
/**
* Execute EXCLUDE operator. Returns branch enabled flag, that is, true to indicate branch is to be included in resulting
* document. Since exclude operator has opposite logic we need to negate given boolean expression; so, if operand is 'true'
* meaning the branch should be excluded this method returns false.
*
* @param element context element, unused,
* @param scope scope object, unused,
* @param booleanExpression boolean expression, 'true' or 'false',
* @param arguments optional arguments, not used.
* @return branch enabled flag.
*/
@Override
protected Object doExec(Element element, Object scope, String booleanExpression, Object... arguments)
{
// returned value is interpreted as branch enabled
// boolean expression argument is true if branch should be excluded, so we need to inverse it
return !Boolean.valueOf(booleanExpression);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy