001 /*
002 * Copyright 2011-2012 UnboundID Corp.
003 *
004 * This program is free software; you can redistribute it and/or modify
005 * it under the terms of the GNU General Public License (GPLv2 only)
006 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
007 * as published by the Free Software Foundation.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, see <http://www.gnu.org/licenses>.
016 */
017
018 package com.unboundid.scim.sdk;
019
020 import static com.unboundid.scim.sdk.StaticUtils.*;
021
022
023
024 /**
025 * This enumeration defines a set of debugging types that are used by the SCIM
026 * SDK.
027 */
028 public enum DebugType
029 {
030 /**
031 * The debug type that will be used for debugging information about
032 * exceptions that are caught.
033 */
034 EXCEPTION("exception"),
035
036
037
038 /**
039 * The debug type that will be used for information about coding errors or
040 * other types of incorrect uses of the SCIM SDK.
041 */
042 CODING_ERROR("coding-error"),
043
044
045
046 /**
047 * The debug type that will be used for debug messages not applicable to any
048 * of the other categories.
049 */
050 OTHER("other");
051
052
053
054 // The name for this debug type.
055 private final String name;
056
057
058
059 /**
060 * Creates a new debug type with the specified name.
061 *
062 * @param name The name for this debug type. It should be in all lowercase
063 * characters.
064 */
065 private DebugType(final String name)
066 {
067 this.name = name;
068 }
069
070
071
072 /**
073 * Retrieves the name for this debug type.
074 *
075 * @return The name for this debug type.
076 */
077 public String getName()
078 {
079 return name;
080 }
081
082
083
084 /**
085 * Retrieves the debug type with the specified name.
086 *
087 * @param name The name of the debug type to retrieve.
088 *
089 * @return The requested debug type, or {@code null} if there is no such
090 * debug type.
091 */
092 public static DebugType forName(final String name)
093 {
094 final String lowerName = toLowerCase(name);
095
096 if (lowerName.equals("exception"))
097 {
098 return EXCEPTION;
099 }
100 else if (lowerName.equals("coding-error"))
101 {
102 return CODING_ERROR;
103 }
104 else if (lowerName.equals("other"))
105 {
106 return OTHER;
107 }
108
109 return null;
110 }
111
112
113
114 /**
115 * Retrieves a comma-delimited list of the defined debug type names.
116 *
117 * @return A comma-delimited list of the defined debug type names.
118 */
119 public static String getTypeNameList()
120 {
121 final StringBuilder buffer = new StringBuilder();
122
123 final DebugType[] types = DebugType.values();
124 for (int i=0; i < types.length; i++)
125 {
126 if (i > 0)
127 {
128 buffer.append(", ");
129 }
130
131 buffer.append(types[i].getName());
132 }
133
134 return buffer.toString();
135 }
136
137
138
139 /**
140 * Retrieves a string representation of this debug type.
141 *
142 * @return A string representation of this debug type.
143 */
144 @Override()
145 public String toString()
146 {
147 return name;
148 }
149 }