Return-Path: X-Original-To: apmail-directory-api-archive@minotaur.apache.org Delivered-To: apmail-directory-api-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0118810E79 for ; Tue, 25 Feb 2014 08:30:38 +0000 (UTC) Received: (qmail 56882 invoked by uid 500); 25 Feb 2014 08:30:37 -0000 Delivered-To: apmail-directory-api-archive@directory.apache.org Received: (qmail 56803 invoked by uid 500); 25 Feb 2014 08:30:36 -0000 Mailing-List: contact api-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: api@directory.apache.org Delivered-To: mailing list api@directory.apache.org Received: (qmail 56792 invoked by uid 99); 25 Feb 2014 08:30:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Feb 2014 08:30:35 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of elecharny@gmail.com designates 74.125.82.46 as permitted sender) Received: from [74.125.82.46] (HELO mail-wg0-f46.google.com) (74.125.82.46) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Feb 2014 08:30:30 +0000 Received: by mail-wg0-f46.google.com with SMTP id z12so58705wgg.5 for ; Tue, 25 Feb 2014 00:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=JDayuRJRzoF15E5PhV7VrR0dFiK74vbYVxr48S1Mx4I=; b=JfaqVCxwgPN9qbF2Nn9ENGhYJ91MdzJU/Q2S3DG21evF5mzuI1bJdiXJMFLD4gEZvf pSJ3jKC2IOTDNOpYqen4OV+nttiandQT6CDFtq9wxV/2NpA2W1OrKsP7FBWpsglNY3Kn r1viaCzVETslVnwpcBB+5OO5elEfSyv0qA7O66iqGvG1RF3rpeI/yK7DGeA7esgw814R Vm+z+Na5jaiQtTdz+8zSWfC8so+HP0KcT3bQCBa87ovp4qqppFs8SJEbCHTSksaZEfrF QWhlTdQ0g+sDiitYQH5f1xl5uJE2s3wkxEDWb6QzjR5heRDjKjTDXSvZS7KCcmsRQxcO 6MPA== X-Received: by 10.194.58.180 with SMTP id s20mr906950wjq.54.1393317009015; Tue, 25 Feb 2014 00:30:09 -0800 (PST) Received: from new-host-3.home (AMontsouris-651-1-220-222.w92-140.abo.wanadoo.fr. [92.140.67.222]) by mx.google.com with ESMTPSA id n15sm31854003wij.3.2014.02.25.00.30.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 00:30:08 -0800 (PST) Message-ID: <530C5490.8040205@gmail.com> Date: Tue, 25 Feb 2014 09:30:08 +0100 From: =?UTF-8?B?RW1tYW51ZWwgTMOpY2hhcm55?= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: api@directory.apache.org Subject: Re: Binary value conversion for LDIF filters References: <530B8792.8060102@gmail.com> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Le 2/25/14 9:11 AM, Raphaël Ouazana-Sustowski a écrit : > 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 binValue = new BinaryValue( ); >> 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 filter = new EqualityNode(attribute, > binValue); > return filter.getEscapedValue().toString(); Yeah, sorry, I pulled it from the back of my head, I didn't checked with a real sample. That deserves to be documented somewhere... -- Regards, Cordialement, Emmanuel Lécharny www.iktek.com