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 legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2007-2009 Sun Microsystems, Inc. 025 * Portions Copyright 2011-2015 ForgeRock AS. 026 */ 027 028package org.opends.messages; 029 030import java.util.Map; 031import java.util.HashMap; 032import java.util.EnumSet; 033 034/** 035 * Defines values for message categories which are loosly based on 036 * server components. Categories contain an in value that can be 037 * used as a mask for bitwise operations. 038 */ 039@org.opends.server.types.PublicAPI( 040 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED, 041 mayInstantiate=false, 042 mayExtend=false, 043 mayInvoke=true) 044public enum Category { 045 046 /** 047 * The category that will be used for messages associated with the 048 * core server. 049 */ 050 CORE(0x00000000), 051 052 /** 053 * The category that will be used for messages associated with server 054 * extensions (e.g., extended operations, SASL mechanisms, password storage 055 * schemes, password validators, etc.). 056 */ 057 EXTENSIONS(0x00100000), 058 059 /** 060 * The category that will be used for messages associated with 061 * connection and protocol handling (e.g., ASN.1 and LDAP). 062 */ 063 PROTOCOL(0x00200000), 064 065 /** 066 * The category that will be used for messages associated with 067 * configuration handling. 068 */ 069 CONFIG(0x00300000), 070 071 /** 072 * The category that will be used for messages associated with the 073 * server loggers. 074 */ 075 LOG(0x00400000), 076 077 /** 078 * The category that will be used for messages associated with the 079 * general server utilities. 080 */ 081 UTIL(0x00500000), 082 083 /** 084 * The category that will be used for messages associated with the 085 * server schema elements. 086 */ 087 SCHEMA(0x00600000), 088 089 /** 090 * The category that will be used for messages associated with plugin 091 * processing. 092 */ 093 PLUGIN(0x00700000), 094 095 /** 096 * The category used for messages associated with the JE backend. 097 */ 098 JEB(0x00800000), 099 100 /** 101 * The category used for messages associated with generic backends. 102 */ 103 BACKEND(0x00900000), 104 105 /** 106 * The category used for messages associated with tools. 107 */ 108 TOOLS(0x00A00000), 109 110 /** 111 * The category used for messages associated with tasks. 112 */ 113 TASK(0x00B00000), 114 115 /** 116 * The category used for messages associated with Access Control. 117 */ 118 ACCESS_CONTROL(0x00C00000), 119 120 /** 121 * The category used for messages associated with the 122 * administration framework. 123 */ 124 ADMIN(0x00D00000), 125 126 /** 127 * The category used for messages associated with the Synchronization. 128 */ 129 SYNC(0x00E00000), 130 131 /** 132 * The category used for messages associated with version information. 133 */ 134 VERSION(0x00F00000), 135 136 /** 137 * The category used for messages associated with quicksetup tools. 138 */ 139 QUICKSETUP(0x01000000), 140 141 /** 142 * The category used for messages associated with the tool like the 143 * offline installer and unintaller. 144 */ 145 ADMIN_TOOL(0x01100000), 146 147 /** 148 * The category used for messages associated with the dsconfig 149 * administration tool. 150 */ 151 DSCONFIG(0x01200000), 152 153 /** 154 * The category used for messages associated with the runtime information. 155 */ 156 157 RUNTIME_INFORMATION(0x01300000), 158 159 /** 160 * The category used for messages associated with the Servicetag registration. 161 * No longer used. 162 * SERVICETAG(0x01400000), 163 */ 164 165 /** 166 * The category that will be used for messages associated with 167 * third-party (including user-defined) modules. 168 */ 169 THIRD_PARTY(0x40000000), 170 171 /** 172 * The category that will be used for messages associated with 173 * user-defined modules. 174 */ 175 USER_DEFINED(0x7FF00000); 176 177 private static Map<Integer,Category> MASK_VALUE_MAP; 178 179 static { 180 MASK_VALUE_MAP = new HashMap<>(); 181 for (Category c : EnumSet.allOf(Category.class)) { 182 MASK_VALUE_MAP.put(c.mask, c); 183 } 184 } 185 186 /** 187 * Obtains the <code>Severity</code> associated with the the input 188 * message ID <code>msgId</code>. 189 * @param msgId int message ID 190 * @return Severity associated with the ID 191 */ 192 public static Category parseMessageId(int msgId) { 193 return Category.parseMask(msgId & 0xFFF00000); 194 } 195 196 /** 197 * Obtains the <code>Severity</code> associated with a given mask 198 * value. 199 * @param mask for which a <code>Severity</code> is obtained. 200 * @return Severity associated with <code>mask</code> 201 */ 202 public static Category parseMask(int mask) { 203 return MASK_VALUE_MAP.get(mask); 204 } 205 206 private final int mask; 207 208 /** 209 * Gets the mask value associated with this category. 210 * @return int mask value 211 */ 212 public int getMask() { 213 return this.mask; 214 } 215 216 private Category(int intValue) { 217 this.mask = intValue; 218 } 219 220}