KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > wrapper > config > BasicHandler


1 /**
2  * Copyright (C) 2001-2003 France Telecom R&D
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package org.objectweb.util.monolog.wrapper.config;
20
21 import org.objectweb.util.monolog.api.Handler;
22
23 import java.util.Map JavaDoc;
24 import java.util.HashMap JavaDoc;
25 import java.io.Serializable JavaDoc;
26
27 /**
28  * This class is a basic implementation the Handler interface. It is not linked
29  * to any underlying log system. Therefore all attributes are stored into
30  * internal struture.
31  *
32  * @author Sebastien Chassande-Barrioz
33  */

34 public class BasicHandler implements Handler, Serializable JavaDoc {
35
36     /**
37      * The name of the handler
38      */

39     protected String JavaDoc name = null;
40
41     /**
42      * The attributes of the handler are listed by this field.
43      * key = atribute name
44      * value = attribute value
45      */

46     protected HashMap JavaDoc attributes = null;
47
48     /**
49      * The type of the handler
50      */

51     protected String JavaDoc type;
52
53     public BasicHandler(String JavaDoc n, String JavaDoc t) {
54         type = t;
55         name = n;
56         attributes = new HashMap JavaDoc();
57     }
58
59     public Map JavaDoc getAttributes() {
60         return attributes;
61     }
62
63     public void setAttributes(Map JavaDoc properties) {
64         attributes.clear();
65         attributes.putAll(properties);
66     }
67
68     // IMPLEMENTATION OF THE Handler INTERFACE //
69
//-----------------------------------------//
70

71     public String JavaDoc getName() {
72         return name;
73     }
74
75     public void setName(String JavaDoc n) {
76         name = n;
77     }
78
79     public String JavaDoc getType() {
80         return type;
81     }
82
83     public String JavaDoc[] getAttributeNames() {
84         return (String JavaDoc[]) attributes.keySet().toArray(new String JavaDoc[0]);
85     }
86
87     public Object JavaDoc getAttribute(String JavaDoc key) {
88         return attributes.get(key);
89     }
90
91     public Object JavaDoc setAttribute(String JavaDoc key, Object JavaDoc value) {
92         return attributes.put(key, value);
93     }
94 }
95
Popular Tags