| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2012 ForgeRock AS. |
| | | * Portions copyright 2011-2014 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.getBytes; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_DN_TYPE_NOT_FOUND; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.SubstringReader; |
| | | |
| | | import static com.forgerock.opendj.ldap.CoreMessages.*; |
| | | import static com.forgerock.opendj.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * A distinguished name (DN) as defined in RFC 4512 section 2.3 is the |
| | | * concatenation of its relative distinguished name (RDN) and its immediate |
| | |
| | | if (dn2.isRootDN()) { |
| | | // both are equal. |
| | | return 0; |
| | | } else { |
| | | // dn1 comes before dn2. |
| | | return -1; |
| | | } |
| | | // dn1 comes before dn2. |
| | | return -1; |
| | | } |
| | | |
| | | if (dn2.isRootDN()) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(final DN dn) { |
| | | return compareTo(this, dn); |
| | | } |
| | |
| | | * |
| | | * @return An iterator of the RDNs contained in this DN. |
| | | */ |
| | | @Override |
| | | public Iterator<RDN> iterator() { |
| | | return new Iterator<RDN>() { |
| | | private DN dn = DN.this; |
| | | |
| | | @Override |
| | | public boolean hasNext() { |
| | | return dn.rdn != null; |
| | | } |
| | | |
| | | @Override |
| | | public RDN next() { |
| | | if (dn.rdn == null) { |
| | | throw new NoSuchElementException(); |
| | |
| | | return rdn; |
| | | } |
| | | |
| | | @Override |
| | | public void remove() { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | * @return The normalized string representation of the provided DN, not usable as a valid DN |
| | | */ |
| | | public ByteString toIrreversibleNormalizedByteString() { |
| | | final StringBuilder builder = new StringBuilder(size()); |
| | | if (rdn() == null) { |
| | | return ByteString.empty(); |
| | | } |
| | | |
| | | final StringBuilder builder = new StringBuilder(size()); |
| | | int i = size() - 1; |
| | | normalizeRDN(builder, parent(i).rdn()); |
| | | for (i--; i >= 0; i--) { |