OSDN Git Service

Initial commit
[ultramonkey-l7/l7gui.git] / src / src / org / ultramonkey / l7 / model / SyncCategoryIdSet.java
1 package org.ultramonkey.l7.model;
2
3 //import java.util.logging.Logger;
4 import org.apache.log4j.Logger;
5
6 /**
7  * <p>class SyncCategoryId</p>
8  * <p>Copyright(c) NTT COMWARE 2008</p>
9  * @author momose
10  */
11 public class SyncCategoryIdSet {
12     protected static Logger debugLogger = Logger.getLogger(LogCategorySet.SYNC_SYNC);
13
14     static public final int SYNC_OK = 1;
15
16     static public final int SYNC_NG = 2;
17
18     static public final int L7VSD_LOG_ID = 3;
19
20     static public final int ADM_LOG_ID = 4;
21
22     static public final int SNMP_LOG_ID = 5;
23
24     static public final int REPLICATION_INFO_ID = 6;
25
26     static public final int SNMP_INFO_ID = 7;
27
28     static public final int ADM_INFO_ID = 8;
29
30     static public final int MONITOR_ID = 9;
31
32     static public final int SERVICE_ID = 10;
33
34     static public final int USERDATA_ID = 11;
35
36     static public final int LOG_ALL_ID = 12;
37
38     /**
39      * <p> change category name to category ID</p>
40      *
41      * @param inStr category name
42      * @return
43      * @throws MessageView
44      */
45     public static int toCategoryId(String inStr) throws MessageView {
46
47         // debug log(in method)
48         if (debugLogger.isDebugEnabled()) {
49             StringBuffer buf = new StringBuffer();
50             buf
51                             .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView in ");
52             buf.append("inStr= " + inStr);
53             debugLogger.debug("11195 " + buf.toString());
54         }
55
56         if (inStr.equals("SYNC_OK")) {
57             // debug log(out method)
58             if (debugLogger.isDebugEnabled()) {
59                 StringBuffer buf = new StringBuffer();
60                 buf
61                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
62                 buf.append("return= SYNC_OK");
63                 debugLogger.debug("11196 " + buf.toString());
64             }
65             return SYNC_OK;
66         }
67         if (inStr.equals("SYNC_NG")) {
68             // debug log(out method)
69             if (debugLogger.isDebugEnabled()) {
70                 StringBuffer buf = new StringBuffer();
71                 buf
72                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
73                 buf.append("return= SYNC_NG");
74                 debugLogger.debug("11197 " + buf.toString());
75             }
76             return SYNC_NG;
77         }
78         if (inStr.equals("l7vsd_log")) {
79             // debug log (out method)
80             if (debugLogger.isDebugEnabled()) {
81                 StringBuffer buf = new StringBuffer();
82                 buf
83                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
84                 buf.append("return= L7VSD_LOG_ID");
85                 debugLogger.debug("11198 " + buf.toString());
86             }
87             return L7VSD_LOG_ID;
88         }
89         if (inStr.equals("adm_log")) {
90             // debug log (out method)
91             if (debugLogger.isDebugEnabled()) {
92                 StringBuffer buf = new StringBuffer();
93                 buf
94                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
95                 buf.append("return= ADM_LOG_ID");
96                 debugLogger.debug("11199 " + buf.toString());
97             }
98             return ADM_LOG_ID;
99         }
100         if (inStr.equals("snmp_log")) {
101             // debug log (out method)
102             if (debugLogger.isDebugEnabled()) {
103                 StringBuffer buf = new StringBuffer();
104                 buf
105                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
106                 buf.append("return= SNMP_LOG_ID");
107                 debugLogger.debug("11200 " + buf.toString());
108             }
109             return SNMP_LOG_ID;
110         }
111         if (inStr.equals("replication_info")) {
112             // debug log (out method)
113             if (debugLogger.isDebugEnabled()) {
114                 StringBuffer buf = new StringBuffer();
115                 buf
116                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
117                 buf.append("return= REPLICATION_INFO_ID");
118                 debugLogger.debug("11201 " + buf.toString());
119             }
120             return REPLICATION_INFO_ID;
121         }
122         if (inStr.equals("snmp_info")) {
123             // debug log (out method)
124             if (debugLogger.isDebugEnabled()) {
125                 StringBuffer buf = new StringBuffer();
126                 buf
127                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
128                 buf.append("return= SNMP_INFO_ID");
129                 debugLogger.debug("11202 " + buf.toString());
130             }
131             return SNMP_INFO_ID;
132         }
133         if (inStr.equals("adm_info")) {
134             // debug log (out method)
135             if (debugLogger.isDebugEnabled()) {
136                 StringBuffer buf = new StringBuffer();
137                 buf
138                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
139                 buf.append("return= ADM_INFO_ID");
140                 debugLogger.debug("11203 " + buf.toString());
141             }
142             return ADM_INFO_ID;
143         }
144         if (inStr.equals("monitor")) {
145             // debug log (out method)
146             if (debugLogger.isDebugEnabled()) {
147                 StringBuffer buf = new StringBuffer();
148                 buf
149                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
150                 buf.append("return= MONITOR_ID");
151                 debugLogger.debug("11204 " + buf.toString());
152             }
153             return MONITOR_ID;
154         }
155         if (inStr.equals("service")) {
156             // debug log (out method)
157             if (debugLogger.isDebugEnabled()) {
158                 StringBuffer buf = new StringBuffer();
159                 buf
160                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
161                 buf.append("return= SERVICE_ID");
162                 debugLogger.debug("11205 " + buf.toString());
163             }
164             return SERVICE_ID;
165         }
166         if (inStr.equals("userdata")) {
167             // debug log (out method)
168             if (debugLogger.isDebugEnabled()) {
169                 StringBuffer buf = new StringBuffer();
170                 buf
171                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
172                 buf.append("return= USERDATA_ID");
173                 debugLogger.debug("11206 " + buf.toString());
174             }
175             return USERDATA_ID;
176         }
177         if (inStr.equals("log_all")) {
178             // debug log (out method)
179             if (debugLogger.isDebugEnabled()) {
180                 StringBuffer buf = new StringBuffer();
181                 buf
182                                 .append("SyncCategoryIdSet::toCategoryId(String inStr) throws MessageView out ");
183                 buf.append("return= LOG_ALL_ID");
184                 debugLogger.debug("11207 " + buf.toString());
185             }
186             return LOG_ALL_ID;
187         } else
188             throw new MessageView(40001, LogCategorySet.SYNC_SYNC,
189                             Message.SYNC_INVALID_ARGUMENT + " toCategoryId : " + inStr);
190
191     }
192
193     /**
194      * <p> change category ID to category name</p>
195      *
196      * @param categoryId category ID
197      * @return category name
198      * @throws MessageView
199      */
200     public static String toCategoryName(int categoryId) throws MessageView {
201         //      debug log(in method)
202         if (debugLogger.isDebugEnabled()) {
203             StringBuffer buf = new StringBuffer();
204             buf
205                             .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView in ");
206             buf.append("categoryId= " + categoryId);
207             debugLogger.debug("11208 " + buf.toString());
208         }
209
210         switch (categoryId) {
211         case L7VSD_LOG_ID:
212             //          debug log(out method)
213             if (debugLogger.isDebugEnabled()) {
214                 StringBuffer buf = new StringBuffer();
215                 buf
216                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
217                 buf.append("return= l7vsd_log");
218                 debugLogger.debug("11209 " + buf.toString());
219             }
220             return "l7vsd_log";
221
222         case ADM_LOG_ID:
223             // debug log(out method)
224             if (debugLogger.isDebugEnabled()) {
225                 StringBuffer buf = new StringBuffer();
226                 buf
227                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
228                 buf.append("return= adm_log");
229                 debugLogger.debug("11210 " + buf.toString());
230             }
231             return "adm_log";
232
233         case SNMP_LOG_ID:
234             //          debug log(out method)
235             if (debugLogger.isDebugEnabled()) {
236                 StringBuffer buf = new StringBuffer();
237                 buf
238                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
239                 buf.append("return= snmp_log");
240                 debugLogger.debug("11211 " + buf.toString());
241             }
242
243             return "snmp_log";
244
245         case REPLICATION_INFO_ID:
246             //          debug log(out method)
247             if (debugLogger.isDebugEnabled()) {
248                 StringBuffer buf = new StringBuffer();
249                 buf
250                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
251                 buf.append("return= replication_info");
252                 debugLogger.debug("11212 " + buf.toString());
253             }
254             return "replication_info";
255
256         case SNMP_INFO_ID:
257             //          debug log(out method)
258             if (debugLogger.isDebugEnabled()) {
259                 StringBuffer buf = new StringBuffer();
260                 buf
261                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
262                 buf.append("return= snmp_info");
263                 debugLogger.debug("11213 " + buf.toString());
264             }
265             return "snmp_info";
266
267         case ADM_INFO_ID:
268             //          debug log(out method)
269             if (debugLogger.isDebugEnabled()) {
270                 StringBuffer buf = new StringBuffer();
271                 buf
272                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
273                 buf.append("return= adm_info");
274                 debugLogger.debug("11214 " + buf.toString());
275             }
276             return "adm_info";
277
278         case MONITOR_ID:
279             //          debug log(out method)
280             if (debugLogger.isDebugEnabled()) {
281                 StringBuffer buf = new StringBuffer();
282                 buf
283                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
284                 buf.append("return= monitor");
285                 debugLogger.debug("11215 " + buf.toString());
286             }
287             return "monitor";
288
289         case SERVICE_ID:
290             //          debug log(out method)
291             if (debugLogger.isDebugEnabled()) {
292                 StringBuffer buf = new StringBuffer();
293                 buf
294                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
295                 buf.append("return= service");
296                 debugLogger.debug("11216 " + buf.toString());
297             }
298             return "service";
299
300         case USERDATA_ID:
301             //          debug log(out method)
302             if (debugLogger.isDebugEnabled()) {
303                 StringBuffer buf = new StringBuffer();
304                 buf
305                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
306                 buf.append("return= userdata");
307                 debugLogger.debug("11217 " + buf.toString());
308             }
309             return "userdata";
310
311         case LOG_ALL_ID:
312             //          debug log(out method)
313             if (debugLogger.isDebugEnabled()) {
314                 StringBuffer buf = new StringBuffer();
315                 buf
316                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
317                 buf.append("return= log_all");
318                 debugLogger.debug("11218 " + buf.toString());
319             }
320             return "log_all";
321
322         case SYNC_OK:
323             //          debug log(out method)
324             if (debugLogger.isDebugEnabled()) {
325                 StringBuffer buf = new StringBuffer();
326                 buf
327                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
328                 buf.append("return= sync_ok");
329                 debugLogger.debug("11219 " + buf.toString());
330             }
331             return "sync_ok";
332
333         case SYNC_NG:
334             //          debug log(out method)
335             if (debugLogger.isDebugEnabled()) {
336                 StringBuffer buf = new StringBuffer();
337                 buf
338                                 .append("SyncCategoryIdSet::toCategoryName(int categoryId) throws MessageView out ");
339                 buf.append("return= sync_ng");
340                 debugLogger.debug("11220 " + buf.toString());
341             }
342             return "sync_ng";
343
344         default:
345             throw new MessageView(40002, LogCategorySet.SYNC_SYNC,
346                             Message.SYNC_INVALID_ARGUMENT + " toCategoryName : "
347                                             + categoryId);
348         }
349     }
350 }