Search in sources :

Example 1 with ASTargument

use of org.apache.jsieve.parser.generated.ASTargument in project zm-mailbox by Zimbra.

the class RuleRewriter method test.

private void test(Element elem, Node node) {
    int numChildren = node.jjtGetNumChildren();
    for (int i = 0; i < numChildren; i++) {
        Node childNode = node.jjtGetChild(i);
        if (childNode instanceof ASTargument) {
            Object val = ((SieveNode) childNode).getValue();
            if (val != null) {
                if (MATCH_TYPES.contains(val.toString())) {
                    if (!mStack.isEmpty())
                        val = mStack.pop() + " " + val;
                    elem.addAttribute(MailConstants.A_OPERATION, val.toString());
                } else {
                    String cname = elem.getAttribute(MailConstants.A_NAME, null);
                    if ("size".equals(cname)) {
                        // special casing size test
                        elem.addAttribute(MailConstants.A_RHS, getSize(val.toString()));
                    } else {
                        elem.addAttribute(MailConstants.A_MODIFIER, val.toString());
                    }
                }
            }
        } else if (childNode instanceof ASTstring_list) {
            List<Object> val = getStringList(childNode);
            String cname = elem.getAttribute(MailConstants.A_NAME, null);
            String param = null;
            if ("date".equals(cname) || "body".equals(cname))
                param = MailConstants.A_RHS;
            else
                param = PARAM_PREFIX + String.valueOf(x++);
            elem.addAttribute(param, toString(val));
        }
        test(elem, childNode);
    }
}
Also used : SieveNode(org.apache.jsieve.parser.SieveNode) ASTstring_list(org.apache.jsieve.parser.generated.ASTstring_list) Node(org.apache.jsieve.parser.generated.Node) SieveNode(org.apache.jsieve.parser.SieveNode) ArrayList(java.util.ArrayList) List(java.util.List) ASTargument(org.apache.jsieve.parser.generated.ASTargument) Mountpoint(com.zimbra.cs.mailbox.Mountpoint)

Aggregations

Mountpoint (com.zimbra.cs.mailbox.Mountpoint)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SieveNode (org.apache.jsieve.parser.SieveNode)1 ASTargument (org.apache.jsieve.parser.generated.ASTargument)1 ASTstring_list (org.apache.jsieve.parser.generated.ASTstring_list)1 Node (org.apache.jsieve.parser.generated.Node)1