1 /* InitialDirContext.java --
2 Copyright (C) 2000, 2001, 2004 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)
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
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
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
;
43 import javax
.naming
.Context
;
44 import javax
.naming
.InitialContext
;
45 import javax
.naming
.Name
;
46 import javax
.naming
.NamingEnumeration
;
47 import javax
.naming
.NamingException
;
48 import javax
.naming
.NoInitialContextException
;
49 import javax
.naming
.NotContextException
;
52 * @author Tom Tromey (tromey@redhat.com)
55 public class InitialDirContext
extends InitialContext
implements DirContext
57 public InitialDirContext ()
58 throws NamingException
63 protected InitialDirContext (boolean lazy
)
64 throws NamingException
69 public InitialDirContext (Hashtable environment
)
70 throws NamingException
75 // The InitialContext docs suggest that this exist. And it does
76 // seem like a good idea. but the InitialDirContext docs indicate
77 // it cannot be non-private.
78 private DirContext
getURLOrDefaultInitDirCtx (Name name
)
79 throws NamingException
81 Context c
= getURLOrDefaultInitCtx (name
);
83 throw new NoInitialContextException ();
84 else if (! (c
instanceof DirContext
))
85 throw new NotContextException ();
86 return (DirContext
) c
;
89 private DirContext
getURLOrDefaultInitDirCtx (String name
)
90 throws NamingException
92 Context c
= getURLOrDefaultInitCtx (name
);
94 throw new NoInitialContextException ();
95 else if (! (c
instanceof DirContext
))
96 throw new NotContextException ();
97 return (DirContext
) c
;
100 public Attributes
getAttributes (String name
)
101 throws NamingException
103 return getURLOrDefaultInitDirCtx (name
).getAttributes (name
);
106 public Attributes
getAttributes (String name
, String
[] attrIds
)
107 throws NamingException
109 return getURLOrDefaultInitDirCtx (name
).getAttributes (name
, attrIds
);
112 public Attributes
getAttributes (Name name
)
113 throws NamingException
115 return getURLOrDefaultInitDirCtx (name
).getAttributes (name
);
118 public Attributes
getAttributes(Name name
, String
[] attrIds
)
119 throws NamingException
121 return getURLOrDefaultInitDirCtx (name
).getAttributes (name
, attrIds
);
124 public void modifyAttributes(Name name
, int mod_op
, Attributes attrs
)
125 throws NamingException
127 getURLOrDefaultInitDirCtx (name
).modifyAttributes (name
, mod_op
, attrs
);
130 public void modifyAttributes(String name
, int mod_op
, Attributes attrs
)
131 throws NamingException
133 getURLOrDefaultInitDirCtx (name
).modifyAttributes (name
, mod_op
, attrs
);
136 public void modifyAttributes(Name name
, ModificationItem
[] mods
)
137 throws NamingException
139 getURLOrDefaultInitDirCtx (name
).modifyAttributes (name
, mods
);
142 public void modifyAttributes(String name
, ModificationItem
[] mods
)
143 throws NamingException
145 getURLOrDefaultInitDirCtx (name
).modifyAttributes (name
, mods
);
148 public void bind(Name name
, Object obj
, Attributes attrs
)
149 throws NamingException
151 getURLOrDefaultInitDirCtx (name
).bind (name
, obj
, attrs
);
154 public void bind(String name
, Object obj
, Attributes attrs
)
155 throws NamingException
157 getURLOrDefaultInitDirCtx (name
).bind (name
, obj
, attrs
);
160 public void rebind(Name name
, Object obj
, Attributes attrs
)
161 throws NamingException
163 getURLOrDefaultInitDirCtx (name
).rebind (name
, obj
, attrs
);
166 public void rebind(String name
, Object obj
, Attributes attrs
)
167 throws NamingException
169 getURLOrDefaultInitDirCtx (name
).rebind (name
, obj
, attrs
);
172 public DirContext
createSubcontext(Name name
, Attributes attrs
)
173 throws NamingException
175 return getURLOrDefaultInitDirCtx (name
).createSubcontext (name
, attrs
);
178 public DirContext
createSubcontext(String name
, Attributes attrs
)
179 throws NamingException
181 return getURLOrDefaultInitDirCtx (name
).createSubcontext (name
, attrs
);
184 public DirContext
getSchema(Name name
)
185 throws NamingException
187 return getURLOrDefaultInitDirCtx (name
).getSchema (name
);
190 public DirContext
getSchema(String name
)
191 throws NamingException
193 return getURLOrDefaultInitDirCtx (name
).getSchema (name
);
196 public DirContext
getSchemaClassDefinition(Name name
)
197 throws NamingException
199 return getURLOrDefaultInitDirCtx (name
).getSchemaClassDefinition (name
);
202 public DirContext
getSchemaClassDefinition(String name
)
203 throws NamingException
205 return getURLOrDefaultInitDirCtx (name
).getSchemaClassDefinition (name
);
208 public NamingEnumeration
search(Name name
, Attributes matchingAttributes
,
209 String
[] attributesToReturn
)
210 throws NamingException
212 return getURLOrDefaultInitDirCtx (name
).search (name
, matchingAttributes
,
216 public NamingEnumeration
search(String name
, Attributes matchingAttributes
,
217 String
[] attributesToReturn
)
218 throws NamingException
220 return getURLOrDefaultInitDirCtx (name
).search (name
, matchingAttributes
,
224 public NamingEnumeration
search(Name name
, Attributes matchingAttributes
)
225 throws NamingException
227 return getURLOrDefaultInitDirCtx (name
).search (name
, matchingAttributes
);
230 public NamingEnumeration
search(String name
, Attributes matchingAttributes
)
231 throws NamingException
233 return getURLOrDefaultInitDirCtx (name
).search (name
, matchingAttributes
);
236 public NamingEnumeration
search(Name name
, String filter
,
238 throws NamingException
240 return getURLOrDefaultInitDirCtx (name
).search (name
, filter
, cons
);
243 public NamingEnumeration
search(String name
, String filter
,
245 throws NamingException
247 return getURLOrDefaultInitDirCtx (name
).search (name
, filter
, cons
);
250 public NamingEnumeration
search(Name name
, String filterExpr
,
251 Object
[] filterArgs
, SearchControls cons
)
252 throws NamingException
254 return getURLOrDefaultInitDirCtx (name
).search (name
, filterExpr
,
258 public NamingEnumeration
search(String name
, String filterExpr
,
259 Object
[] filterArgs
, SearchControls cons
)
260 throws NamingException
262 return getURLOrDefaultInitDirCtx (name
).search (name
, filterExpr
,