How do I parse strings as an Expression in Android?

Examples:

(woassetclass == 'FSE BMP' OR woassetclass == 'Collected Fog') and inspectionstatus == 'Closed'

(doctype == 'gisasset' OR doctype == 'gpsasset') and (woassetclass == 'FSE BMP' OR woassetclass == 'Collected Fog') and inspectionstatus == 'Follow Up'

layername == 'Collected Fog'

I want to use these in Couchbase Lite. How do I parse these strings to Couchbase Expression type instances? The syntax is pretty strict (==, !=, contains), the left hand side which are the property names do not have quotation marks, while the value strings do.

Example translation:1.

(Expression.property("woassetclass").equalTo(Expression.string("FSE BMP")).or(Expression.property("woassetclass").equalTo(Expression.string("Collected Fog")))).and(Expression.property("inspectionstatus").equalTo(Expression.string("Closed")))

I’m not clear on what you are trying to accomplish.

Perhaps, instead of the string constants, you would like a runtime created parameter? You could do that as follows:

(Expression.property("woassetclass").equalTo(Expression.parameter("FSEBMP"))...
...
Parameters params = new Parameters();
params.setString("FSEBMP", someValue);
query.setParameters(params);

Hope that helps…

The string constants come from an external source. So I have no choice but to manually parse them as SQL query parameters. But i dont know how to

I guess what i want is to have a Query.where(String rawString) method so we can input raw string constants that are valid NoSQL WHERE clauses.

I just saw the explain() method. I would want to be able to do the opposite of that

I would have to see more specifics for use case. I cannot imagine a case where you would need to wrap pre-built “where” clauses. If you can pre-build the where clause, you can build the where clause using the CBL Query builder…