From 56274dff0f872d02abb69608f6d98fa087c8e6f2 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 15 Feb 2007 00:21:49 +0000
Subject: [PATCH] Rewrite the DN and RDN code for significant performance improvements, especially in the area of DN parsing.

---
 opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/TemplateEntry.java |   45 +++++++++++++++++++++++++++++++++------------
 1 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/TemplateEntry.java b/opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/TemplateEntry.java
index fa4c9be..18ebd2e 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/TemplateEntry.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/TemplateEntry.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
  */
 package org.opends.server.tools.makeldif;
 
@@ -148,29 +148,50 @@
 
 
   /**
-   * Retrieves teh DN for this template entry, if it is known.
+   * Retrieves the DN for this template entry, if it is known.
    *
    * @return  The DN for this template entry if it is known, or
    *          <CODE>null</CODE> if it cannot yet be determined.
    */
   public DN getDN()
   {
-    if (dn == null) {
-      RDN.Builder builder = RDN.createBuilder();
-
-      for (AttributeType type : template.getRDNAttributes()) {
-        TemplateValue v = getValue(type);
-        if (v == null) {
+    if (dn == null)
+    {
+      RDN rdn;
+      AttributeType[] rdnAttrs = template.getRDNAttributes();
+      if (rdnAttrs.length == 1)
+      {
+        AttributeType t = rdnAttrs[0];
+        TemplateValue v = getValue(t);
+        if (v == null)
+        {
           return null;
         }
 
-        AttributeValue value = new AttributeValue(type,
-            v.getValue().toString());
+        AttributeValue value = new AttributeValue(t, v.getValue().toString());
+        rdn = new RDN(t, value);
+      }
+      else
+      {
+        String[]         names  = new String[rdnAttrs.length];
+        AttributeValue[] values = new AttributeValue[rdnAttrs.length];
+        for (int i=0; i < rdnAttrs.length; i++)
+        {
+          AttributeType t = rdnAttrs[i];
+          TemplateValue v = getValue(t);
+          if (v == null)
+          {
+            return null;
+          }
 
-        builder.append(type, value);
+          names[i]  = t.getPrimaryName();
+          values[i] = new AttributeValue(t, v.getValue().toString());
+        }
+
+        rdn = new RDN(rdnAttrs, names, values);
       }
 
-      dn = parentDN.concat(builder.getInstance());
+      dn = parentDN.concat(rdn);
     }
 
     return dn;

--
Gitblit v1.10.0