directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1743011 [13/13] - in /directory/shared/branches/shared-value: dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/ dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/response/ dsml/parser/src/test/java/org/apache/direc...
Date Mon, 09 May 2016 17:22:21 GMT
Modified: directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerLoadWithDepsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerLoadWithDepsTest.java?rev=1743011&r1=1743010&r2=1743011&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerLoadWithDepsTest.java
(original)
+++ directory/shared/branches/shared-value/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerLoadWithDepsTest.java
Mon May  9 17:22:19 2016
@@ -121,7 +121,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 38, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 35, schemaManager.getComparatorRegistry().size() );
         assertEquals( 35, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 9, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 59, schemaManager.getLdapSyntaxRegistry().size() );
@@ -147,7 +147,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 92, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 36, schemaManager.getComparatorRegistry().size() );
         assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 36, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
@@ -174,7 +174,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 148, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 44, schemaManager.getComparatorRegistry().size() );
         assertEquals( 50, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 43, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 42, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 53, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 62, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 73, schemaManager.getLdapSyntaxRegistry().size() );
@@ -202,7 +202,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 71, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 40, schemaManager.getComparatorRegistry().size() );
         assertEquals( 40, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 40, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 39, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 22, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 63, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 64, schemaManager.getLdapSyntaxRegistry().size() );
@@ -229,7 +229,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 99, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 36, schemaManager.getComparatorRegistry().size() );
         assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 41, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
@@ -258,7 +258,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 181, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 49, schemaManager.getComparatorRegistry().size() );
         assertEquals( 55, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 48, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 47, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 66, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 66, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 78, schemaManager.getLdapSyntaxRegistry().size() );
@@ -288,7 +288,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 133, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 36, schemaManager.getComparatorRegistry().size() );
         assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 49, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
@@ -317,7 +317,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 142, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 36, schemaManager.getComparatorRegistry().size() );
         assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 50, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
@@ -346,7 +346,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 105, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 36, schemaManager.getComparatorRegistry().size() );
         assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 36, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
@@ -374,7 +374,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 107, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 36, schemaManager.getComparatorRegistry().size() );
         assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 39, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
@@ -493,7 +493,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 142, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 36, schemaManager.getComparatorRegistry().size() );
         assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 50, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
@@ -560,7 +560,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 142, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 36, schemaManager.getComparatorRegistry().size() );
         assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 50, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
@@ -595,7 +595,7 @@ public class SchemaManagerLoadWithDepsTe
         assertEquals( 142, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( 36, schemaManager.getComparatorRegistry().size() );
         assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
-        assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
+        assertEquals( 34, schemaManager.getNormalizerRegistry().size() );
         assertEquals( 50, schemaManager.getObjectClassRegistry().size() );
         assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
         assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );

Copied: directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/ExpansibleByteBuffer.java
(from r1736388, directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/ExpansibleByteBuffer.java?p2=directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/ExpansibleByteBuffer.java&p1=directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java&r1=1736388&r2=1743011&rev=1743011&view=diff
==============================================================================
--- directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/ByteBuffer.java
(original)
+++ directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/ExpansibleByteBuffer.java
Mon May  9 17:22:19 2016
@@ -28,7 +28,7 @@ import org.apache.directory.api.i18n.I18
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ByteBuffer
+public class ExpansibleByteBuffer
 {
     /** the default initial buffer size */
     private static final int DEFAULT_INITIAL_SIZE = 10;
@@ -43,13 +43,13 @@ public class ByteBuffer
     private byte[] buf;
 
 
-    public ByteBuffer()
+    public ExpansibleByteBuffer()
     {
         this( DEFAULT_INITIAL_SIZE );
     }
 
 
-    public ByteBuffer( int initialSize )
+    public ExpansibleByteBuffer( int initialSize )
     {
         if ( initialSize <= 0 )
         {
@@ -67,12 +67,26 @@ public class ByteBuffer
     }
 
 
+    /**
+     * @return The position of the last byte in the buffer
+     */
     public final int position()
     {
         return pos;
     }
 
 
+    /**
+     * Set the position to a specific value
+     * 
+     * @param pos the new position
+     */
+    public final void position( int pos )
+    {
+        this.pos = pos;
+    }
+
+
     public final int capacity()
     {
         return buf.length;

Modified: directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/Strings.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/Strings.java?rev=1743011&r1=1743010&r2=1743011&view=diff
==============================================================================
--- directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/Strings.java
(original)
+++ directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/Strings.java
Mon May  9 17:22:19 2016
@@ -51,7 +51,7 @@ public final class Strings
     private static final Logger LOG = LoggerFactory.getLogger( Strings.class );
 
     /** Hex chars */
-    private static final byte[] HEX_CHAR = new byte[]
+    public static final byte[] HEX_CHAR = new byte[]
         { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
 
     /** A table containing booleans when the corresponding char is printable */
@@ -249,6 +249,19 @@ public final class Strings
 
 
     /**
+     * Helper function that dump a byte as a double digit value
+     *
+     * @param b The byte to dump
+     * @return A string representation of byte as a string
+     */
+    public static String byteToString( byte b )
+    {
+        return Strings.utf8ToString( new byte[]
+            { HEX_CHAR[( b & 0x00F0 ) >> 4], HEX_CHAR[b & 0x000F] } );
+    }
+
+
+    /**
      * Helper function that dump a byte in hex form
      *
      * @param octet The byte to dump
@@ -665,7 +678,30 @@ public final class Strings
         }
         else
         {
-            return ( ( byteArray[index] == car ) ? true : false );
+            return ( byteArray[index] == car );
+        }
+    }
+
+
+    /**
+     * Test if the current character is equal to a specific character. This
+     * function works only for character between 0 and 127, as it does compare a
+     * byte and a char (which is 16 bits wide)
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param car The character we want to compare with the current buffer position
+     * @return <code>true</code> if the current character equals the given character.
+     */
+    public static boolean isCharASCII( char[] charArray, int index, char car )
+    {
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) || (
index >= charArray.length ) )
+        {
+            return false;
+        }
+        else
+        {
+            return ( charArray[index] == car );
         }
     }
 

Modified: directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/Unicode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/Unicode.java?rev=1743011&r1=1743010&r2=1743011&view=diff
==============================================================================
--- directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/Unicode.java
(original)
+++ directory/shared/branches/shared-value/util/src/main/java/org/apache/directory/api/util/Unicode.java
Mon May  9 17:22:19 2016
@@ -73,8 +73,6 @@ public final class Unicode
     private static final int CHAR_TWO_BYTES_MASK = 0xFFFFF800;
     private static final int CHAR_THREE_BYTES_MASK = 0xFFFF0000;
     private static final int CHAR_FOUR_BYTES_MASK = 0xFFE00000;
-    private static final int CHAR_FIVE_BYTES_MASK = 0xFC000000;
-    private static final int CHAR_SIX_BYTES_MASK = 0x80000000;
 
     /**
      * Count the number of bytes needed to return an Unicode char. This can be
@@ -252,14 +250,6 @@ public final class Unicode
         {
             return 4;
         }
-        else if ( ( car & CHAR_FIVE_BYTES_MASK ) == 0 )
-        {
-            return 5;
-        }
-        else if ( ( car & CHAR_SIX_BYTES_MASK ) == 0 )
-        {
-            return 6;
-        }
         else
         {
             return -1;
@@ -335,29 +325,36 @@ public final class Unicode
      */
     public static byte[] charToBytes( char car )
     {
-        byte[] bytes = new byte[countNbBytesPerChar( car )];
-
-        if ( car <= 0x7F )
+        if ( car <= 0x007F )
         {
+            byte[] bytes = new byte[1];
+
             // Single byte char
             bytes[0] = ( byte ) car;
+            
             return bytes;
         }
-        else if ( car <= 0x7FF )
+        else if ( car <= 0x07FF )
         {
+            byte[] bytes = new byte[2];
+
             // two bytes char
             bytes[0] = ( byte ) ( 0x00C0 + ( ( car & 0x07C0 ) >> 6 ) );
             bytes[1] = ( byte ) ( 0x0080 + ( car & 0x3F ) );
+            
+            return bytes;
         }
         else
         {
+            byte[] bytes = new byte[3];
+
             // Three bytes char
             bytes[0] = ( byte ) ( 0x00E0 + ( ( car & 0xF000 ) >> 12 ) );
             bytes[1] = ( byte ) ( 0x0080 + ( ( car & 0x0FC0 ) >> 6 ) );
             bytes[2] = ( byte ) ( 0x0080 + ( car & 0x3F ) );
+            
+            return bytes;
         }
-
-        return bytes;
     }
 
 

Modified: directory/shared/branches/shared-value/util/src/test/java/org/apache/directory/api/util/ByteBufferTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/util/src/test/java/org/apache/directory/api/util/ByteBufferTest.java?rev=1743011&r1=1743010&r2=1743011&view=diff
==============================================================================
--- directory/shared/branches/shared-value/util/src/test/java/org/apache/directory/api/util/ByteBufferTest.java
(original)
+++ directory/shared/branches/shared-value/util/src/test/java/org/apache/directory/api/util/ByteBufferTest.java
Mon May  9 17:22:19 2016
@@ -41,7 +41,7 @@ public class ByteBufferTest
     @Test
     public void testByteBufferGrowth()
     {
-        ByteBuffer buf = new ByteBuffer();
+        ExpansibleByteBuffer buf = new ExpansibleByteBuffer();
         assertEquals( 10, buf.capacity() );
 
         for ( int ii = 0; ii < 20; ii++ )
@@ -57,7 +57,7 @@ public class ByteBufferTest
 
         // -------------------------------------------------------------------
 
-        buf = new ByteBuffer( 5 );
+        buf = new ExpansibleByteBuffer( 5 );
         assertEquals( 5, buf.capacity() );
 
         for ( int ii = 0; ii < 5; ii++ )
@@ -76,7 +76,7 @@ public class ByteBufferTest
     @Test
     public void testCopyOfUsedBytes()
     {
-        ByteBuffer buf = new ByteBuffer();
+        ExpansibleByteBuffer buf = new ExpansibleByteBuffer();
         byte[] bytes = buf.copyOfUsedBytes();
         assertEquals( 0, bytes.length );
 
@@ -93,7 +93,7 @@ public class ByteBufferTest
     @Test
     public void testAppendByteArray()
     {
-        ByteBuffer buf = new ByteBuffer();
+        ExpansibleByteBuffer buf = new ExpansibleByteBuffer();
         buf.append( new byte[]
             { 0, 1, 2, 3, 4 } );
         for ( int ii = 0; ii < 5; ii++ )



Mime
View raw message