Hi,

Le 24/02/2014 18:55, Emmanuel Lécharny a écrit :
Le 2/24/14 6:20 PM, Raphaël Ouazana-Sustowski a écrit :
Hi,

I have a binary attribute (a byte[] or a BinaryValue if needed). I'd
like to convert it to an escaped format, suitable for a filter.
Is there any convenient method to do this?

Create a Value (in your case, a BinaryValue) and use the ExprNode class
you need to create a filter (EqualityNode, SubstringNode, ...).

For instance,

Value<byte[]> binValue = new BinaryValue( <your byte[]> );
Node filter = new EqualityNode( "MyBinaryAttr", binValue );

String escapedString = filter.toString();

the escapedString should be fine as a filter.

Thank you Emmanuel, this works with some little modifications:

BinaryValue binValue = new BinaryValue(value);
SimpleNode<byte[]> filter = new EqualityNode<byte[]>(attribute, binValue);
return filter.getEscapedValue().toString();

Regards,
Raphaël.

Reply via email to