From 0b75361593e78cb6a83d7f763080b36a60e3eb79 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 07 Mar 2016 15:13:46 +0000
Subject: [PATCH] OPENDJ-1342 Migrate AVA, RDN, and DN classes: Moved DN2ID.isChild() to DNKeyFormat

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java |   33 +--------------------------------
 1 files changed, 1 insertions(+), 32 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
index b2d3afe..22e45d3 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2ID.java
@@ -192,37 +192,6 @@
     }
   }
 
-  /**
-   * Check if two DN have a parent-child relationship.
-   *
-   * @param parent
-   *          The potential parent
-   * @param child
-   *          The potential child of parent
-   * @return true if child is a direct children of parent, false otherwise.
-   */
-  static boolean isChild(ByteSequence parent, ByteSequence child)
-  {
-    if (!child.startsWith(parent))
-    {
-      return false;
-    }
-    // Immediate children should only have one RDN separator past the parent length
-    int nbSeparator = 0;
-    for (int i = parent.length() ; i < child.length(); i++)
-    {
-      if (child.byteAt(i) == DnKeyFormat.NORMALIZED_RDN_SEPARATOR)
-      {
-        nbSeparator++;
-        if (nbSeparator > 1)
-        {
-          return false;
-        }
-      }
-    }
-    return nbSeparator == 1;
-  }
-
   @Override
   public String keyToString(ByteString key)
   {
@@ -378,7 +347,7 @@
     private void popCompleteParents(ByteString dn)
     {
       ParentInfo<V> currentParent;
-      while ((currentParent = parentsInfoStack.peek()) != null && !isChild(currentParent.parentDN, dn))
+      while ((currentParent = parentsInfoStack.peek()) != null && !DnKeyFormat.isChild(currentParent.parentDN, dn))
       {
         visitor.endParent(parentsInfoStack.pop().visitorData);
       }

--
Gitblit v1.10.0