001 /*
002 * Copyright 2009-2015 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2015 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.unboundidds;
022
023
024
025 import com.unboundid.util.StaticUtils;
026 import com.unboundid.util.ThreadSafety;
027 import com.unboundid.util.ThreadSafetyLevel;
028
029
030
031 /**
032 * <BLOCKQUOTE>
033 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID
034 * LDAP SDK for Java. It is not available for use in applications that
035 * include only the Standard Edition of the LDAP SDK, and is not supported for
036 * use in conjunction with non-UnboundID products.
037 * </BLOCKQUOTE>
038 * This class provides information about the types of alert severities that may
039 * be included in alert entries.
040 */
041 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
042 public enum AlertSeverity
043 {
044 /**
045 * The alert severity that indicates that the associated alert is
046 * informational.
047 */
048 INFO("info"),
049
050
051
052 /**
053 * The alert severity that indicates that the associated alert indicates a
054 * warning has occurred.
055 */
056 WARNING("warning"),
057
058
059
060 /**
061 * The alert severity that indicates that the associated alert indicates a
062 * non-fatal error has occurred.
063 */
064 ERROR("error"),
065
066
067
068 /**
069 * The alert severity that indicates that the associated alert indicates a
070 * fatal error has occurred.
071 */
072 FATAL("fatal");
073
074
075
076 // The name for this alert severity.
077 private final String name;
078
079
080
081 /**
082 * Creates a new alert severity with the specified name.
083 *
084 * @param name The name for this alert severity.
085 */
086 private AlertSeverity(final String name)
087 {
088 this.name = name;
089 }
090
091
092
093 /**
094 * Retrieves the name for this alert severity.
095 *
096 * @return The name for this alert severity.
097 */
098 public String getName()
099 {
100 return name;
101 }
102
103
104
105 /**
106 * Retrieves the alert severity with the specified name.
107 *
108 * @param name The name of the alert severity to retrieve.
109 *
110 * @return The alert severity with the specified name, or {@code null} if
111 * there is no alert severity with the given name.
112 */
113 public static AlertSeverity forName(final String name)
114 {
115 final String lowerName = StaticUtils.toLowerCase(name);
116
117 if (lowerName.equals("error"))
118 {
119 return ERROR;
120 }
121 else if (lowerName.equals("fatal"))
122 {
123 return FATAL;
124 }
125 else if (lowerName.equals("info"))
126 {
127 return INFO;
128 }
129 else if (lowerName.equals("warning"))
130 {
131 return WARNING;
132 }
133 else
134 {
135 return null;
136 }
137 }
138
139
140
141 /**
142 * Retrieves a string representation of this alert severity.
143 *
144 * @return A string representation of this alert severity.
145 */
146 @Override()
147 public String toString()
148 {
149 return name;
150 }
151 }