KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > log > output > db > ColumnType


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.log.output.db;
18
19 /**
20  * A class to hold all constants for ColumnTypes.
21  *
22  * @author Peter Donald
23  */

24 public class ColumnType
25 {
26     public static final int STATIC = 1;
27     public static final int CATEGORY = 2;
28     public static final int CONTEXT = 3;
29     public static final int MESSAGE = 4;
30     public static final int TIME = 5;
31     public static final int RELATIVE_TIME = 6;
32     public static final int THROWABLE = 7;
33     public static final int PRIORITY = 8;
34     public static final int HOSTNAME = 9;
35     //public static final int IPADDRESS = 10;
36

37     /**
38      * The maximum value used for TYPEs. Subclasses can define their own TYPEs
39      * starting at <code>MAX_TYPE + 1</code>.
40      */

41     //public static final int MAX_TYPE = IPADDRESS;
42

43     public static final String JavaDoc STATIC_STR = "static";
44     public static final String JavaDoc CATEGORY_STR = "category";
45     public static final String JavaDoc CONTEXT_STR = "context";
46     public static final String JavaDoc MESSAGE_STR = "message";
47     public static final String JavaDoc TIME_STR = "time";
48     public static final String JavaDoc RELATIVE_TIME_STR = "rtime";
49     public static final String JavaDoc THROWABLE_STR = "throwable";
50     public static final String JavaDoc PRIORITY_STR = "priority";
51     public static final String JavaDoc HOSTNAME_STR = "hostname";
52     //public static final String IPADDRESS_STR = "ipaddress";
53

54
55     public static int getTypeIdFor( final String JavaDoc type )
56     {
57         if( type.equalsIgnoreCase( CATEGORY_STR ) )
58         {
59             return CATEGORY;
60         }
61         else if( type.equalsIgnoreCase( STATIC_STR ) )
62         {
63             return STATIC;
64         }
65         else if( type.equalsIgnoreCase( CONTEXT_STR ) )
66         {
67             return CONTEXT;
68         }
69         else if( type.equalsIgnoreCase( MESSAGE_STR ) )
70         {
71             return MESSAGE;
72         }
73         else if( type.equalsIgnoreCase( PRIORITY_STR ) )
74         {
75             return PRIORITY;
76         }
77         else if( type.equalsIgnoreCase( TIME_STR ) )
78         {
79             return TIME;
80         }
81         else if( type.equalsIgnoreCase( RELATIVE_TIME_STR ) )
82         {
83             return RELATIVE_TIME;
84         }
85         //else if( type.equalsIgnoreCase( IPADDRESS_STR ) ) return IPADDRESS;
86
else if( type.equalsIgnoreCase( HOSTNAME_STR ) )
87         {
88             return HOSTNAME;
89         }
90         else if( type.equalsIgnoreCase( THROWABLE_STR ) )
91         {
92             return THROWABLE;
93         }
94         else
95         {
96             throw new IllegalArgumentException JavaDoc( "Unknown Type " + type );
97         }
98     }
99 }
100
101
Popular Tags