KickJava   Java API By Example, From Geeks To Geeks.

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


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

26
27 package org.objectweb.util.browser.core.naming;
28
29 /** To use the Name interface. */
30 import org.objectweb.util.browser.api.Context;
31 import org.objectweb.util.browser.core.api.ExtendedEntry;
32 import org.objectweb.util.browser.core.api.Name;
33
34 /** To use the Context interface. */
35
36 /** To use the ExtendedEntry interface */
37
38 /**
39  * Default basic implementation of the Entry interface.
40  *
41  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
42  * @version 0.1
43  */

44 public class DefaultEntry
45      extends AbstractEntry
46   implements ExtendedEntry {
47
48     // ==================================================================
49
//
50
// Internal state.
51
//
52
// ==================================================================
53

54     /** The value. */
55     private Object JavaDoc value_;
56
57     /** The name. */
58     private Name name_;
59
60     /** The context. */
61     private Context context_;
62
63     /** The wrapped object */
64     private Object JavaDoc wrappedObject_;
65
66     // ==================================================================
67
//
68
// Constructors.
69
//
70
// ==================================================================
71

72     /**
73      * Constructs a DefaultEntry with a value, name, and context.
74      *
75      * This constructor sets the value, name and context
76      * to respectively the given value, name, and context.
77      *
78      * @param value The value.
79      * @param name The name.
80      * @param context The context.
81      *
82      * @postcondition
83      * getOWValue() == value
84      * and getOWName() == name
85      * and getOWContext() == context;
86      */

87     public DefaultEntry(Object JavaDoc value, Name name, Context context) {
88         // Inits the internal state.
89
value_ = value;
90         name_ = name;
91         context_ = context;
92         wrappedObject_ = value;
93     }
94
95     /**
96      * Constructs a DefaultEntry with a value, name.
97      *
98      * This constructor sets the value, name
99      * to respectively the given value, name.
100      *
101      * @param value The value.
102      * @param name The name.
103      *
104      */

105     public DefaultEntry(Object JavaDoc value, Name name) {
106         this(value,name,null);
107     }
108
109     // ==================================================================
110
//
111
// No internal methods.
112
//
113
// ==================================================================
114

115     // ==================================================================
116
//
117
// Public methods for class Object.
118
//
119
// ==================================================================
120

121     // ==================================================================
122
//
123
// Public methods for interface Entry.
124
//
125
// ==================================================================
126

127     /**
128      * Gets the value contained in the target entry.
129      *
130      * This method does not update the value contained in the target entry.
131      *
132      * @return The value contained in the target entry.
133      *
134      * @postcondition return == getOWValue();
135      */

136     public Object JavaDoc getValue() {
137         // Matter: The CosNaming context doesn't displayed any children !!!
138
//return this.getWrappedObject();
139
return value_;
140     }
141
142     /**
143      * Gets the name of the target entry, in the context it belongs to.
144      *
145      * This method does not update the name of the target entry.
146      *
147      * @return The name of the target entry, in the context it belongs to.
148      *
149      * @postcondition return == getOWName();
150      */

151     public Object JavaDoc getName() {
152         return name_.getOWId();
153     }
154
155     /**
156      * Gets the context containing the target entry,
157      * if any, null otherwise.
158      *
159      * This method does not update the context containing
160      * the target entry.
161      *
162      * @return The context containing the target entry,
163      * if any, null otherwise..
164      *
165      * @postcondition return == getOWContext();
166      */

167     public Context getContext() {
168         return context_;
169     }
170
171     /**
172      * Changes the value of the Entry.
173      *
174      * @param value The value to set.
175      */

176     public void setOWValue(Object JavaDoc value) {
177         value_ = value;
178     }
179
180     /**
181      * Returns the wrapped object. The returned value is the same as the getOWObject method if no Context is defined for this object.
182      *
183      * @return The wrapped object
184      */

185     public Object JavaDoc getWrappedObject() {
186         return wrappedObject_;
187     }
188
189     /**
190      * Sets the wrapped object. It's necessary when the object crosses more than one factory, as every CORBA Object does.
191      */

192     public void setWrappedObject(Object JavaDoc wrapped) {
193         wrappedObject_ = wrapped;
194     }
195
196 }
197
Popular Tags