001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
005 *
006 * The contents of this file are subject to the terms
007 * of the Common Development and Distribution License
008 * (the License). You may not use this file except in
009 * compliance with the License.
010 *
011 * You can obtain a copy of the License at
012 * https://opensso.dev.java.net/public/CDDLv1.0.html or
013 * opensso/legal/CDDLv1.0.txt
014 * See the License for the specific language governing
015 * permission and limitations under the License.
016 *
017 * When distributing Covered Code, include this CDDL
018 * Header Notice in each file and include the License file
019 * at opensso/legal/CDDLv1.0.txt.
020 * If applicable, add the following below the CDDL Header,
021 * with the fields enclosed by brackets [] replaced by
022 * your own identifying information:
023 * "Portions Copyrighted [year] [name of copyright owner]"
024 *
025 * $Id: ModSet.java,v 1.4 2009/01/28 05:34:49 ww203982 Exp $
026 *
027 */
028
029package com.iplanet.services.ldap;
030
031import com.sun.identity.shared.ldap.LDAPModification;
032import com.sun.identity.shared.ldap.LDAPModificationSet;
033
034/**
035 * Represents a set of modification on attributes
036 * @supported.api
037 */
038public class ModSet extends LDAPModificationSet {
039    // TODO: This is an incomplete implementation. Currently subclass from
040    // LDAPModificationSet is used to get things going. Need internal
041    // representation overhaul to move away from "extends LDAPModification"
042
043    /**
044     * Modification specifiers for ADD
045     */
046    public static final int ADD = LDAPModification.ADD;
047
048    /**
049     * Modification specifiers for REPLACE
050     */
051    public static final int REPLACE = LDAPModification.REPLACE;
052
053    /**
054     * Modification specifiers for DELETE
055     */
056    public static final int DELETE = LDAPModification.DELETE;
057
058    /**
059     * Default consturctor
060     */
061    public ModSet() {
062        super();
063    }
064
065    /**
066     * Constructor with an attribute set defaulting all operation types to
067     * ModSet.ADD
068     * 
069     * @param attrSet
070     *            Attribute set to construct the modSet. All operations are
071     *            default to ModSet.ADD
072     */
073    public ModSet(AttrSet attrSet) {
074        this(attrSet, ModSet.ADD);
075    }
076
077    /**
078     * Construct ModSet given the same operation on a set of attributes
079     * 
080     * @param attrSet
081     *            Attribute set to construct the ModSet
082     * @param op
083     *            Operation type for ADD, REPLACE or DELETE
084     */
085    public ModSet(AttrSet attrSet, int op) {
086
087        super();
088        for (int i = 0; i < attrSet.size(); i++) {
089            this.add(op, attrSet.elementAt(i).toLDAPAttribute());
090        }
091    }
092}