directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r209128 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/AddRequest.java
Date Mon, 04 Jul 2005 21:41:18 GMT
Author: elecharny
Date: Mon Jul  4 14:41:16 2005
New Revision: 209128

URL: http://svn.apache.org/viewcvs?rev=209128&view=rev
Log:
- added a toString() method
- polished the Javadoc
- added transient to every members that won't be serialized

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

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/AddRequest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/AddRequest.java?rev=209128&r1=209127&r2=209128&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/AddRequest.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/AddRequest.java
Mon Jul  4 14:41:16 2005
@@ -21,8 +21,11 @@
 import org.apache.asn1.ldap.codec.primitives.LdapString;
 import org.apache.asn1.primitives.OctetString;
 
+import org.apache.log4j.Logger;
+
 import java.util.ArrayList;
 
+import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.BasicAttribute;
 
@@ -43,16 +46,24 @@
  */
 public class AddRequest extends Asn1Object
 {
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private transient static final Logger log = Logger.getLogger( AddRequest.class );
+
+    /** Logging speed up  */
+    private transient static final boolean DEBUG = log.isDebugEnabled();
+
     //~ Instance fields ----------------------------------------------------------------------------
 
-    /** The DN to be modified. */
+    /** The DN to be added. */
     private LdapDN entry;
 
     /** The attributes list. */
     private ArrayList attributes;
 
     /** The current attribute being decoded */
-    private Attribute currentAttribute;
+    private transient Attribute currentAttribute;
 
     //~ Constructors -------------------------------------------------------------------------------
 
@@ -86,7 +97,8 @@
 
     /**
      * Create a new attributeValue
-     * @param type The attribute's name
+     * 
+     * @param type The attribute's name (called 'type' in the grammar) 
      */
     public void addAttributeType( LdapString type )
     {
@@ -96,7 +108,8 @@
 
     /**
      * Add a new value to the current attribute
-     * @param value
+     * 
+     * @param value The value to be added
      */
     public void addAttributeValue( OctetString value )
     {
@@ -105,6 +118,7 @@
 
     /**
      * Get the added DN
+     * 
      * @return Returns the entry.
      */
     public String getEntry()
@@ -114,10 +128,59 @@
 
     /**
      * Set the added DN.
+     * 
      * @param entry The entry to set.
      */
     public void setEntry( LdapDN entry )
     {
         this.entry = entry;
+    }
+
+    /**
+     * Return a String representing an AddRequest
+     * 
+     * @return A String representing the AddRequest
+    */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Add Request :\n" );
+        sb.append( "        Entry : '" ).append( entry.toString() ).append( "'\n" );
+
+        if ( attributes != null )
+        {
+            sb.append( "        Attributes : \n" );
+
+            for ( int i = 0; i < attributes.size(); i++ )
+            {
+
+                Attribute attribute = ( Attribute ) attributes.get( i );
+
+                sb.append( "           Type[" ).append( i ).append( "] : '" )
+                  .append( attribute.getID() ).append( "'\n" );
+
+                for ( int j = 0; j < attribute.size(); j++ )
+                {
+
+                    try
+                    {
+
+                        OctetString attributeValue = ( OctetString ) attribute.get( j );
+                        sb.append( "               Val[" ).append( j ).append( "] : " )
+                          .append( attributeValue.toString() ).append( " \n" );
+                    }
+                    catch ( NamingException ne )
+                    {
+                        log.error( "Naming exception will printing the '" + attribute.getID()
+
+                            "'" );
+                    }
+
+                }
+            }
+        }
+
+        return sb.toString();
     }
 }



Mime
View raw message