01: /**
02: * Copyright (C) 2001-2003 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * 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: */package org.objectweb.util.monolog.wrapper.config;
18:
19: import org.objectweb.util.monolog.api.Handler;
20:
21: import java.util.Map;
22: import java.util.HashMap;
23: import java.io.Serializable;
24:
25: /**
26: * This class is a basic implementation the Handler interface. It is not linked
27: * to any underlying log system. Therefore all attributes are stored into
28: * internal struture.
29: *
30: * @author Sebastien Chassande-Barrioz
31: */
32: public class BasicHandler implements Handler, Serializable {
33:
34: /**
35: * The name of the handler
36: */
37: protected String name = null;
38:
39: /**
40: * The attributes of the handler are listed by this field.
41: * key = atribute name
42: * value = attribute value
43: */
44: protected HashMap attributes = null;
45:
46: /**
47: * The type of the handler
48: */
49: protected String type;
50:
51: public BasicHandler(String n, String t) {
52: type = t;
53: name = n;
54: attributes = new HashMap();
55: }
56:
57: public Map getAttributes() {
58: return attributes;
59: }
60:
61: public void setAttributes(Map properties) {
62: attributes.clear();
63: attributes.putAll(properties);
64: }
65:
66: // IMPLEMENTATION OF THE Handler INTERFACE //
67: //-----------------------------------------//
68:
69: public String getName() {
70: return name;
71: }
72:
73: public void setName(String n) {
74: name = n;
75: }
76:
77: public String getType() {
78: return type;
79: }
80:
81: public String[] getAttributeNames() {
82: return (String[]) attributes.keySet().toArray(new String[0]);
83: }
84:
85: public Object getAttribute(String key) {
86: return attributes.get(key);
87: }
88:
89: public Object setAttribute(String key, Object value) {
90: return attributes.put(key, value);
91: }
92: }
|