Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5B9E210BBD for ; Thu, 3 Oct 2013 05:10:52 +0000 (UTC) Received: (qmail 12542 invoked by uid 500); 3 Oct 2013 05:08:59 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 12373 invoked by uid 500); 3 Oct 2013 05:08:26 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 11886 invoked by uid 99); 3 Oct 2013 05:06:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Oct 2013 05:06:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Oct 2013 05:06:30 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2F24A238883D; Thu, 3 Oct 2013 05:06:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1528717 - /directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/Strings.java Date: Thu, 03 Oct 2013 05:06:09 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131003050609.2F24A238883D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Thu Oct 3 05:06:08 2013 New Revision: 1528717 URL: http://svn.apache.org/r1528717 Log: Forgot to commit the addition of a utf8ToStrin(ByteBuffer) method Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/Strings.java Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/Strings.java URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/Strings.java?rev=1528717&r1=1528716&r2=1528717&view=diff ============================================================================== --- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/Strings.java (original) +++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/Strings.java Thu Oct 3 05:06:08 2013 @@ -21,6 +21,7 @@ package org.apache.directory.mavibot.btr import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; import java.util.List; import java.util.Map; import java.util.Set; @@ -224,6 +225,34 @@ public final class Strings * Return an UTF-8 encoded String * * @param bytes The byte array to be transformed to a String + * @return A String. + */ + public static String utf8ToString( ByteBuffer bytes ) + { + if ( bytes == null ) + { + return ""; + } + + char[] chars = new char[bytes.limit()]; + int pos = 0; + + byte b; + + do + { + chars[pos++] = ( char ) UTF8[bytes.get()]; + } + while ( bytes.position() < bytes.limit() ); + + return new String( chars ); + } + + + /** + * Return an UTF-8 encoded String + * + * @param bytes The byte array to be transformed to a String * @param length The length of the byte array to be converted * @return A String. */