From 31ea71e61ed556a6aa2bcdfb0aa5d827a29b78d7 Mon Sep 17 00:00:00 2001 From: Mattias Hellborg Arthursson Date: Fri, 30 Aug 2013 12:45:43 +0200 Subject: [PATCH] LDAP-258: Added a couple of construction methods to LdapNameBuilder --- .../ldap/support/LdapNameBuilder.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/support/LdapNameBuilder.java b/core/src/main/java/org/springframework/ldap/support/LdapNameBuilder.java index abec24c1..461361e6 100644 --- a/core/src/main/java/org/springframework/ldap/support/LdapNameBuilder.java +++ b/core/src/main/java/org/springframework/ldap/support/LdapNameBuilder.java @@ -19,6 +19,7 @@ package org.springframework.ldap.support; import org.springframework.util.Assert; import javax.naming.InvalidNameException; +import javax.naming.Name; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; @@ -30,14 +31,39 @@ import javax.naming.ldap.Rdn; */ public class LdapNameBuilder { - private final LdapName ldapName = LdapUtils.emptyLdapName(); - - private LdapNameBuilder() { + private final LdapName ldapName; + private LdapNameBuilder(LdapName ldapName) { + this.ldapName = ldapName; } + /** + * Construct a new instance, starting with a blank LdapName. + * + * @return a new instance. + */ public static LdapNameBuilder newInstance() { - return new LdapNameBuilder(); + return new LdapNameBuilder(LdapUtils.emptyLdapName()); + } + + /** + * Construct a new instance, starting with a copy of the supplied LdapName. + * @param name the starting point of the LdapName to be built. + * + * @return a new instance. + */ + public static LdapNameBuilder newInstance(Name name) { + return new LdapNameBuilder(LdapUtils.newLdapName(name)); + } + + /** + * Construct a new instance, starting with an LdapName constructed from the supplied string. + * @param name the starting point of the LdapName to be built. + * + * @return a new instance. + */ + public static LdapNameBuilder newInstance(String name) { + return new LdapNameBuilder(LdapUtils.newLdapName(name)); } /**