2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / javax / naming / directory / InitialDirContext.java
bloba0a598b331668a9f8d62b8fa7291002cf98c618c
1 /* InitialDirContext.java --
2 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.naming.directory;
41 import java.util.Hashtable;
42 import javax.naming.Context;
43 import javax.naming.InitialContext;
44 import javax.naming.Name;
45 import javax.naming.NamingEnumeration;
46 import javax.naming.NamingException;
47 import javax.naming.NoInitialContextException;
48 import javax.naming.NotContextException;
50 /**
51 * @author Tom Tromey <tromey@redhat.com>
52 * @date June 25, 2001
54 public class InitialDirContext extends InitialContext implements DirContext
56 public InitialDirContext ()
57 throws NamingException
59 this (null);
62 protected InitialDirContext (boolean lazy)
63 throws NamingException
65 super (lazy);
68 public InitialDirContext (Hashtable environment)
69 throws NamingException
71 super (environment);
74 // The InitialContext docs suggest that this exist. And it does
75 // seem like a good idea. but the InitialDirContext docs indicate
76 // it cannot be non-private.
77 private DirContext getURLOrDefaultInitDirCtx (Name name)
78 throws NamingException
80 Context c = getURLOrDefaultInitCtx (name);
81 if (c == null)
82 throw new NoInitialContextException ();
83 else if (! (c instanceof DirContext))
84 throw new NotContextException ();
85 return (DirContext) c;
88 private DirContext getURLOrDefaultInitDirCtx (String name)
89 throws NamingException
91 Context c = getURLOrDefaultInitCtx (name);
92 if (c == null)
93 throw new NoInitialContextException ();
94 else if (! (c instanceof DirContext))
95 throw new NotContextException ();
96 return (DirContext) c;
99 public Attributes getAttributes (String name)
100 throws NamingException
102 return getURLOrDefaultInitDirCtx (name).getAttributes (name);
105 public Attributes getAttributes (String name, String[] attrIds)
106 throws NamingException
108 return getURLOrDefaultInitDirCtx (name).getAttributes (name, attrIds);
111 public Attributes getAttributes (Name name)
112 throws NamingException
114 return getURLOrDefaultInitDirCtx (name).getAttributes (name);
117 public Attributes getAttributes(Name name, String[] attrIds)
118 throws NamingException
120 return getURLOrDefaultInitDirCtx (name).getAttributes (name, attrIds);
123 public void modifyAttributes(Name name, int mod_op, Attributes attrs)
124 throws NamingException
126 getURLOrDefaultInitDirCtx (name).modifyAttributes (name, mod_op, attrs);
129 public void modifyAttributes(String name, int mod_op, Attributes attrs)
130 throws NamingException
132 getURLOrDefaultInitDirCtx (name).modifyAttributes (name, mod_op, attrs);
135 public void modifyAttributes(Name name, ModificationItem[] mods)
136 throws NamingException
138 getURLOrDefaultInitDirCtx (name).modifyAttributes (name, mods);
141 public void modifyAttributes(String name, ModificationItem[] mods)
142 throws NamingException
144 getURLOrDefaultInitDirCtx (name).modifyAttributes (name, mods);
147 public void bind(Name name, Object obj, Attributes attrs)
148 throws NamingException
150 getURLOrDefaultInitDirCtx (name).bind (name, obj, attrs);
153 public void bind(String name, Object obj, Attributes attrs)
154 throws NamingException
156 getURLOrDefaultInitDirCtx (name).bind (name, obj, attrs);
159 public void rebind(Name name, Object obj, Attributes attrs)
160 throws NamingException
162 getURLOrDefaultInitDirCtx (name).rebind (name, obj, attrs);
165 public void rebind(String name, Object obj, Attributes attrs)
166 throws NamingException
168 getURLOrDefaultInitDirCtx (name).rebind (name, obj, attrs);
171 public DirContext createSubcontext(Name name, Attributes attrs)
172 throws NamingException
174 return getURLOrDefaultInitDirCtx (name).createSubcontext (name, attrs);
177 public DirContext createSubcontext(String name, Attributes attrs)
178 throws NamingException
180 return getURLOrDefaultInitDirCtx (name).createSubcontext (name, attrs);
183 public DirContext getSchema(Name name)
184 throws NamingException
186 return getURLOrDefaultInitDirCtx (name).getSchema (name);
189 public DirContext getSchema(String name)
190 throws NamingException
192 return getURLOrDefaultInitDirCtx (name).getSchema (name);
195 public DirContext getSchemaClassDefinition(Name name)
196 throws NamingException
198 return getURLOrDefaultInitDirCtx (name).getSchemaClassDefinition (name);
201 public DirContext getSchemaClassDefinition(String name)
202 throws NamingException
204 return getURLOrDefaultInitDirCtx (name).getSchemaClassDefinition (name);
207 public NamingEnumeration search(Name name, Attributes matchingAttributes,
208 String[] attributesToReturn)
209 throws NamingException
211 return getURLOrDefaultInitDirCtx (name).search (name, matchingAttributes,
212 attributesToReturn);
215 public NamingEnumeration search(String name, Attributes matchingAttributes,
216 String[] attributesToReturn)
217 throws NamingException
219 return getURLOrDefaultInitDirCtx (name).search (name, matchingAttributes,
220 attributesToReturn);
223 public NamingEnumeration search(Name name, Attributes matchingAttributes)
224 throws NamingException
226 return getURLOrDefaultInitDirCtx (name).search (name, matchingAttributes);
229 public NamingEnumeration search(String name, Attributes matchingAttributes)
230 throws NamingException
232 return getURLOrDefaultInitDirCtx (name).search (name, matchingAttributes);
235 public NamingEnumeration search(Name name, String filter,
236 SearchControls cons)
237 throws NamingException
239 return getURLOrDefaultInitDirCtx (name).search (name, filter, cons);
242 public NamingEnumeration search(String name, String filter,
243 SearchControls cons)
244 throws NamingException
246 return getURLOrDefaultInitDirCtx (name).search (name, filter, cons);
249 public NamingEnumeration search(Name name, String filterExpr,
250 Object[] filterArgs, SearchControls cons)
251 throws NamingException
253 return getURLOrDefaultInitDirCtx (name).search (name, filterExpr,
254 filterArgs, cons);
257 public NamingEnumeration search(String name, String filterExpr,
258 Object[] filterArgs, SearchControls cons)
259 throws NamingException
261 return getURLOrDefaultInitDirCtx (name).search (name, filterExpr,
262 filterArgs, cons);