directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r693837 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
Date Wed, 10 Sep 2008 13:21:15 GMT
Author: pamarcelot
Date: Wed Sep 10 06:21:14 2008
New Revision: 693837

URL: http://svn.apache.org/viewvc?rev=693837&view=rev
Log:
Added a toAttribute(...) method.

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?rev=693837&r1=693836&r2=693837&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
Wed Sep 10 06:21:14 2008
@@ -1220,20 +1220,44 @@
      * Converts an {@link Entry} to an {@link Attributes}.
      *
      * @param entry
-     *      the entry to convert
+     *      the {@link Entry} to convert
      * @return
      *      the equivalent {@link Attributes}
      */
     public static Attributes toAttributes( Entry entry )
     {
-        Attributes attributes = new BasicAttributes();
+        if ( entry != null )
+        {
+            Attributes attributes = new BasicAttributes();
+
+            // Looping on attributes
+            for ( Iterator<EntryAttribute> attributeIterator = entry.iterator(); attributeIterator.hasNext();
)
+            {
+                EntryAttribute entryAttribute = ( EntryAttribute ) attributeIterator.next();
+
+                attributes.put( toAttribute( entryAttribute ) );
+            }
+
+            return attributes;
+        }
+
+        return null;
+    }
+
 
-        // Looping on attributes
-        for ( Iterator<EntryAttribute> attributeIterator = entry.iterator(); attributeIterator.hasNext();
)
+    /**
+     * Converts an {@link EntryAttribute} to an {@link Attribute}.
+     *
+     * @param entryAttribute
+     *      the {@link EntryAttribute} to convert
+     * @return
+     *      the equivalent {@link Attribute}
+     */
+    public static Attribute toAttribute( EntryAttribute entryAttribute )
+    {
+        if ( entryAttribute != null )
         {
-            EntryAttribute entryAttribute = ( EntryAttribute ) attributeIterator.next();
             Attribute attribute = new BasicAttribute( entryAttribute.getId() );
-            attributes.put( attribute );
 
             // Looping on values
             for ( Iterator<Value<?>> valueIterator = entryAttribute.iterator();
valueIterator.hasNext(); )
@@ -1241,9 +1265,11 @@
                 Value<?> value = ( Value<?> ) valueIterator.next();
                 attribute.add( value.get() );
             }
+
+            return attribute;
         }
 
-        return attributes;
+        return null;
     }
 
 



Mime
View raw message