KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > browser > core > naming > DefaultContext


1 /*===========================================================================
2
3 ObjectWeb Naming Context Framework
4 Copyright (C) 2002 USTL - LIFL - GOAL
5 Contact: architecture@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 Moroy.
23 Contributor(s): ______________________________________.
24
25 ===========================================================================*/

26
27 package org.objectweb.util.browser.core.naming;
28
29 import org.objectweb.util.browser.api.Context;
30 import org.objectweb.util.browser.api.Entry;
31 import java.util.Vector JavaDoc;
32
33 /**
34  * Basic implementation of the Context interface. It uses the Vector class.
35  *
36  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>
37  * @version 0.1
38  */

39
40 public class DefaultContext implements Context {
41
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     /** The elements. */
49     protected Vector JavaDoc elts_;
50
51     // ==================================================================
52
//
53
// Constructors.
54
//
55
// ==================================================================
56

57     /**
58      * Constructs a DefaultContextContainer.
59      */

60     public DefaultContext() {
61         // Inits internal state.
62
elts_ = new Vector JavaDoc();
63     }
64
65     // ==================================================================
66
//
67
// Internal methods.
68
//
69
// ==================================================================
70

71     /**
72      * Creates an Entry.
73      *
74      * @param value The value of the entry to create.
75      * @param id The id of the name of the entry to create.
76      *
77      * @return A new Entry.
78      *
79      * @postcondition
80      * return.getOWValue() == value
81      * and return.getOWName().getOWID() == id
82      * and return.getOWContext() == this;
83      */

84     protected Entry createEntry(Object JavaDoc value, String JavaDoc id) {
85         return new DefaultEntry(value, new DefaultName(id), this);
86     }
87
88     // ==================================================================
89
//
90
// Public methods for interface Context.
91
//
92
// ==================================================================
93

94     public Entry[] getEntries() {
95         return (Entry[])elts_.toArray(new Entry[0]);
96     }
97
98 }
99
Popular Tags