From 0d5f5ba8ed70611b05aeef5bcd368b8bbe16b5e8 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 14 Sep 2012 21:49:26 +0000
Subject: [PATCH] Fix OPENDJ-592: Make it easier to create child DNs

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DN.java |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DN.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DN.java
index ef3f314..e2ed752 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DN.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DN.java
@@ -343,6 +343,29 @@
     }
 
     /**
+     * Returns a DN which is an immediate child of this DN and with an RDN
+     * having the provided attribute type and value decoded using the default
+     * schema.
+     * <p>
+     * If {@code attributeValue} is not an instance of {@code ByteString} then
+     * it will be converted using the {@link ByteString#valueOf(Object)} method.
+     *
+     * @param attributeType
+     *            The attribute type.
+     * @param attributeValue
+     *            The attribute value.
+     * @return The child DN.
+     * @throws UnknownSchemaElementException
+     *             If {@code attributeType} was not found in the default schema.
+     * @throws NullPointerException
+     *             If {@code attributeType} or {@code attributeValue} was
+     *             {@code null}.
+     */
+    public DN child(final String attributeType, final Object attributeValue) {
+        return child(new RDN(attributeType, attributeValue));
+    }
+
+    /**
      * {@inheritDoc}
      */
     public int compareTo(final DN dn) {

--
Gitblit v1.10.0