1 /*
2 * org.osjava.naming.ContextBindings
3 *
4 * $Id: ContextNames.java 1978 2005-08-30 01:30:33Z hen $
5 * $Rev: 1978 $
6 * $Date: 2005-08-29 18:30:33 -0700 (Mon, 29 Aug 2005) $
7 * $Author: hen $
8 *
9 * Created on Apr 27, 2004
10 * Copyright (c) 2004, Robert M. Zigweid
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 *
16 * + Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 *
19 * + Redistributions in binary form must reproduce the above copyright notice,
20 * this list of conditions and the following disclaimer in the documentation
21 * and/or other materials provided with the distribution.
22 *
23 * + Neither the name of the Simple-JNDI nor the bindings of its contributors may
24 * be used to endorse or promote products derived from this software without
25 * specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39 package org.osjava.sj.jndi;
40
41 import java.util.Map;
42
43 import javax.naming.Binding;
44 import javax.naming.NameClassPair;
45 import javax.naming.NamingException;
46
47 /***
48 * This class represents a NamingEnumeration of the class names of a Context.
49 * Originally authored by Henri Yandell and modified to make more flexable with other
50 * Context implementations.
51 *
52 * @author Robert M. Zigweid and Henri Yandell
53 * @version $Rev: 1978 $ $Date: 2005-08-29 18:30:33 -0700 (Mon, 29 Aug 2005) $
54 */
55 public class ContextNames extends ContextBindings {
56
57 /***
58 * Creates a ContextNames object based upon an a Map of names and the objects
59 * the names are bound to. If <code>table</code> is modified after instantiation
60 * of ContextBindings, behavior is undefined and should be considered invalid.
61 *
62 * @param table The table upon which the ContextBindings is based.
63 */
64 public ContextNames(Map table) {
65 super(table);
66 }
67
68 /***
69 * Returns a {@link NameClassPair} created from the next available name.
70 *
71 * @return a NameClassPair representing the binding of the name and the
72 * object bound to the name
73 */
74 public Object nextElement() {
75 return super.nextElement();
76 }
77
78 /***
79 * Returns a {@link NameClassPair} created from the next available name.
80 *
81 * @return a NameClassPair representing the binding of the name and the
82 * object bound to the name
83 *
84 * @throws NamingException if a naming exception occurs
85 */
86 public Object next() throws NamingException {
87 Binding binding = null;
88 binding = (Binding)super.next();
89 return new NameClassPair(binding.getName(),
90 binding.getObject().getClass().getName());
91 }
92 }
93