AddChangeRecordEntry.java revision 98e8aab354a385055392de7154758c1890a3265a
0N/A/*
0N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
0N/A * Common Development and Distribution License, Version 1.0 only
2362N/A * (the "License"). You may not use this file except in compliance
0N/A * with the License.
2362N/A *
0N/A * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
0N/A * or http://forgerock.org/license/CDDLv1.0.html.
0N/A * See the License for the specific language governing permissions
0N/A * and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
0N/A * file and include the License file at legal-notices/CDDLv1_0.txt.
0N/A * If applicable, add the following below this CDDL HEADER, with the
0N/A * fields enclosed by brackets "[]" replaced with your own identifying
0N/A * information:
0N/A * Portions Copyright [yyyy] [name of copyright owner]
2362N/A *
2362N/A * CDDL HEADER END
2362N/A *
0N/A *
0N/A * Copyright 2006-2008 Sun Microsystems, Inc.
0N/A * Portions Copyright 2014-2015 ForgeRock AS
0N/A */
0N/Apackage org.opends.server.util;
0N/A
0N/Aimport static org.forgerock.util.Reject.*;
0N/A
0N/Aimport java.util.ArrayList;
0N/Aimport java.util.Collections;
0N/Aimport java.util.Iterator;
0N/Aimport java.util.List;
0N/Aimport java.util.Map;
0N/A
0N/Aimport org.opends.server.types.Attribute;
0N/Aimport org.opends.server.types.AttributeType;
0N/Aimport org.opends.server.types.DN;
0N/A
0N/A
0N/A
0N/A/**
0N/A * This class defines a data structure for a change record entry for
0N/A * an add operation. It includes a DN and a set of attributes, as well as
0N/A * methods to decode the entry.
0N/A */
0N/A@org.opends.server.types.PublicAPI(
0N/A stability=org.opends.server.types.StabilityLevel.VOLATILE,
0N/A mayInstantiate=true,
0N/A mayExtend=false,
0N/A mayInvoke=true)
0N/Apublic final class AddChangeRecordEntry extends ChangeRecordEntry
0N/A{
0N/A
0N/A /**
0N/A * The entry attributes for this operation.
0N/A */
0N/A private final List<Attribute> attributes;
0N/A
0N/A
0N/A
0N/A /**
0N/A * Creates a new entry with the provided information.
0N/A *
0N/A * @param dn
0N/A * The distinguished name for this entry. It must not be
0N/A * <CODE>null</CODE>.
0N/A * @param attributes
0N/A * The entry attributes for this operation. It must not be
0N/A * <CODE>null</CODE>.
0N/A */
0N/A public AddChangeRecordEntry(DN dn,
0N/A Map<AttributeType,List<Attribute>> attributes)
0N/A {
0N/A super(dn);
0N/A
0N/A
0N/A ifNull(attributes);
0N/A
0N/A
0N/A this.attributes = new ArrayList<Attribute>(attributes.size());
0N/A for (List<Attribute> list : attributes.values())
0N/A {
0N/A this.attributes.addAll(list);
0N/A }
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Retrieves the name of the change operation type.
0N/A *
0N/A * @return The name of the change operation type.
0N/A */
0N/A public ChangeOperationType getChangeOperationType()
0N/A {
0N/A return ChangeOperationType.ADD;
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Retrieves the entire set of attributes for this entry.
0N/A * <p>
0N/A * The returned list is read-only.
0N/A *
0N/A * @return The entire unmodifiable list of attributes for this entry.
0N/A */
0N/A public List<Attribute> getAttributes()
0N/A {
0N/A return Collections.unmodifiableList(attributes);
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A @Override
0N/A public String toString()
0N/A {
0N/A StringBuilder buffer = new StringBuilder();
0N/A buffer.append("AddChangeRecordEntry(dn=\"");
0N/A buffer.append(String.valueOf(getDN()));
0N/A buffer.append("\", attrs={");
0N/A
0N/A Iterator<Attribute> iterator = attributes.iterator();
0N/A while (iterator.hasNext())
0N/A {
0N/A buffer.append(iterator.next().getName());
0N/A if (iterator.hasNext())
0N/A {
0N/A buffer.append(", ");
0N/A }
0N/A }
0N/A buffer.append("})");
0N/A
0N/A return buffer.toString();
0N/A }
0N/A}
0N/A
0N/A