001 /* 002 * Copyright 2007-2014 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2008-2014 UnboundID Corp. 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021 package com.unboundid.ldap.sdk; 022 023 024 025 026 import static com.unboundid.util.StaticUtils.*; 027 028 029 030 /** 031 * This enum defines a set of change types that are associated with operations 032 * that may be processed in an LDAP directory server. The defined change types 033 * are "add", "delete", "modify", and "modify DN". 034 */ 035 public enum ChangeType 036 { 037 /** 038 * Indicates that the change type is for an add operation. 039 */ 040 ADD("add"), 041 042 043 044 /** 045 * Indicates that the change type is for a delete operation. 046 */ 047 DELETE("delete"), 048 049 050 051 /** 052 * Indicates that the change type is for a modify operation. 053 */ 054 MODIFY("modify"), 055 056 057 058 /** 059 * Indicates that the change type is for a modify DN operation. 060 */ 061 MODIFY_DN("moddn"); 062 063 064 065 // The human-readable name for this change type. 066 private final String name; 067 068 069 070 /** 071 * Creates a new change type with the specified name. 072 * 073 * @param name The human-readable name for this change type. 074 */ 075 private ChangeType(final String name) 076 { 077 this.name = name; 078 } 079 080 081 082 /** 083 * Retrieves the human-readable name for this change type. 084 * 085 * @return The human-readable name for this change type. 086 */ 087 public String getName() 088 { 089 return name; 090 } 091 092 093 094 /** 095 * Retrieves the change type with the specified name. 096 * 097 * @param name The name of the change type to retrieve. 098 * 099 * @return The requested change type, or {@code null} if no such change type 100 * is defined. 101 */ 102 public static ChangeType forName(final String name) 103 { 104 final String lowerName = toLowerCase(name); 105 if (lowerName.equals("add")) 106 { 107 return ADD; 108 } 109 else if (lowerName.equals("delete")) 110 { 111 return DELETE; 112 } 113 else if (lowerName.equals("modify")) 114 { 115 return MODIFY; 116 } 117 else if (lowerName.equals("moddn") || lowerName.equals("modrdn")) 118 { 119 return MODIFY_DN; 120 } 121 else 122 { 123 return null; 124 } 125 } 126 127 128 129 /** 130 * Retrieves a string representation for this change type. 131 * 132 * @return A string representation for this change type. 133 */ 134 @Override() 135 public String toString() 136 { 137 return name; 138 } 139 }