001/* 002 * Copyright 2008-2019 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2008-2019 Ping Identity Corporation 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 */ 021package com.unboundid.util; 022 023 024 025/** 026 * This enumeration defines a set of debugging types that are used by the LDAP 027 * SDK. 028 */ 029@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 030public enum DebugType 031{ 032 /** 033 * The debug type that will be used for debugging information about ASN.1 034 * elements written to or read from a directory server. 035 */ 036 ASN1("asn1"), 037 038 039 040 /** 041 * The debug type that will be used for debugging information about 042 * connection establishment and termination. 043 */ 044 CONNECT("connect"), 045 046 047 048 /** 049 * The debug type that will be used for debugging information about 050 * exceptions that are caught. 051 */ 052 EXCEPTION("exception"), 053 054 055 056 /** 057 * The debug type that will be used for debugging information about LDAP 058 * requests sent to or received from a directory server. 059 */ 060 LDAP("ldap"), 061 062 063 064 /** 065 * The debug type that will be used for information about connection pool 066 * interaction. 067 */ 068 CONNECTION_POOL("connection-pool"), 069 070 071 072 /** 073 * The debug type that will be used for debugging information about LDIF 074 * entries or change records read or written. 075 */ 076 LDIF("ldif"), 077 078 079 080 /** 081 * The debug type that will be used for information about monitor entry 082 * parsing. 083 */ 084 MONITOR("monitor"), 085 086 087 088 /** 089 * The debug type that will be used for information about coding errors or 090 * other types of incorrect uses of the LDAP SDK. 091 */ 092 CODING_ERROR("coding-error"), 093 094 095 096 /** 097 * The debug type that will be used for debug messages not applicable to any 098 * of the other categories. 099 */ 100 OTHER("other"); 101 102 103 104 // The name for this debug type. 105 private final String name; 106 107 108 109 /** 110 * Creates a new debug type with the specified name. 111 * 112 * @param name The name for this debug type. It should be in all lowercase 113 * characters. 114 */ 115 DebugType(final String name) 116 { 117 this.name = name; 118 } 119 120 121 122 /** 123 * Retrieves the name for this debug type. 124 * 125 * @return The name for this debug type. 126 */ 127 public String getName() 128 { 129 return name; 130 } 131 132 133 134 /** 135 * Retrieves the debug type with the specified name. 136 * 137 * @param name The name of the debug type to retrieve. It must not be 138 * {@code null}. 139 * 140 * @return The requested debug type, or {@code null} if there is no such 141 * debug type. 142 */ 143 public static DebugType forName(final String name) 144 { 145 switch (StaticUtils.toLowerCase(name)) 146 { 147 case "asn1": 148 return ASN1; 149 case "connect": 150 return CONNECT; 151 case "exception": 152 return EXCEPTION; 153 case "ldap": 154 return LDAP; 155 case "pool": 156 case "connectionpool": 157 case "connection-pool": 158 case "connection_pool": 159 return CONNECTION_POOL; 160 case "ldif": 161 return LDIF; 162 case "monitor": 163 return MONITOR; 164 case "codingerror": 165 case "coding-error": 166 case "coding_error": 167 return CODING_ERROR; 168 case "other": 169 return OTHER; 170 default: 171 return null; 172 } 173 } 174 175 176 177 /** 178 * Retrieves a comma-delimited list of the defined debug type names. 179 * 180 * @return A comma-delimited list of the defined debug type names. 181 */ 182 public static String getTypeNameList() 183 { 184 final StringBuilder buffer = new StringBuilder(); 185 186 final DebugType[] types = DebugType.values(); 187 for (int i=0; i < types.length; i++) 188 { 189 if (i > 0) 190 { 191 buffer.append(", "); 192 } 193 194 buffer.append(types[i].name); 195 } 196 197 return buffer.toString(); 198 } 199 200 201 202 /** 203 * Retrieves a string representation of this debug type. 204 * 205 * @return A string representation of this debug type. 206 */ 207 @Override() 208 public String toString() 209 { 210 return name; 211 } 212}