Hi,

On 28/10/2019 13:12, Davi Baldin Tavares wrote:
Hello,

I would like to use Apache’s FilterParser to parser RFC style queries.

However, digging into your APIs, I couldn’t figure out how to navigate under 
the parsed filter structure. My goal is to iterate over parser attributes and 
construct a MongoDB’s filter object.

import org.apache.directory.shared.ldap.filter.FilterParser;
final ExprNode filter = FilterParser.parse(“(name=Davi)”);

Would you have an example of iterating over the parsed filter?


Not sure what you mean by 'iterating over the parsed filter'.

In any case, the parse() method returns a ExprNode instance, which depends on the kind of filter you just parsed.  You have 2 big classes of Nodes :

- branch nodes (&, |, !), which contains sub-nodes

- leaf nodes ( =*, <=, >=, =, ~=, substring and extensible nodes), which are final nodes.

You can check the type of nodes you are dealing with using the ExprNode.isLeaf(), then the simlplest way to know which kind of node is to use instanceof.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to