use of org.apache.jsieve.parser.generated.ASTtest in project zm-mailbox by Zimbra.
the class RuleRewriter method rule.
private void rule(Element elem, Node parent) {
int numChildren = parent.jjtGetNumChildren();
for (int i = 0; i < numChildren; i++) {
Node node = parent.jjtGetChild(i);
String name = ((SieveNode) node).getName();
if (node instanceof ASTtest) {
if ("anyof".equals(name) || "allof".equals(name)) {
Element condsElem = elem.addElement(MailConstants.E_CONDITION_GROUP).addAttribute(MailConstants.A_OPERATION, name);
rule(condsElem, node);
} else if ("not".equals(name)) {
mStack.push(name);
rule(elem, node);
} else {
if ("exists".equals(name) && !mStack.isEmpty()) {
name = mStack.pop() + " " + name;
}
Element cElem = elem.addElement(MailConstants.E_CONDITION).addAttribute(MailConstants.A_NAME, name);
x = 0;
test(cElem, node);
}
} else if (node instanceof ASTcommand) {
Element actionElem = elem.addElement(MailConstants.E_ACTION).addAttribute(MailConstants.A_NAME, ((SieveNode) node).getName());
action(actionElem, node);
} else {
rule(elem, node);
}
}
}
use of org.apache.jsieve.parser.generated.ASTtest in project zm-mailbox by Zimbra.
the class SieveVisitor method accept.
private void accept(Node parent, RuleProperties props) throws ServiceException {
visitNode(parent, VisitPhase.begin, props);
int numChildren = parent.jjtGetNumChildren();
for (int i = 0; i < numChildren; i++) {
Node node = parent.jjtGetChild(i);
if (isRuleNode(node)) {
// New rule tree or Nested if. New RuleProperties is created for each nested if
RuleProperties newProps = new RuleProperties();
if ("disabled_if".equalsIgnoreCase(getNodeName(node))) {
newProps.isEnabled = false;
}
visitIfControl(node, VisitPhase.begin, newProps);
accept(node, newProps);
visitIfControl(node, VisitPhase.end, newProps);
} else if (node instanceof ASTtest) {
acceptTest(node, props);
} else if (node instanceof ASTcommand) {
acceptAction(node, props);
} else {
accept(node, props);
}
}
visitNode(parent, VisitPhase.end, props);
}
Aggregations