001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2006-2008 Sun Microsystems, Inc.
025 */
026package org.opends.server.util;
027
028/**
029 * This enumeration defines the set of possible change types.
030 */
031@org.opends.server.types.PublicAPI(
032     stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
033     mayInstantiate=false,
034     mayExtend=false,
035     mayInvoke=true)
036public enum ChangeOperationType
037{
038  /** The change type for add operations. */
039  ADD("ADD", "add"),
040
041  /** The change type for delete operations. */
042  DELETE("DELETE", "delete"),
043
044  /** The change type for modify operations. */
045  MODIFY("MODIFY", "modify"),
046
047  /** The change type for modify DN operations. */
048  MODIFY_DN("MODIFY_DN", "moddn");
049
050
051
052  /**
053   * The name of this change type as it should appear in the "changetype" field
054   * in LDIF records.
055   */
056  private String ldifChangeType;
057
058  /** The user-friendly name given to this change type. */
059  private String type;
060
061  /**
062   * Creates a change type with the given string value.
063   *
064   * @param  type            The string value for this change type.
065   * @param  ldifChangeType  The change type as it should appear in the
066   *                         "changetype" field in LDIF records.
067   */
068  private ChangeOperationType(String type, String ldifChangeType)
069  {
070    this.type           = type;
071    this.ldifChangeType = ldifChangeType;
072  }
073
074
075  /**
076   * Retrieves the human-readable name this change type.
077   *
078   * @return  The human-readable name for this change type.
079   */
080  public String getType()
081  {
082    return type;
083  }
084
085
086  /**
087   * Retrieves the name of the change type as it should appear in LDIF
088   * "changetype" records.
089   *
090   * @return  The name of the change type as it should appear in LDIF
091   *          "changetype" records.
092   */
093  public String getLDIFChangeType()
094  {
095    return ldifChangeType;
096  }
097
098
099  /**
100   * Retrieves a string representation of this type.
101   *
102   * @return  A string representation of this type.
103   */
104  @Override
105  public String toString()
106  {
107    return type;
108  }
109}
110