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
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2006-2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.types;
028
029
030
031 /**
032 * This enumeration defines the set of possible modification types
033 * that may be used for an attribute modification. This is based on
034 * the LDAP specification defined in RFC 2251.
035 */
036 @org.opends.server.types.PublicAPI(
037 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
038 mayInstantiate=false,
039 mayExtend=false,
040 mayInvoke=true)
041 public enum ModificationType
042 {
043 /**
044 * The modification type that indicates that the associated
045 * attribute values should be added to the entry.
046 */
047 ADD(0, "add"),
048
049
050
051 /**
052 * The modification type that indicates that the associated
053 * attribute or set of values should be removed from the entry.
054 */
055 DELETE(1, "delete"),
056
057
058
059 /**
060 * The modification type that indicates that the associated
061 * attribute should be used to replace any existing values for that
062 * attribute in the entry.
063 */
064 REPLACE(2, "replace"),
065
066
067
068 /**
069 * The modification type that indicates that the value of the
070 * associated attribute should be incremented by a specified amount
071 * as defined in RFC 4525.
072 */
073 INCREMENT(3, "increment");
074
075
076
077 // The integer value for this modification type.
078 private int intValue;
079
080 // The name of this modification type as it should appear in LDIF
081 // records.
082 private String ldifName;
083
084
085
086 /**
087 * Creates a new modification type with the provided integer value.
088 *
089 * @param intValue The integer value for this modification type.
090 * @param ldifName The name of this modification type as it should
091 * appear in LDIF records.
092 */
093 private ModificationType(int intValue, String ldifName)
094 {
095 this.intValue = intValue;
096 this.ldifName = ldifName;
097 }
098
099
100
101 /**
102 * Retrieves the integer value for this modification type.
103 *
104 * @return The integer value for this modification type.
105 */
106 public int intValue()
107 {
108 return intValue;
109 }
110
111
112
113 /**
114 * Retrieves the name of this modification type as it should appear
115 * in LDIF records.
116 *
117 * @return The name of this modification type as it should appear
118 * in LDIF records.
119 */
120 public String getLDIFName()
121 {
122 return ldifName;
123 }
124
125
126
127 /**
128 * Retrieves a string representation of this modification type.
129 *
130 * @return A string representation of this modification type.
131 */
132 public String toString()
133 {
134 switch (intValue)
135 {
136 case 0:
137 return "Add";
138 case 1:
139 return "Delete";
140 case 2:
141 return "Replace";
142 case 3:
143 return "Increment";
144 default:
145 return "Unknown";
146 }
147 }
148 }
149