directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raphaël Ouazana-Sustowski <raphael.ouaz...@linagora.com>
Subject Re: Binary value conversion for LDIF filters
Date Tue, 25 Feb 2014 08:11:55 GMT
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.

Mime
View raw message