directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r224596 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java
Date Sun, 24 Jul 2005 09:56:57 GMT
Author: elecharny
Date: Sun Jul 24 02:56:54 2005
New Revision: 224596

URL: http://svn.apache.org/viewcvs?rev=224596&view=rev
Log:
- added a toString() method
- set some members transient

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java?rev=224596&r1=224595&r2=224596&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java
Sun Jul 24 02:56:54 2005
@@ -22,7 +22,10 @@
 import org.apache.asn1.primitives.OctetString;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.BasicAttribute;
 
@@ -58,10 +61,10 @@
     private ArrayList partialAttributeList;
 
     /** The attributes list expected length */
-    private transient int       partialAttributesListExpectedLength;
+    private transient int partialAttributesListExpectedLength;
 
     /** The current attribute being decoded */
-    private Attribute currentAttributeValue;
+    private transient Attribute currentAttributeValue;
 
     //~ Constructors -------------------------------------------------------------------------------
 
@@ -112,6 +115,7 @@
      */
     public void addPartialAttributeList()
     {
+
         if ( currentAttributeValue == null )
         {
             partialAttributeList = new ArrayList();
@@ -156,5 +160,69 @@
     public void addAttributeValue( OctetString value )
     {
         currentAttributeValue.add( value );
+    }
+
+    /**
+     * Returns the Search Result Entry string
+     *
+     * @return The Search Result Entry string 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Search Result Entry\n" );
+        sb.append( "        Object Name : '" ).append( objectName.toString() ).append( "'\n"
);
+        sb.append( "        Attributes\n" );
+
+        if ( ( partialAttributeList == null ) || ( partialAttributeList.size() == 0 ) )
+        {
+            sb.append( "            No attributes\n" );
+        }
+        else
+        {
+
+            Iterator attributesIter = partialAttributeList.iterator();
+
+            while ( attributesIter.hasNext() )
+            {
+
+                Attribute attribute = ( Attribute ) attributesIter.next();
+
+                sb.append( "            Name : '" ).append( attribute.getID() ).append( "'\n"
);
+
+                try
+                {
+
+                    NamingEnumeration values = attribute.getAll();
+
+                    if ( values.hasMoreElements() )
+                    {
+                        sb.append( "            Values\n" );
+
+                        while ( values.hasMore() )
+                        {
+
+                            OctetString value = ( OctetString ) values.next();
+
+                            sb.append( "                '" ).append( value.toString() ).append(
+                                "'\n" );
+                        }
+                    }
+                    else
+                    {
+                        sb.append( "            No Values\n" );
+
+                    }
+                }
+                catch ( NamingException ne )
+                {
+                    sb.append( "            Error while reading attribute.\n " );
+                }
+            }
+        }
+
+        return sb.toString();
     }
 }



Mime
View raw message