directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1393267 - /directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java
Date Wed, 03 Oct 2012 03:07:39 GMT
Author: elecharny
Date: Wed Oct  3 03:07:38 2012
New Revision: 1393267

URL: http://svn.apache.org/viewvc?rev=1393267&view=rev
Log:
Added a hekper method to extract a String value from a Binary value

Modified:
    directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java

Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java?rev=1393267&r1=1393266&r2=1393267&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/SchemaEntityFactory.java
Wed Oct  3 03:07:38 2012
@@ -1045,6 +1045,25 @@ public class SchemaEntityFactory impleme
 
 
     /**
+     * Return a String value, from teh given Valu, even if it's a binary value
+     */
+    private String getStringValue( Attribute attribute )
+    {
+        Value<?> value = attribute.get();
+
+        if ( value instanceof BinaryValue )
+        {
+            // We have to transform the value to a String
+            return Strings.utf8ToString( value.getBytes() );
+        }
+        else
+        {
+            return value.getString();
+        }
+    }
+
+
+    /**
      * Process the common attributes to all SchemaObjects :
      *  - obsolete
      *  - description
@@ -1073,17 +1092,7 @@ public class SchemaEntityFactory impleme
 
         if ( mDescription != null )
         {
-            Value<?> value = mDescription.get();
-
-            if ( value instanceof BinaryValue )
-            {
-                // We have to transform the value to a String
-                schemaObject.setDescription( Strings.utf8ToString( mDescription.getBytes()
) );
-            }
-            else
-            {
-                schemaObject.setDescription( mDescription.getString() );
-            }
+            schemaObject.setDescription( getStringValue( mDescription ) );
         }
 
         // The names field



Mime
View raw message