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 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2007-2008 Sun Microsystems, Inc. 026 */ 027 028 package org.opends.messages; 029 030 import java.util.Map; 031 import java.util.HashMap; 032 import 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) 044 public 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 that will be used for messages associated with 161 * third-party (including user-defined) modules. 162 */ 163 THIRD_PARTY(0x80000000), 164 165 /** 166 * The category that will be used for messages associated with 167 * user-defined modules. 168 */ 169 USER_DEFINED(0xFFF00000); 170 171 static private Map<Integer,Category> MASK_VALUE_MAP; 172 173 static { 174 MASK_VALUE_MAP = new HashMap<Integer,Category>(); 175 for (Category c : EnumSet.allOf(Category.class)) { 176 MASK_VALUE_MAP.put(c.mask, c); 177 } 178 } 179 180 /** 181 * Obtains the <code>Severity</code> associated with the the input 182 * message ID <code>msgId</code>. 183 * @param msgId int message ID 184 * @return Severity assocated with the ID 185 */ 186 static public Category parseMessageId(int msgId) { 187 return Category.parseMask(msgId & 0xFFF00000); 188 } 189 190 /** 191 * Obtains the <code>Severity</code> associated with a given mask 192 * value. 193 * @param mask for which a <code>Severity</code> is obtained. 194 * @return Severity associated with <code>mask</code> 195 */ 196 static public Category parseMask(int mask) { 197 return MASK_VALUE_MAP.get(mask); 198 } 199 200 private final int mask; 201 202 /** 203 * Gets the mask value associated with this category. 204 * @return int mask value 205 */ 206 public int getMask() { 207 return this.mask; 208 } 209 210 private Category(int intValue) { 211 this.mask = intValue; 212 } 213 214 }