directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r209133 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapResult.java
Date Mon, 04 Jul 2005 22:34:06 GMT
Author: elecharny
Date: Mon Jul  4 15:34:04 2005
New Revision: 209133

URL: http://svn.apache.org/viewcvs?rev=209133&view=rev
Log:
- Polished the javadoc
- Added a toString() method
- Changed referrals form a [] to an arrayList

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

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapResult.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapResult.java?rev=209133&r1=209132&r2=209133&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapResult.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/LdapResult.java
Mon Jul  4 15:34:04 2005
@@ -19,6 +19,9 @@
 import org.apache.asn1.Asn1Object;
 import org.apache.asn1.ldap.codec.primitives.LdapDN;
 import org.apache.asn1.ldap.codec.primitives.LdapString;
+import org.apache.asn1.ldap.codec.primitives.LdapURL;
+
+import java.util.ArrayList;
 
 
 /**
@@ -81,35 +84,30 @@
      */
     private int resultCode;
 
-    /** The DN that is mathed by the Bind */
+    /** The DN that is matched by the Bind */
     private LdapDN matchedDN;
 
-    /** The Bind error message, if any */
+    /** The error message */
     private LdapString errorMessage;
 
     /** The referrals, if any. This is an optional element */
-    private LdapString[] referrals;
-    
-    /** The number of referral */
-    private int nbReferral;
+    private ArrayList referrals;
 
     //~ Constructors -------------------------------------------------------------------------------
 
     /**
      * Creates a new BindResponse object.
-     * We will create a limited number of Referral objects.
      */
     public LdapResult()
     {
-        super( );
-        
-        nbReferral = 0;
-        referrals = new LdapString[10];
+        referrals = new ArrayList();
     }
 
     //~ Methods ------------------------------------------------------------------------------------
 
     /**
+     * Get the error message
+     *
      * @return Returns the errorMessage.
      */
     public String getErrorMessage()
@@ -118,6 +116,8 @@
     }
 
     /**
+     * Set the error message
+     *
      * @param errorMessage The errorMessage to set.
      */
     public void setErrorMessage( LdapString errorMessage )
@@ -126,6 +126,8 @@
     }
 
     /**
+     * Get the matched DN
+     *
      * @return Returns the matchedDN.
      */
     public String getMatchedDN()
@@ -135,6 +137,7 @@
 
     /**
      * Set the Matched DN
+     * 
      * @param matchedDN The matchedDN to set.
      */
     public void setMatchedDN( LdapDN matchedDN )
@@ -143,34 +146,28 @@
     }
 
     /**
-     * @return Returns the referral.
-     */
-    public LdapString[] getReferrals()
-    {
-        return referrals;
-    }
-
-    /**
-     * Set some referrals
+     * Get the referrals
      *
-     * @param referral The referral to set.
+     * @return Returns the referrals.
      */
-    public void setReferral( LdapString[] referrals )
+    public ArrayList getReferrals()
     {
-        this.referrals = referrals;
+        return referrals;
     }
 
     /**
-     * Add a referrals
+     * Add a referral
      *
      * @param referral The referral to add.
      */
-    public void addReferral( LdapString referral )
+    public void addReferral( LdapURL referral )
     {
-        this.referrals[nbReferral++] = referral;
+        referrals.add( referral );
     }
 
     /**
+     * Get the result code
+     *
      * @return Returns the resultCode.
      */
     public int getResultCode()
@@ -186,5 +183,278 @@
     public void setResultCode( int resultCode )
     {
         this.resultCode = resultCode;
+    }
+
+    /**
+     * Get a String representation of an AddResponse
+     *
+     * @return An AddResponse String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "        Ldap Result\n" );
+        sb.append( "            Result code : (" ).append( resultCode ).append( ')' );
+
+        switch ( resultCode )
+        {
+
+            case 0 :
+                sb.append( " success\n" );
+                break;
+
+            case 1 :
+                sb.append( " operationsError\n" );
+                break;
+
+            case 2 :
+                sb.append( " protocolError\n" );
+                break;
+
+            case 3 :
+                sb.append( " timeLimitExceeded\n" );
+                break;
+
+            case 4 :
+                sb.append( " sizeLimitExceeded\n" );
+                break;
+
+            case 5 :
+                sb.append( " compareFalse\n" );
+                break;
+
+            case 6 :
+                sb.append( " compareTrue\n" );
+                break;
+
+            case 7 :
+                sb.append( " authMethodNotSupported\n" );
+                break;
+
+            case 8 :
+                sb.append( " strongAuthRequired\n" );
+                break;
+
+            case 9 :
+                sb.append( " -- 9 reserved --\n" );
+                break;
+
+            case 10 :
+                sb.append( " referral -- new\n" );
+                break;
+
+            case 11 :
+                sb.append( " adminLimitExceeded -- new\n" );
+                break;
+
+            case 12 :
+                sb.append( " unavailableCriticalExtension -- new\n" );
+                break;
+
+            case 13 :
+                sb.append( " confidentialityRequired -- new\n" );
+                break;
+
+            case 14 :
+                sb.append( " saslBindInProgress -- new\n" );
+                break;
+
+            case 15 :
+                sb.append( " !! Unknow error code\n" );
+                break;
+
+            case 16 :
+                sb.append( " noSuchAttribute\n" );
+                break;
+
+            case 17 :
+                sb.append( " undefinedAttributeType\n" );
+                break;
+
+            case 18 :
+                sb.append( " inappropriateMatching\n" );
+                break;
+
+            case 19 :
+                sb.append( " constraintViolation\n" );
+                break;
+
+            case 20 :
+                sb.append( " attributeOrValueExists\n" );
+                break;
+
+            case 21 :
+                sb.append( " invalidAttributeSyntax\n" );
+                break;
+
+            case 22 :
+            case 23 :
+            case 24 :
+            case 25 :
+            case 26 :
+            case 27 :
+            case 28 :
+            case 29 :
+            case 30 :
+            case 31 :
+                sb.append( " -- 22-31 unused --\n" );
+                break;
+
+            case 32 :
+                sb.append( " noSuchObject\n" );
+                break;
+
+            case 33 :
+                sb.append( " aliasProblem\n" );
+                break;
+
+            case 34 :
+                sb.append( " invalidDNSyntax\n" );
+                break;
+
+            case 35 :
+                sb.append( " -- 35 reserved for undefined isLeaf --\n" );
+                break;
+
+            case 36 :
+                sb.append( " aliasDereferencingProblem\n" );
+                break;
+
+            case 37 :
+            case 38 :
+            case 39 :
+            case 40 :
+            case 41 :
+            case 42 :
+            case 43 :
+            case 44 :
+            case 45 :
+            case 46 :
+            case 47 :
+                sb.append( " -- 37-47 unused --\n" );
+                break;
+
+            case 48 :
+                sb.append( " inappropriateAuthentication\n" );
+                break;
+
+            case 49 :
+                sb.append( " invalidCredentials\n" );
+                break;
+
+            case 50 :
+                sb.append( " insufficientAccessRights\n" );
+                break;
+
+            case 51 :
+                sb.append( " busy\n" );
+                break;
+
+            case 52 :
+                sb.append( " unavailable\n" );
+                break;
+
+            case 53 :
+                sb.append( " unwillingToPerform\n" );
+                break;
+
+            case 54 :
+                sb.append( " loopDetect\n" );
+                break;
+
+            case 55 :
+            case 56 :
+            case 57 :
+            case 58 :
+            case 59 :
+            case 60 :
+            case 61 :
+            case 62 :
+            case 63 :
+                sb.append( " -- 55-63 unused --\n" );
+                break;
+
+            case 64 :
+                sb.append( " namingViolation\n" );
+                break;
+
+            case 65 :
+                sb.append( " objectClassViolation\n" );
+                break;
+
+            case 66 :
+                sb.append( " notAllowedOnNonLeaf\n" );
+                break;
+
+            case 67 :
+                sb.append( " notAllowedOnRDN\n" );
+                break;
+
+            case 68 :
+                sb.append( " entryAlreadyExists\n" );
+                break;
+
+            case 69 :
+                sb.append( " objectClassModsProhibited\n" );
+                break;
+
+            case 70 :
+                sb.append( " -- 70 reserved for CLDAP --\n" );
+                break;
+
+            case 71 :
+                sb.append( " affectsMultipleDSAs -- new\n" );
+                break;
+
+            case 72 :
+            case 73 :
+            case 74 :
+            case 75 :
+            case 76 :
+            case 77 :
+            case 78 :
+            case 79 :
+                sb.append( " -- 72-79 unused --\n" );
+                break;
+
+            case 80 :
+                sb.append( " other\n" );
+                break;
+
+            case 81 :
+            case 82 :
+            case 83 :
+            case 84 :
+            case 85 :
+            case 86 :
+            case 87 :
+            case 88 :
+            case 89 :
+            case 90 :
+                sb.append( " -- 81-90 reserved for APIs --" );
+                break;
+        }
+
+        sb.append( "            Matched DN : '" ).append( matchedDN.toString() ).append(
"'\n" );
+        sb.append( "            Error message : '" ).append( errorMessage.toString() ).append(
+            "'\n" );
+
+        if ( referrals.size() != 0 )
+        {
+            sb.append( "            Referrals :\n" );
+
+            for ( int i = 0; i < referrals.size(); i++ )
+            {
+
+                LdapURL referral = ( LdapURL ) referrals.get( i );
+
+                sb.append( "                Referral[" ).append( i ).append( "] :" )
+                  .append( referral.toString() ).append( '\n' );
+            }
+        }
+
+        return sb.toString();
     }
 }



Mime
View raw message