directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r591493 [2/2] - in /directory/shared/branches/bigbang/ldap/src: main/java/org/apache/directory/shared/ldap/name/ main/java/org/apache/directory/shared/ldap/util/ test/java/org/apache/directory/shared/ldap/name/
Date Fri, 02 Nov 2007 22:08:05 GMT
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=591493&r1=591492&r2=591493&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java Fri Nov  2 15:08:03 2007
@@ -461,8 +461,7 @@
      * to a single space to perserve the whitespace separated tokenization order
      * of the String.
      * 
-     * @param string
-     *            the string to deep trim.
+     * @param string the string to deep trim.
      * @return the trimmed string.
      */
     public static final String deepTrim( String string )
@@ -488,10 +487,8 @@
     /**
      * Put common code to deepTrim(String) and deepTrimToLower here.
      * 
-     * @param str
-     *            the string to deep trim
-     * @param toLowerCase
-     *            how to normalize for case: upper or lower
+     * @param str the string to deep trim
+     * @param toLowerCase how to normalize for case: upper or lower
      * @return the deep trimmed string
      * @see StringTools#deepTrim( String )
      * 
@@ -566,12 +563,9 @@
      * length of the truncated string so size of '...' can be interpreted.
      * Useful for large strings in UIs or hex dumps to log files.
      * 
-     * @param str
-     *            the string to truncate
-     * @param head
-     *            the amount of the head to display
-     * @param tail
-     *            the amount of the tail to display
+     * @param str the string to truncate
+     * @param head the amount of the head to display
+     * @param tail the amount of the tail to display
      * @return the center truncated string
      */
     public static final String centerTrunc( String str, int head, int tail )
@@ -687,15 +681,11 @@
     /**
      * This method is used to insert HTML block dynamically
      * 
-     * @param source
-     *            the HTML code to be processes
-     * @param replaceNl
-     *            if true '\n' will be replaced by <br>
-     * @param replaceTag
-     *            if true '<' will be replaced by &lt; and '>' will be replaced
+     * @param source the HTML code to be processes
+     * @param replaceNl if true '\n' will be replaced by &lt;br>
+     * @param replaceTag if true '<' will be replaced by &lt; and '>' will be replaced
      *            by &gt;
-     * @param replaceQuote
-     *            if true '\"' will be replaced by &quot;
+     * @param replaceQuote if true '\"' will be replaced by &quot;
      * @return the formated html block
      */
     public static final String formatHtml( String source, boolean replaceNl, boolean replaceTag,
@@ -903,7 +893,7 @@
      * @return the filter accepted path component Strings in the order
      *         encountered
      */
-    public static final List getPaths( String paths, FileFilter filter )
+    public static final List<String> getPaths( String paths, FileFilter filter )
     {
         int start = 0;
         int stop = -1;
@@ -978,8 +968,7 @@
     /**
      * Helper function that dump a byte in hex form
      * 
-     * @param octet
-     *            The byte to dump
+     * @param octet The byte to dump
      * @return A string representation of the byte
      */
     public static final String dumpByte( byte octet )
@@ -1004,8 +993,7 @@
     /**
      * Helper function that dump an array of bytes in hex form
      * 
-     * @param buffer
-     *            The bytes array to dump
+     * @param buffer The bytes array to dump
      * @return A string representation of the array of bytes
      */
     public static final String dumpBytes( byte[] buffer )
@@ -1083,8 +1071,7 @@
     /**
      * Return the Unicode char which is coded in the bytes at position 0.
      * 
-     * @param bytes
-     *            The byte[] represntation of an Unicode string.
+     * @param bytes The byte[] represntation of an Unicode string.
      * @return The first char found.
      */
     public static final char bytesToChar( byte[] bytes )
@@ -1097,10 +1084,8 @@
      * Count the number of bytes needed to return an Unicode char. This can be
      * from 1 to 6.
      * 
-     * @param bytes
-     *            The bytes to read
-     * @param pos
-     *            Position to start counting. It must be a valid start of a
+     * @param bytes The bytes to read
+     * @param pos Position to start counting. It must be a valid start of a
      *            encoded char !
      * @return The number of bytes to create a char, or -1 if the encoding is
      *         wrong. TODO : Should stop after the third byte, as a char is only
@@ -1147,8 +1132,7 @@
     /**
      * Return the number of bytes that hold an Unicode char.
      * 
-     * @param car
-     *            The character to be decoded
+     * @param car The character to be decoded
      * @return The number of bytes to hold the char. TODO : Should stop after
      *         the third byte, as a char is only 2 bytes long.
      */
@@ -1188,8 +1172,7 @@
     /**
      * Count the number of bytes included in the given char[].
      * 
-     * @param chars
-     *            The char array to decode
+     * @param chars The char array to decode
      * @return The number of bytes in the char array
      */
     public static final int countBytes( char[] chars )
@@ -1220,10 +1203,8 @@
      * Return the Unicode char which is coded in the bytes at the given
      * position.
      * 
-     * @param bytes
-     *            The byte[] represntation of an Unicode string.
-     * @param pos
-     *            The current position to start decoding the char
+     * @param bytes The byte[] represntation of an Unicode string.
+     * @param pos The current position to start decoding the char
      * @return The decoded char, or -1 if no char can be decoded TODO : Should
      *         stop after the third byte, as a char is only 2 bytes long.
      */
@@ -1411,8 +1392,7 @@
     /**
      * Count the number of chars included in the given byte[].
      * 
-     * @param bytes
-     *            The byte array to decode
+     * @param bytes The byte array to decode
      * @return The number of char in the byte array
      */
     public static final int countChars( byte[] bytes )
@@ -1438,17 +1418,14 @@
     /**
      * Check if a text is present at the current position in a buffer.
      * 
-     * @param byteArray
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
-     * @param text
-     *            The text we want to check
+     * @param bytes The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param text The text we want to check
      * @return <code>true</code> if the buffer contains the text.
      */
-    public static final int areEquals( byte[] byteArray, int index, String text )
+    public static final int areEquals( byte[] bytes, int index, String text )
     {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( byteArray.length <= index ) || ( index < 0 )
+        if ( ( bytes == null ) || ( bytes.length == 0 ) || ( bytes.length <= index ) || ( index < 0 )
             || ( text == null ) )
         {
             return NOT_EQUAL;
@@ -1459,7 +1436,7 @@
             {
                 byte[] data = text.getBytes( "UTF-8" );
 
-                return areEquals( byteArray, index, data );
+                return areEquals( bytes, index, data );
             }
             catch ( UnsupportedEncodingException uee )
             {
@@ -1472,17 +1449,14 @@
     /**
      * Check if a text is present at the current position in a buffer.
      * 
-     * @param charArray
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
-     * @param text
-     *            The text we want to check
+     * @param chars The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param text The text we want to check
      * @return <code>true</code> if the buffer contains the text.
      */
-    public static final int areEquals( char[] charArray, int index, String text )
+    public static final int areEquals( char[] chars, int index, String text )
     {
-        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( charArray.length <= index ) || ( index < 0 )
+        if ( ( chars == null ) || ( chars.length == 0 ) || ( chars.length <= index ) || ( index < 0 )
             || ( text == null ) )
         {
             return NOT_EQUAL;
@@ -1491,7 +1465,7 @@
         {
             char[] data = text.toCharArray();
 
-            return areEquals( charArray, index, data );
+            return areEquals( chars, index, data );
         }
     }
 
@@ -1499,28 +1473,24 @@
     /**
      * Check if a text is present at the current position in a buffer.
      * 
-     * @param charArray
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
-     * @param charArray2
-     *            The text we want to check
+     * @param chars The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param chars2 The text we want to check
      * @return <code>true</code> if the buffer contains the text.
      */
-    public static final int areEquals( char[] charArray, int index, char[] charArray2 )
+    public static final int areEquals( char[] chars, int index, char[] chars2 )
     {
-
-        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( charArray.length <= index ) || ( index < 0 )
-            || ( charArray2 == null ) || ( charArray2.length == 0 )
-            || ( charArray2.length > ( charArray.length + index ) ) )
+        if ( ( chars == null ) || ( chars.length == 0 ) || ( chars.length <= index ) || ( index < 0 )
+            || ( chars2 == null ) || ( chars2.length == 0 )
+            || ( chars2.length > ( chars.length + index ) ) )
         {
             return NOT_EQUAL;
         }
         else
         {
-            for ( int i = 0; i < charArray2.length; i++ )
+            for ( int i = 0; i < chars2.length; i++ )
             {
-                if ( charArray[index++] != charArray2[i] )
+                if ( chars[index++] != chars2[i] )
                 {
                     return NOT_EQUAL;
                 }
@@ -1533,19 +1503,19 @@
     /**
      * Check if a text is present at the current position in another string.
      * 
-     * @param string1 The string which contains the data
+     * @param string The string which contains the data
      * @param index Current position in the string
      * @param text The text we want to check
      * @return <code>true</code> if the string contains the text.
      */
-    public static final boolean areEquals( String string1, int index, String text )
+    public static final boolean areEquals( String string, int index, String text )
     {
-        if ( ( string1 == null ) || ( text == null ) ) 
+        if ( ( string == null ) || ( text == null ) ) 
         {
             return false;
         }
         
-        int length1 = string1.length();
+        int length1 = string.length();
         int length2 = text.length();
 
         if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 )
@@ -1555,7 +1525,7 @@
         }
         else
         {
-        	return string1.substring( index ).startsWith( text );
+        	return string.substring( index ).startsWith( text );
         }
     }
     
@@ -1563,28 +1533,25 @@
     /**
      * Check if a text is present at the current position in a buffer.
      * 
-     * @param byteArray
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
-     * @param byteArray2
-     *            The text we want to check
+     * @param bytes The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param bytes2 The text we want to check
      * @return <code>true</code> if the buffer contains the text.
      */
-    public static final int areEquals( byte[] byteArray, int index, byte[] byteArray2 )
+    public static final int areEquals( byte[] bytes, int index, byte[] bytes2 )
     {
 
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( byteArray.length <= index ) || ( index < 0 )
-            || ( byteArray2 == null ) || ( byteArray2.length == 0 )
-            || ( byteArray2.length > ( byteArray.length + index ) ) )
+        if ( ( bytes == null ) || ( bytes.length == 0 ) || ( bytes.length <= index ) || ( index < 0 )
+            || ( bytes2 == null ) || ( bytes2.length == 0 )
+            || ( bytes2.length > ( bytes.length + index ) ) )
         {
             return NOT_EQUAL;
         }
         else
         {
-            for ( int i = 0; i < byteArray2.length; i++ )
+            for ( int i = 0; i < bytes2.length; i++ )
             {
-                if ( byteArray[index++] != byteArray2[i] )
+                if ( bytes[index++] != bytes2[i] )
                 {
                     return NOT_EQUAL;
                 }
@@ -1677,6 +1644,7 @@
         }
     }
 
+
     /**
      * Test if the current character is equal to a specific character.
      * 
@@ -1706,6 +1674,37 @@
         }
     }
 
+
+    /**
+     * Test if the current character is equal to a specific character.
+     * 
+     * @param string The String which contains the data
+     * @param index Current position in the string
+     * @param car The character we want to compare with the current string
+     *            position
+     * @return <code>true</code> if the current character equals the given
+     *         character.
+     */
+    public static final boolean isICharASCII( byte[] bytes, int index, char car )
+    {
+        if ( bytes == null )
+        {
+            return false;
+        }
+        
+        int length = bytes.length;
+        
+        if ( ( length == 0 ) || ( index < 0 ) || ( index >= length ) )
+        {
+            return false;
+        }
+        else
+        {
+            return ( ( bytes[ index ] | 0x20 ) & car ) == car;
+        }
+    }
+
+
     /**
      * Test if the current character is a bit, ie 0 or 1.
      * 
@@ -1739,10 +1738,8 @@
     /**
      * Get the character at a given position in a string, checking fo limits
      * 
-     * @param string
-     *            The string which contains the data
-     * @param index
-     *            Current position in the string
+     * @param string The string which contains the data
+     * @param index Current position in the string
      * @return The character ar the given position, or '\0' if something went wrong 
      */
     public static final char charAt( String string, int index )
@@ -1764,16 +1761,52 @@
         }
     }
 
-    public static byte getHexValue( char c1, char c2 )
+    
+    /**
+     * Translate two chars to an hex value. The chars must be 
+     * in [a-fA-F0-9]
+     *
+     * @param high The high value 
+     * @param low The low value
+     * @return A byte representation of the two chars
+     */
+    public static byte getHexValue( char high, char low )
+    {
+        if ( ( high > 127 ) || ( low > 127 ) || ( high < 0 ) | ( low < 0 ) )
+        {
+            return -1;
+        }
+        
+        return (byte)( ( HEX_VALUE[high] << 4 ) | HEX_VALUE[low] );
+    }
+
+
+    /**
+     * Translate two bytes to an hex value. The bytes must be 
+     * in [0-9a-fA-F]
+     *
+     * @param high The high value 
+     * @param low The low value
+     * @return A byte representation of the two bytes
+     */
+    public static byte getHexValue( byte high, byte low )
     {
-        if ( ( c1 > 127 ) || (c2 > 127 ) || ( c1 < 0 ) | ( c2 < 0 ) )
+        if ( ( high > 127 ) || ( low > 127 ) || ( high < 0 ) | ( low < 0 ) )
         {
             return -1;
         }
         
-        return (byte)( ( HEX_VALUE[c1] << 4 ) | HEX_VALUE[c2] );
+        return (byte)( ( HEX_VALUE[high] << 4 ) | HEX_VALUE[low] );
     }
 
+    
+    /**
+     * Return an hex value from a sinle char
+     * The char must be in [0-9a-fA-F]
+     *
+     * @param c The char we want to convert
+     * @return A byte between 0 and 15
+     */
     public static byte getHexValue( char c )
     {
         if ( ( c > 127 ) || ( c < 0 ) )
@@ -1788,21 +1821,19 @@
      * Check if the current character is an Hex Char &lt;hex> ::= [0x30-0x39] |
      * [0x41-0x46] | [0x61-0x66]
      * 
-     * @param byteArray
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
+     * @param bytes The buffer which contains the data
+     * @param index Current position in the buffer
      * @return <code>true</code> if the current character is a Hex Char
      */
-    public static final boolean isHex( byte[] byteArray, int index )
+    public static final boolean isHex( byte[] bytes, int index )
     {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) || ( index >= byteArray.length ) )
+        if ( ( bytes == null ) || ( bytes.length == 0 ) || ( index < 0 ) || ( index >= bytes.length ) )
         {
             return false;
         }
         else
         {
-            byte c = byteArray[index];
+            byte c = bytes[index];
 
             if ( ( ( c | 0x7F ) != 0x7F ) || ( HEX[c] == false ) )
             {
@@ -1820,10 +1851,8 @@
      * Check if the current character is an Hex Char &lt;hex> ::= [0x30-0x39] |
      * [0x41-0x46] | [0x61-0x66]
      * 
-     * @param chars
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
+     * @param chars The buffer which contains the data
+     * @param index Current position in the buffer
      * @return <code>true</code> if the current character is a Hex Char
      */
     public static final boolean isHex( char[] chars, int index )
@@ -1851,10 +1880,8 @@
      * Check if the current character is an Hex Char &lt;hex> ::= [0x30-0x39] |
      * [0x41-0x46] | [0x61-0x66]
      * 
-     * @param string
-     *            The string which contains the data
-     * @param index
-     *            Current position in the string
+     * @param string The string which contains the data
+     * @param index Current position in the string
      * @return <code>true</code> if the current character is a Hex Char
      */
     public static final boolean isHex( String string, int index )
@@ -1890,22 +1917,22 @@
      * Test if the current character is a digit &lt;digit> ::= '0' | '1' | '2' |
      * '3' | '4' | '5' | '6' | '7' | '8' | '9'
      * 
-     * @param byteArray
-     *            The buffer which contains the data
+     * @param bytes The buffer which contains the data
      * @return <code>true</code> if the current character is a Digit
      */
-    public static final boolean isDigit( byte[] byteArray )
+    public static final boolean isDigit( byte[] bytes )
     {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) )
+        if ( ( bytes == null ) || ( bytes.length == 0 ) )
         {
             return false;
         }
         else
         {
-            return ( ( ( ( byteArray[0] | 0x7F ) != 0x7F ) || !DIGIT[byteArray[0]] ) ? false : true );
+            return ( ( ( ( bytes[0] | 0x7F ) != 0x7F ) || !DIGIT[bytes[0]] ) ? false : true );
         }
     }
 
+    
     /**
      * Test if the current character is a digit &lt;digit> ::= '0' | '1' | '2' |
      * '3' | '4' | '5' | '6' | '7' | '8' | '9'
@@ -1919,6 +1946,7 @@
         return ( car >= '0' ) && ( car <= '9' );
     }
 
+    
     /**
      * Test if the current byte is an Alpha character : 
      * &lt;alpha> ::= [0x41-0x5A] | [0x61-0x7A]
@@ -1933,6 +1961,7 @@
         return ( ( c > 0 ) && ( c <= 127 ) && ALPHA[c] );
     }
 
+    
     /**
      * Test if the current character is an Alpha character : 
      * &lt;alpha> ::= [0x41-0x5A] | [0x61-0x7A]
@@ -1952,22 +1981,20 @@
      * Test if the current character is an Alpha character : &lt;alpha> ::=
      * [0x41-0x5A] | [0x61-0x7A]
      * 
-     * @param byteArray
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
+     * @param bytes The buffer which contains the data
+     * @param index Current position in the buffer
      * @return <code>true</code> if the current character is an Alpha
      *         character
      */
-    public static final boolean isAlphaASCII( byte[] byteArray, int index )
+    public static final boolean isAlphaASCII( byte[] bytes, int index )
     {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) || ( index >= byteArray.length ) )
+        if ( ( bytes == null ) || ( bytes.length == 0 ) || ( index < 0 ) || ( index >= bytes.length ) )
         {
             return false;
         }
         else
         {
-            byte c = byteArray[index++];
+            byte c = bytes[index++];
 
             if ( ( ( c | 0x7F ) != 0x7F ) || ( ALPHA[c] == false ) )
             {
@@ -1985,10 +2012,8 @@
      * Test if the current character is an Alpha character : &lt;alpha> ::=
      * [0x41-0x5A] | [0x61-0x7A]
      * 
-     * @param chars
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
+     * @param chars The buffer which contains the data
+     * @param index Current position in the buffer
      * @return <code>true</code> if the current character is an Alpha
      *         character
      */
@@ -2013,14 +2038,13 @@
         }
     }
 
+    
     /**
      * Test if the current character is an Alpha character : &lt;alpha> ::=
      * [0x41-0x5A] | [0x61-0x7A]
      * 
-     * @param string
-     *            The string which contains the data
-     * @param index
-     *            Current position in the string
+     * @param string The string which contains the data
+     * @param index Current position in the string
      * @return <code>true</code> if the current character is an Alpha
      *         character
      */
@@ -2052,14 +2076,13 @@
         }
     }
 
+    
     /**
      * Test if the current character is a lowercased Alpha character : <br/>
      * &lt;alpha> ::= [0x61-0x7A]
      * 
-     * @param string
-     *            The string which contains the data
-     * @param index
-     *            Current position in the string
+     * @param string The string which contains the data
+     * @param index Current position in the string
      * @return <code>true</code> if the current character is a lower Alpha
      *         character
      */
@@ -2091,14 +2114,13 @@
         }
     }
 
+    
     /**
      * Test if the current character is a uppercased Alpha character : <br/>
      * &lt;alpha> ::= [0x61-0x7A]
      * 
-     * @param string
-     *            The string which contains the data
-     * @param index
-     *            Current position in the string
+     * @param string The string which contains the data
+     * @param index Current position in the string
      * @return <code>true</code> if the current character is a lower Alpha
      *         character
      */
@@ -2135,21 +2157,19 @@
      * Test if the current character is a digit &lt;digit> ::= '0' | '1' | '2' |
      * '3' | '4' | '5' | '6' | '7' | '8' | '9'
      * 
-     * @param byteArray
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
+     * @param bytes The buffer which contains the data
+     * @param index Current position in the buffer
      * @return <code>true</code> if the current character is a Digit
      */
-    public static final boolean isDigit( byte[] byteArray, int index )
+    public static final boolean isDigit( byte[] bytes, int index )
     {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) || ( index >= byteArray.length ) )
+        if ( ( bytes == null ) || ( bytes.length == 0 ) || ( index < 0 ) || ( index >= bytes.length ) )
         {
             return false;
         }
         else
         {
-            return ( ( ( ( byteArray[index] | 0x7F ) !=  0x7F ) || !DIGIT[byteArray[index]] ) ? false : true );
+            return ( ( ( ( bytes[index] | 0x7F ) !=  0x7F ) || !DIGIT[bytes[index]] ) ? false : true );
         }
     }
 
@@ -2158,10 +2178,8 @@
      * Test if the current character is a digit &lt;digit> ::= '0' | '1' | '2' |
      * '3' | '4' | '5' | '6' | '7' | '8' | '9'
      * 
-     * @param chars
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
+     * @param chars The buffer which contains the data
+     * @param index Current position in the buffer
      * @return <code>true</code> if the current character is a Digit
      */
     public static final boolean isDigit( char[] chars, int index )
@@ -2176,14 +2194,13 @@
         }
     }
 
+    
     /**
      * Test if the current character is a digit &lt;digit> ::= '0' | '1' | '2' |
      * '3' | '4' | '5' | '6' | '7' | '8' | '9'
      * 
-     * @param string
-     *            The string which contains the data
-     * @param index
-     *            Current position in the string
+     * @param string The string which contains the data
+     * @param index Current position in the string
      * @return <code>true</code> if the current character is a Digit
      */
     public static final boolean isDigit( String string, int index )
@@ -2206,12 +2223,12 @@
         }
     }
 
+    
     /**
      * Test if the current character is a digit &lt;digit> ::= '0' | '1' | '2' |
      * '3' | '4' | '5' | '6' | '7' | '8' | '9'
      * 
-     * @param chars
-     *            The buffer which contains the data
+     * @param chars The buffer which contains the data
      * @return <code>true</code> if the current character is a Digit
      */
     public static final boolean isDigit( char[] chars )
@@ -2226,15 +2243,14 @@
         }
     }
 
+    
     /**
      * Check if the current character is an 7 bits ASCII CHAR (between 0 and
      * 127). 
      * &lt;char> ::= &lt;alpha> | &lt;digit>
      * 
-     * @param string
-     *            The string which contains the data
-     * @param index
-     *            Current position in the string
+     * @param string The string which contains the data
+     * @param index Current position in the string
      * @return The position of the next character, if the current one is a CHAR.
      */
     public static final boolean isAlphaDigit( String string, int index )
@@ -2266,26 +2282,23 @@
     }
 
 
-
     /**
      * Check if the current character is an 7 bits ASCII CHAR (between 0 and
      * 127). &lt;char> ::= &lt;alpha> | &lt;digit> | '-'
      * 
-     * @param byteArray
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
+     * @param bytes The buffer which contains the data
+     * @param index Current position in the buffer
      * @return The position of the next character, if the current one is a CHAR.
      */
-    public static final boolean isAlphaDigitMinus( byte[] byteArray, int index )
+    public static final boolean isAlphaDigitMinus( byte[] bytes, int index )
     {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) || ( index >= byteArray.length ) )
+        if ( ( bytes == null ) || ( bytes.length == 0 ) || ( index < 0 ) || ( index >= bytes.length ) )
         {
             return false;
         }
         else
         {
-            byte c = byteArray[index++];
+            byte c = bytes[index++];
 
             if ( ( ( c | 0x7F ) != 0x7F ) || ( CHAR[c] == false ) )
             {
@@ -2303,10 +2316,8 @@
      * Check if the current character is an 7 bits ASCII CHAR (between 0 and
      * 127). &lt;char> ::= &lt;alpha> | &lt;digit> | '-'
      * 
-     * @param chars
-     *            The buffer which contains the data
-     * @param index
-     *            Current position in the buffer
+     * @param chars The buffer which contains the data
+     * @param index Current position in the buffer
      * @return The position of the next character, if the current one is a CHAR.
      */
     public static final boolean isAlphaDigitMinus( char[] chars, int index )
@@ -2330,14 +2341,13 @@
         }
     }
 
+    
     /**
      * Check if the current character is an 7 bits ASCII CHAR (between 0 and
      * 127). &lt;char> ::= &lt;alpha> | &lt;digit> | '-'
      * 
-     * @param string
-     *            The string which contains the data
-     * @param index
-     *            Current position in the string
+     * @param string The string which contains the data
+     * @param index Current position in the string
      * @return The position of the next character, if the current one is a CHAR.
      */
     public static final boolean isAlphaDigitMinus( String string, int index )
@@ -2368,6 +2378,7 @@
         }
     }
 
+    
     // Empty checks
     // -----------------------------------------------------------------------
     /**
@@ -2388,8 +2399,7 @@
      * String. That functionality is available in isBlank().
      * </p>
      * 
-     * @param str
-     *            the String to check, may be null
+     * @param str the String to check, may be null
      * @return <code>true</code> if the String is empty or null
      */
     public static final boolean isEmpty( String str )
@@ -2401,8 +2411,7 @@
     /**
      * Checks if a bytes array is empty or null.
      * 
-     * @param bytes
-     *            The bytes array to check, may be null
+     * @param bytes The bytes array to check, may be null
      * @return <code>true</code> if the bytes array is empty or null
      */
     public static final boolean isEmpty( byte[] bytes )
@@ -2424,8 +2433,7 @@
      *  StringUtils.isNotEmpty(&quot;  bob  &quot;) = true
      * </pre>
      * 
-     * @param str
-     *            the String to check, may be null
+     * @param str the String to check, may be null
      * @return <code>true</code> if the String is not empty and not null
      */
     public static final boolean isNotEmpty( String str )
@@ -2449,8 +2457,7 @@
      *  StringUtils.trim(&quot;    abc    &quot;) = &quot;abc&quot;
      * </pre>
      * 
-     * @param str
-     *            the String to be trimmed, may be null
+     * @param str the String to be trimmed, may be null
      * @return the trimmed string, <code>null</code> if null String input
      */
     public static final String trim( String str )
@@ -2520,8 +2527,7 @@
      *  StringUtils.trimLeft(&quot;    abc    &quot;) = &quot;abc    &quot;
      * </pre>
      * 
-     * @param str
-     *            the String to be trimmed, may be null
+     * @param str the String to be trimmed, may be null
      * @return the trimmed string, <code>null</code> if null String input
      */
     public static final String trimLeft( String str )
@@ -2558,8 +2564,7 @@
      *  StringUtils.trimLeft(&quot;    abc    &quot;) = &quot;abc    &quot;
      * </pre>
      * 
-     * @param chars
-     *            the chars array to be trimmed, may be null
+     * @param chars the chars array to be trimmed, may be null
      * @return the position of the first char which is not a space, or the last
      *         position of the array.
      */
@@ -2578,6 +2583,7 @@
         return pos;
     }
 
+
     /**
      * <p>
      * Removes spaces (char &lt;= 32) from a position in this array, handling
@@ -2618,6 +2624,44 @@
 
     /**
      * <p>
+     * Removes spaces (char &lt;= 32) from a position in this array, handling
+     * <code>null</code> by returning <code>null</code>.
+     * </p>
+     * Trim removes start characters &lt;= 32.
+     * 
+     * <pre>
+     *  StringUtils.trimLeft(null)          = null
+     *  StringUtils.trimLeft(&quot;&quot;,...)            = &quot;&quot;
+     *  StringUtils.trimLeft(&quot;     &quot;,...)       = &quot;&quot;
+     *  StringUtils.trimLeft(&quot;abc&quot;,...)         = &quot;abc&quot;
+     *  StringUtils.trimLeft(&quot;    abc    &quot;,...) = &quot;abc    &quot;
+     * </pre>
+     * 
+     * @param bytes the byte array to be trimmed, may be null
+     * @param pos The starting position
+     */
+    public static final void trimLeft( byte[] bytes, Position pos )
+    {
+        if ( bytes == null )
+        {
+            return;
+        }
+
+        int length = bytes.length;
+        
+        while ( ( pos.start < length ) && ( bytes[ pos.start ] == ' ' ) )
+        {
+            pos.start++;
+        }
+        
+        pos.end = pos.start;
+
+        return;
+    }
+
+    
+    /**
+     * <p>
      * Removes spaces (char &lt;= 32) from start of this array, handling
      * <code>null</code> by returning <code>null</code>.
      * </p>
@@ -2631,8 +2675,7 @@
      *  StringUtils.trimLeft(&quot;    abc    &quot;) = &quot;abc    &quot;
      * </pre>
      * 
-     * @param bytes
-     *            the byte array to be trimmed, may be null
+     * @param bytes the byte array to be trimmed, may be null
      * @return the position of the first byte which is not a space, or the last
      *         position of the array.
      */
@@ -2667,8 +2710,7 @@
      *  StringUtils.trimRight(&quot;    abc    &quot;) = &quot;    abc&quot;
      * </pre>
      * 
-     * @param str
-     *            the String to be trimmed, may be null
+     * @param str the String to be trimmed, may be null
      * @return the trimmed string, <code>null</code> if null String input
      */
     public static final String trimRight( String str )
@@ -2752,8 +2794,7 @@
      *  StringUtils.trimRight(&quot;    abc    &quot;) = &quot;    abc&quot;
      * </pre>
      * 
-     * @param chars
-     *            the chars array to be trimmed, may be null
+     * @param chars the chars array to be trimmed, may be null
      * @return the position of the first char which is not a space, or the last
      *         position of the array.
      */
@@ -2772,6 +2813,7 @@
         return pos;
     }
 
+
     /**
      * <p>
      * Removes spaces (char &lt;= 32) from end of this string, handling
@@ -2787,8 +2829,7 @@
      *  StringUtils.trimRight(&quot;    abc    &quot;) = &quot;    abc&quot;
      * </pre>
      * 
-     * @param string
-     *            the string to be trimmed, may be null
+     * @param string the string to be trimmed, may be null
      * @return the position of the first char which is not a space, or the last
      *         position of the string.
      */
@@ -2812,6 +2853,54 @@
         return ( pos.end == string.length() ? string : string.substring( 0, pos.end ) );
     }
 
+
+    /**
+     * <p>
+     * Removes spaces (char &lt;= 32) from end of this string, handling
+     * <code>null</code> by returning <code>null</code>.
+     * </p>
+     * Trim removes start characters &lt;= 32.
+     * 
+     * <pre>
+     *  StringUtils.trimRight(null)          = null
+     *  StringUtils.trimRight(&quot;&quot;)            = &quot;&quot;
+     *  StringUtils.trimRight(&quot;     &quot;)       = &quot;&quot;
+     *  StringUtils.trimRight(&quot;abc&quot;)         = &quot;abc&quot;
+     *  StringUtils.trimRight(&quot;    abc    &quot;) = &quot;    abc&quot;
+     * </pre>
+     * 
+     * @param bytes the byte array to be trimmed, may be null
+     * @return the position of the first char which is not a space, or the last
+     *         position of the byte array.
+     */
+    public static final String trimRight( byte[] bytes, Position pos )
+    {
+        if ( bytes == null )
+        {
+            return "";
+        }
+
+        while ( ( pos.end >= 0 ) && ( bytes[pos.end - 1] == ' ' ) )
+        {
+            if ( ( pos.end > 1 ) && ( bytes[pos.end - 2] == '\\' ) )
+            {
+                break;
+            }
+            
+            pos.end--;
+        }
+
+        if ( pos.end == bytes.length )
+        {
+            return StringTools.utf8ToString( bytes );
+        }
+        else
+        {
+            return StringTools.utf8ToString( bytes, pos.end );
+        }
+    }
+
+
     /**
      * <p>
      * Removes spaces (char &lt;= 32) from end of this array, handling
@@ -2827,8 +2916,7 @@
      *  StringUtils.trimRight(&quot;    abc    &quot;) = &quot;    abc&quot;
      * </pre>
      * 
-     * @param bytes
-     *            the chars array to be trimmed, may be null
+     * @param bytes the byte array to be trimmed, may be null
      * @return the position of the first char which is not a space, or the last
      *         position of the array.
      */
@@ -2864,8 +2952,7 @@
      *  StringUtils.upperCase(&quot;aBc&quot;) = &quot;ABC&quot;
      * </pre>
      * 
-     * @param str
-     *            the String to upper case, may be null
+     * @param str the String to upper case, may be null
      * @return the upper cased String, <code>null</code> if null String input
      */
     public static final String upperCase( String str )
@@ -2893,8 +2980,7 @@
      *  StringUtils.lowerCase(&quot;aBc&quot;) = &quot;abc&quot;
      * </pre>
      * 
-     * @param str
-     *            the String to lower case, may be null
+     * @param str the String to lower case, may be null
      * @return the lower cased String, <code>null</code> if null String input
      */
     public static final String lowerCase( String str )
@@ -2907,6 +2993,7 @@
         return str.toLowerCase();
     }
 
+    
     /**
      * Rewrote the toLowercase method to improve performances.
      * In Ldap, attributesType are supposed to use ASCII chars :
@@ -2934,6 +3021,7 @@
         return new String( chars );
     }
 
+    
     // Equals
     // -----------------------------------------------------------------------
     /**
@@ -2955,10 +3043,8 @@
      * </pre>
      * 
      * @see java.lang.String#equals(Object)
-     * @param str1
-     *            the first String, may be null
-     * @param str2
-     *            the second String, may be null
+     * @param str1 the first String, may be null
+     * @param str2 the second String, may be null
      * @return <code>true</code> if the Strings are equal, case sensitive, or
      *         both <code>null</code>
      */
@@ -2971,8 +3057,7 @@
     /**
      * Return an UTF-8 encoded String
      * 
-     * @param bytes
-     *            The byte array to be transformed to a String
+     * @param bytes The byte array to be transformed to a String
      * @return A String.
      */
     public static final String utf8ToString( byte[] bytes )
@@ -2992,13 +3077,12 @@
         }
     }
 
+
     /**
      * 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
+     * @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.
      */
     public static final String utf8ToString( byte[] bytes, int length )
@@ -3020,10 +3104,35 @@
 
 
     /**
+     * Return an UTF-8 encoded String
+     * 
+     * @param bytes  The byte array to be transformed to a String
+     * @param start the starting position in the byte array  
+     * @param length The length of the byte array to be converted
+     * @return A String.
+     */
+    public static final String utf8ToString( byte[] bytes, int start, int length )
+    {
+        if ( bytes == null )
+        {
+            return "";
+        }
+
+        try
+        {
+            return new String( bytes, start, length, "UTF-8" );
+        }
+        catch ( UnsupportedEncodingException uee )
+        {
+            return "";
+        }
+    }
+
+
+    /**
      * Return UTF-8 encoded byte[] representation of a String
      * 
-     * @param string
-     *            The string to be transformed to a byte array
+     * @param string The string to be transformed to a byte array
      * @return The transformed byte array
      */
     public static final byte[] getBytesUtf8( String string )
@@ -3048,21 +3157,20 @@
     /**
      * Utility method that return a String representation of a list
      * 
-     * @param list
-     *            The list to transform to a string
+     * @param list The list to transform to a string
      * @return A csv string
      */
-    public static final String listToString( List list )
+    public static final String listToString( List<?> list )
     {
         if ( ( list == null ) || ( list.size() == 0 ) )
         {
             return "";
         }
 
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         boolean isFirst = true;
 
-        Iterator iter = list.iterator();
+        Iterator<?> iter = list.iterator();
 
         while ( iter.hasNext() )
         {
@@ -3085,11 +3193,11 @@
     /**
      * Utility method that return a String representation of a list
      * 
-     * @param list
-     *            The list to transform to a string
+     * @param list The list to transform to a string
+     * @param tabs The tabs to add in ffront of the elements
      * @return A csv string
      */
-    public static final String listToString( List list, String tabs )
+    public static final String listToString( List<?> list, String tabs )
     {
         if ( ( list == null ) || ( list.size() == 0 ) )
         {
@@ -3098,7 +3206,7 @@
 
         StringBuffer sb = new StringBuffer();
 
-        Iterator iter = list.iterator();
+        Iterator<?> iter = list.iterator();
 
         while ( iter.hasNext() )
         {
@@ -3115,11 +3223,10 @@
      * Utility method that return a String representation of a map. The elements
      * will be represented as "key = value"
      * 
-     * @param map
-     *            The map to transform to a string
+     * @param map The map to transform to a string
      * @return A csv string
      */
-    public static final String mapToString( Map map )
+    public static final String mapToString( Map<?,?> map )
     {
         if ( ( map == null ) || ( map.size() == 0 ) )
         {
@@ -3129,7 +3236,7 @@
         StringBuffer sb = new StringBuffer();
         boolean isFirst = true;
 
-        Iterator iter = map.keySet().iterator();
+        Iterator<?> iter = map.keySet().iterator();
 
         while ( iter.hasNext() )
         {
@@ -3155,11 +3262,11 @@
      * Utility method that return a String representation of a map. The elements
      * will be represented as "key = value"
      * 
-     * @param map
-     *            The map to transform to a string
+     * @param map The map to transform to a string
+     * @param tabs The tabs to add in ffront of the elements
      * @return A csv string
      */
-    public static final String mapToString( Map map, String tabs )
+    public static final String mapToString( Map<?,?> map, String tabs )
     {
         if ( ( map == null ) || ( map.size() == 0 ) )
         {
@@ -3168,7 +3275,7 @@
 
         StringBuffer sb = new StringBuffer();
 
-        Iterator iter = map.keySet().iterator();
+        Iterator<?> iter = map.keySet().iterator();
 
         while ( iter.hasNext() )
         {
@@ -3183,6 +3290,7 @@
         return sb.toString();
     }
 
+    
     /**
      * Get the default charset
      * 
@@ -3208,11 +3316,15 @@
     	return defaultCharset;
     }
     
+    
     /**
      * Decodes values of attributes in the DN encoded in hex into a UTF-8 
      * String.  RFC2253 allows a DN's attribute to be encoded in hex.
      * The encoded value starts with a # then is followed by an even 
      * number of hex characters.  
+     * 
+     * @param str the string to decode
+     * @return the decoded string
      */
     public static final String decodeHexString( String str ) throws InvalidNameException
     {
@@ -3251,7 +3363,7 @@
      * String is returned.
      * 
      * @param str the string containing hex escapes
-     * @return decoded string
+     * @return the decoded string
      */
     public static final String decodeEscapedHex( String str ) throws InvalidNameException
     {
@@ -3323,6 +3435,7 @@
         return advanceBy;
     }
     
+    
     /**
      * Thansform an array of ASCII bytes to a string. the byte array should contains
      * only values in [0, 127].
@@ -3347,6 +3460,7 @@
         return new String( result );
     }
     
+    
     /**
      * Build an AttributeType froma byte array. An AttributeType contains
      * only chars within [0-9][a-z][A-Z][-.].
@@ -3372,6 +3486,7 @@
         return new String( chars );
     }
     
+    
     /**
      * 
      * Check that a String is a valid IA5String. An IA5String contains only
@@ -3429,6 +3544,7 @@
         return true;
     }
 
+    
     /**
      * Check if the current char is in the unicodeSubset : all chars but
      * '\0', '(', ')', '*' and '\'
@@ -3447,9 +3563,9 @@
         char c = str.charAt( pos );
         
         return ( ( c > 127 ) || UNICODE_SUBSET[c] );
-        
     }
 
+    
     /**
      * Check if the current char is in the unicodeSubset : all chars but
      * '\0', '(', ')', '*' and '\'

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=591493&r1=591492&r2=591493&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java Fri Nov  2 15:08:03 2007
@@ -1070,7 +1070,7 @@
    public void testLdapDNGetAllNull()
    {
        LdapDN dn = new LdapDN();
-       Enumeration nc = dn.getAll();
+       Enumeration<String> nc = dn.getAll();
 
        assertEquals( false, nc.hasMoreElements() );
    }
@@ -1082,7 +1082,7 @@
    public void testLdapDNGetAllEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "" );
-       Enumeration nc = dn.getAll();
+       Enumeration<String> nc = dn.getAll();
 
        assertEquals( false, nc.hasMoreElements() );
    }
@@ -1094,7 +1094,7 @@
    public void testLdapDNGetAllSimple() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b" );
-       Enumeration nc = dn.getAll();
+       Enumeration<String> nc = dn.getAll();
 
        assertEquals( true, nc.hasMoreElements() );
        assertEquals( "a=b", nc.nextElement() );
@@ -1108,7 +1108,7 @@
    public void testLdapDNGetAllComplex() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "e=f+g=h,a=b,c=d" );
-       Enumeration nc = dn.getAll();
+       Enumeration<String> nc = dn.getAll();
 
        assertEquals( true, nc.hasMoreElements() );
        assertEquals( "c=d", nc.nextElement() );
@@ -1126,7 +1126,7 @@
    public void testLdapDNGetAllComplexOrdered() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "g=h+e=f,a=b,c=d" );
-       Enumeration nc = dn.getAll();
+       Enumeration<String> nc = dn.getAll();
 
        assertEquals( true, nc.hasMoreElements() );
        assertEquals( "c=d", nc.nextElement() );
@@ -1591,10 +1591,10 @@
        Name name5 = new LdapDN( "cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
        Name name6 = new LdapDN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
 
-       Enumeration enum0 = name0.getAll();
+       Enumeration<String> enum0 = name0.getAll();
        assertEquals( false, enum0.hasMoreElements() );
 
-       Enumeration enum1 = name1.getAll();
+       Enumeration<String> enum1 = name1.getAll();
        assertEquals( true, enum1.hasMoreElements() );
 
        for ( int i = 0; enum1.hasMoreElements(); i++ )
@@ -1607,7 +1607,7 @@
            }
        }
 
-       Enumeration enum2 = name2.getAll();
+       Enumeration<String> enum2 = name2.getAll();
        assertEquals( true, enum2.hasMoreElements() );
 
        for ( int i = 0; enum2.hasMoreElements(); i++ )
@@ -1625,7 +1625,7 @@
            }
        }
 
-       Enumeration enum3 = name3.getAll();
+       Enumeration<String> enum3 = name3.getAll();
        assertEquals( true, enum3.hasMoreElements() );
 
        for ( int i = 0; enum3.hasMoreElements(); i++ )
@@ -1648,7 +1648,7 @@
            }
        }
 
-       Enumeration enum4 = name4.getAll();
+       Enumeration<String> enum4 = name4.getAll();
        assertEquals( true, enum4.hasMoreElements() );
 
        for ( int i = 0; enum4.hasMoreElements(); i++ )
@@ -1676,7 +1676,7 @@
            }
        }
 
-       Enumeration enum5 = name5.getAll();
+       Enumeration<String> enum5 = name5.getAll();
        assertEquals( true, enum5.hasMoreElements() );
 
        for ( int i = 0; enum5.hasMoreElements(); i++ )
@@ -1709,7 +1709,7 @@
            }
        }
 
-       Enumeration enum6 = name6.getAll();
+       Enumeration<String> enum6 = name6.getAll();
        assertEquals( true, enum6.hasMoreElements() );
 
        for ( int i = 0; enum6.hasMoreElements(); i++ )
@@ -1759,7 +1759,7 @@
    {
        LdapDN name = new LdapDN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
 
-       Enumeration rdns = name.getAllRdn();
+       Enumeration<Rdn> rdns = name.getAllRdn();
        assertEquals( true, rdns.hasMoreElements() );
 
        for ( int i = 0; rdns.hasMoreElements(); i++ )
@@ -2596,8 +2596,8 @@
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
 
-       Enumeration j = jName.getAll();
-       Enumeration a = aName.getAll();
+       Enumeration<String> j = jName.getAll();
+       Enumeration<String> a = aName.getAll();
        while (j.hasMoreElements())
        {
            assertTrue(j.hasMoreElements());
@@ -2614,8 +2614,8 @@
        Name name1 = new LdapDN( "cn=\"Kylie Minogue\",dc=example,dc=com" );
        Name name2 = new LdapName( "cn=\"Kylie Minogue\",dc=example,dc=com" );
 
-       Enumeration j = name1.getAll();
-       Enumeration a = name2.getAll();
+       Enumeration<String> j = name1.getAll();
+       Enumeration<String> a = name2.getAll();
 
        while (j.hasMoreElements())
        {

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java?rev=591493&r1=591492&r2=591493&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java Fri Nov  2 15:08:03 2007
@@ -244,6 +244,19 @@
     }
 
 
+    public void testStringParserShort() throws NamingException
+    {
+        String dn = StringTools.utf8ToString( new byte[]
+            { 'C', '=', ' ', 'E', ( byte ) 0xc3, ( byte ) 0xa9, 'c' } );
+
+        NameParser dnParser = LdapDnParser.getNameParser();
+        LdapDN name = ( LdapDN ) dnParser.parse( dn );
+
+        Assert.assertEquals( dn, name.getUpName() );
+        Assert.assertEquals( "c=E\\C3\\A9c", name.toString() );
+    }
+
+
     public void testVsldapExtras() throws NamingException
     {
         NameParser dnParser = LdapDnParser.getNameParser();
@@ -521,6 +534,29 @@
 
         assertEquals( "cn=\\C4\\B0\\C4\\B1\\C5\\9E\\C5\\9F\\C3\\96\\C3\\B6\\C3\\9C\\C3\\BC\\C4\\9E\\C4\\9F", result );
 
+    }
+    
+   
+    public void testAUmlautPlusBytes() throws Exception
+    {
+        String cn = new String( new byte[] { 'c', 'n', '=', (byte)0xC3, (byte)0x84, 0x5C, 0x32, 0x42 }, "UTF-8" );
+
+
+        NameParser parser = LdapDnParser.getNameParser();
+        String result = parser.parse( cn ).toString();
+        
+        assertEquals( "cn=\\C3\\84\\+", result );
+    }
+
+
+    public void testAUmlautPlusChar() throws Exception
+    {
+        String cn = new String( new byte[] { 'c', 'n', '=', (byte)0xC3, (byte)0x84, '\\', '+' }, "UTF-8" );
+        
+        NameParser parser = LdapDnParser.getNameParser();
+        String result = parser.parse( cn ).toString();
+        
+        assertEquals( "cn=\\C3\\84\\+", result );
     }
 
 



Mime
View raw message