KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > provider > lib > topics > TopicsMap


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Offroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.util.monolog.provider.lib.topics;
27
28 import java.util.HashMap JavaDoc;
29
30
31 /**
32  * @author Jerome Offroy
33  *
34  * this class is used to store the TopicsValue and allows getting entry by ref or dy name
35  */

36 public class TopicsMap implements TopicsPool {
37     /**
38      * internals HashMap and ArrayList
39      */

40      private HashMap JavaDoc binding_name = new HashMap JavaDoc();
41      private HashMap JavaDoc binding_desc = new HashMap JavaDoc();
42      private HashMap JavaDoc binding_ref = new HashMap JavaDoc();
43
44     /**
45      * Constructor for TopicsMap.
46      */

47     public TopicsMap() {
48     }
49     
50     /**
51      * get name associated to a Topic by reference.
52      * @param ref
53      * @return String
54      */

55     public String JavaDoc getName(Class JavaDoc ref) {
56         return (String JavaDoc) binding_name.get(ref);
57     }
58
59     /**
60      * getDescription of a Topic by name.
61      * @param name
62      * @return String[]
63      */

64     public String JavaDoc[] getDescription(String JavaDoc name) {
65         return (String JavaDoc[]) binding_desc.get(name);
66     }
67
68     public String JavaDoc[] getAllName() {
69         Object JavaDoc[] tmp = binding_name.values().toArray();
70         String JavaDoc res[] = new String JavaDoc[tmp.length];
71         for (int i = 0; i < tmp.length; i++)
72             res[i] = (String JavaDoc) tmp[i];
73         return res;
74     }
75
76     /**
77      * put a new TopicsValue into referential .
78      * @param value the TopicsValue to add
79      * @return int the hashcode for the new entry
80      */

81     public int put(TopicsValue value) {
82         binding_name.put(value.getRef(), value.getName());
83         binding_desc.put(value.getRef(), value.getDescription());
84         binding_ref.put(value.getName(), value.getRef());
85         return 0;
86     }
87
88     /**
89      * put a new TopicsValue into referentia (as attributes).
90      * @param ref
91      * @param name
92      * @param description
93      * @return int the hashcode for the new entry
94      */

95     public int put(Class JavaDoc ref, String JavaDoc name, String JavaDoc[] description) {
96         return put(new TopicsValue(ref,name,description));
97     }
98
99     public HashMap JavaDoc getTopicsByRef() {
100         return binding_name;
101     }
102 }
103
Popular Tags