You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/05/19 19:40:46 UTC

svn commit: r946302 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/util/ test/java/org/apache/directory/shared/ldap/util/

Author: elecharny
Date: Wed May 19 17:40:46 2010
New Revision: 946302

URL: http://svn.apache.org/viewvc?rev=946302&view=rev
Log:
o Removed the unused ParserPipedInputStream class
o Removed unused methods and test

Removed:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/ParserPipedInputStream.java
Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=946302&r1=946301&r2=946302&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java Wed May 19 17:40:46 2010
@@ -3395,89 +3395,6 @@ public class StringTools
 
 
     /**
-     * Decodes sequences of escaped hex within an attribute's value into 
-     * a UTF-8 String.  The hex is decoded inline and the complete decoded
-     * String is returned.
-     * 
-     * @param str the string containing hex escapes
-     * @return the decoded string
-     */
-    public static final String decodeEscapedHex( String str ) throws InvalidNameException
-    {
-        if ( str == null )
-        {
-            throw new InvalidNameException( I18n.err( I18n.ERR_04433 ) );
-        }
-        
-        int length = str.length();
-        
-        if ( length == 0 )
-        {
-            throw new InvalidNameException( I18n.err( I18n.ERR_04434 ) );
-        }
-        
-        // create buffer and add everything before start of scan
-        StringBuffer buf = new StringBuffer();
-        ByteBuffer bb = new ByteBuffer();
-        boolean escaped = false;
-        
-        // start scaning until we find an escaped series of bytes
-        for ( int ii = 0; ii < length; ii++ )
-        {
-            char c = str.charAt( ii );
-            
-            if ( !escaped && c == '\\' )
-            {
-                // we have the start of a hex escape sequence
-                if ( isHex( str, ii+1 ) && isHex ( str, ii+2 ) )
-                {
-                    bb.clear();
-                    int advancedBy = collectEscapedHexBytes( bb, str, ii );
-                    ii+=advancedBy-1;
-                    buf.append( StringTools.utf8ToString( bb.buffer(), bb.position() ) );
-                    escaped = false;
-                    continue;
-                }
-                else
-                {
-                    // It may be an escaped char ( ' ', '"', '#', '+', ',', ';', '<', '=', '>', '\' )
-                    escaped = true;
-                    continue;
-                }
-            }
-            
-            if ( escaped )
-            {
-                if ( DNUtils.isPairCharOnly( c ) )
-                {
-                    // It is an escaped char ( ' ', '"', '#', '+', ',', ';', '<', '=', '>', '\' )
-                    // Stores it into the buffer without the '\'
-                    escaped = false;
-                    buf.append( c );
-                    continue;
-                }
-                else
-                {
-                    throw new InvalidNameException( I18n.err( I18n.ERR_04435 ) );
-                }
-            }
-            else
-            {
-                buf.append( str.charAt( ii ) );
-            }
-        }
-        
-        if ( escaped )
-        {
-            // We should not have a '\' at the end of the string
-            throw new InvalidNameException( I18n.err( I18n.ERR_04436 ) );
-        }
-
-        return buf.toString();
-    }
-
-
-    /**
      * Convert an escaoed list of bytes to a byte[]
      * 
      * @param str the string containing hex escapes
@@ -3529,39 +3446,6 @@ public class StringTools
 
 
     /**
-     * Collects an hex sequence from a string, and returns the value
-     * as an integer, after having modified the initial value (the escaped
-     * hex value is transsformed to the byte it represents).
-     *
-     * @param bb the buffer which will contain the unescaped byte
-     * @param str the initial string with ecaped chars 
-     * @param index the position in the string of the escaped data
-     * @return the byte as an integer
-     */
-    public static int collectEscapedHexBytes( ByteBuffer bb, String str, int index )
-    {
-        int advanceBy = 0;
-        
-        for ( int ii = index; ii < str.length(); ii += 3, advanceBy += 3 )
-        {
-            // we have the start of a hex escape sequence
-            if ( ( str.charAt( ii ) == '\\' ) && isHex( str, ii+1 ) && isHex ( str, ii+2 ) )
-            {
-                int bite = ( StringTools.HEX_VALUE[str.charAt( ii+1 )] << 4 ) + 
-                    StringTools.HEX_VALUE[str.charAt( ii+2 )];
-                bb.append( bite );
-            }
-            else
-            {
-                break;
-            }
-        }
-        
-        return advanceBy;
-    }
-    
-    
-    /**
      * Thansform an array of ASCII bytes to a string. the byte array should contains
      * only values in [0, 127].
      * 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java?rev=946302&r1=946301&r2=946302&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/StringToolsTest.java Wed May 19 17:40:46 2010
@@ -47,29 +47,6 @@ import static org.junit.Assert.assertFal
 public class StringToolsTest
 {
     @Test
-    public void testDecodeEscapedHex() throws Exception
-    {
-        assertEquals( "Ferry", StringTools.decodeEscapedHex( "\\46\\65\\72\\72\\79" ) );
-        assertEquals( "Ferry", StringTools.decodeEscapedHex( "Fe\\72\\72\\79" ) );
-        assertEquals( "Ferry", StringTools.decodeEscapedHex( "Fe\\72\\72y" ) );
-        assertEquals( "Ferry", StringTools.decodeEscapedHex( "Fe\\72ry" ) );
-
-        assertEquals( "<DC", StringTools.decodeEscapedHex( "\\<DC" ) );
-        assertEquals( ">DC", StringTools.decodeEscapedHex( "\\>DC" ) );
-        assertEquals( "\"DC", StringTools.decodeEscapedHex( "\\\"DC" ) );
-        assertEquals( "+DC", StringTools.decodeEscapedHex( "\\+DC" ) );
-        assertEquals( ",DC", StringTools.decodeEscapedHex( "\\,DC" ) );
-        assertEquals( ";DC", StringTools.decodeEscapedHex( "\\;DC" ) );
-        assertEquals( "=DC", StringTools.decodeEscapedHex( "\\=DC" ) );
-        assertEquals( " DC", StringTools.decodeEscapedHex( "\\ DC" ) );
-        assertEquals( "#DC", StringTools.decodeEscapedHex( "\\#DC" ) );
-
-        // test a corner case: ESC ESC HEX HEX
-        assertEquals( "\\DC", StringTools.decodeEscapedHex( "\\5CDC" ) );
-        assertEquals( "\\DC", StringTools.decodeEscapedHex( "\\\\DC" ) );
-    }
-    
-    @Test
     public void testDecodeHexString() throws Exception
     {
         // weird stuff - corner cases