directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r531197 - /directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/DN.java
Date Sun, 22 Apr 2007 15:15:07 GMT
Author: seelmann
Date: Sun Apr 22 08:15:06 2007
New Revision: 531197

URL: http://svn.apache.org/viewvc?view=rev&rev=531197
Log:
Added local name support.

Modified:
    directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/DN.java

Modified: directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/DN.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/DN.java?view=diff&rev=531197&r1=531196&r2=531197
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/DN.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-browser-core/src/main/java/org/apache/directory/ldapstudio/browser/core/model/DN.java
Sun Apr 22 08:15:06 2007
@@ -139,6 +139,36 @@
 
 
     /**
+     * Creates a new instance of DN using the given local name and suffix.
+     * The given local name and suffix are cloned.
+     *
+     * @param localName the local name
+     * @param suffix the suffix
+     */
+    public DN( DN localName, DN suffix )
+    {
+        if ( localName == null )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_dn );
+        }
+        if ( suffix == null )
+        {
+            throw new IllegalArgumentException( BrowserCoreMessages.model__empty_dn );
+        }
+
+        this.rdns = new RDN[localName.getRdns().length + suffix.getRdns().length];
+        for ( int i = 0; i < localName.getRdns().length; i++ )
+        {
+            this.rdns[i] = new RDN( localName.getRdns()[i] );
+        }
+        for ( int i = 0; i < suffix.getRdns().length; i++ )
+        {
+            this.rdns[i + localName.getRdns().length] = new RDN( suffix.getRdns()[i] );
+        }
+    }
+
+
+    /**
      * Creates a new instance of DN. The given strings are parsed.
      *
      * @param rdn the rdn
@@ -206,6 +236,32 @@
             DN parent = new DN();
             parent.rdns = parentRdns;
             return parent;
+        }
+    }
+
+
+    /**
+     * Extracts the local name by stripping the given
+     * suffix from this DN.
+     *
+     * @param suffix the suffix to strip
+     *
+     * @return the local name
+     */
+    public DN getLocalName( DN suffix )
+    {
+        if ( suffix != null && suffix.getRdns().length > 0 )
+        {
+            DN localName = new DN();
+            for ( int i = getRdns().length - suffix.getRdns().length - 1; i >= 0; i--
)
+            {
+                localName = new DN( getRdns()[i], localName );
+            }
+            return localName;
+        }
+        else
+        {
+            return this;
         }
     }
 



Mime
View raw message