1 7 8 9 package javax.naming.directory; 10 11 import java.util.Hashtable ; 12 import javax.naming.spi.NamingManager ; 13 import javax.naming.*; 14 15 28 29 public class InitialDirContext extends InitialContext implements DirContext { 30 31 48 protected InitialDirContext(boolean lazy) throws NamingException { 49 super(lazy); 50 } 51 52 61 public InitialDirContext() throws NamingException { 62 super(); 63 } 64 65 79 public InitialDirContext(Hashtable <?,?> environment) 80 throws NamingException 81 { 82 super(environment); 83 } 84 85 private DirContext getURLOrDefaultInitDirCtx(String name) 86 throws NamingException { 87 Context answer = getURLOrDefaultInitCtx(name); 88 if (!(answer instanceof DirContext )) { 89 if (answer == null) { 90 throw new NoInitialContextException(); 91 } else { 92 throw new NotContextException( 93 "Not an instance of DirContext"); 94 } 95 } 96 return (DirContext )answer; 97 } 98 99 private DirContext getURLOrDefaultInitDirCtx(Name name) 100 throws NamingException { 101 Context answer = getURLOrDefaultInitCtx(name); 102 if (!(answer instanceof DirContext )) { 103 if (answer == null) { 104 throw new NoInitialContextException(); 105 } else { 106 throw new NotContextException( 107 "Not an instance of DirContext"); 108 } 109 } 110 return (DirContext )answer; 111 } 112 113 116 public Attributes getAttributes(String name) 117 throws NamingException { 118 return getAttributes(name, null); 119 } 120 121 public Attributes getAttributes(String name, String [] attrIds) 122 throws NamingException { 123 return getURLOrDefaultInitDirCtx(name).getAttributes(name, attrIds); 124 } 125 126 public Attributes getAttributes(Name name) 127 throws NamingException { 128 return getAttributes(name, null); 129 } 130 131 public Attributes getAttributes(Name name, String [] attrIds) 132 throws NamingException { 133 return getURLOrDefaultInitDirCtx(name).getAttributes(name, attrIds); 134 } 135 136 public void modifyAttributes(String name, int mod_op, Attributes attrs) 137 throws NamingException { 138 getURLOrDefaultInitDirCtx(name).modifyAttributes(name, mod_op, attrs); 139 } 140 141 public void modifyAttributes(Name name, int mod_op, Attributes attrs) 142 throws NamingException { 143 getURLOrDefaultInitDirCtx(name).modifyAttributes(name, mod_op, attrs); 144 } 145 146 public void modifyAttributes(String name, ModificationItem [] mods) 147 throws NamingException { 148 getURLOrDefaultInitDirCtx(name).modifyAttributes(name, mods); 149 } 150 151 public void modifyAttributes(Name name, ModificationItem [] mods) 152 throws NamingException { 153 getURLOrDefaultInitDirCtx(name).modifyAttributes(name, mods); 154 } 155 156 public void bind(String name, Object obj, Attributes attrs) 157 throws NamingException { 158 getURLOrDefaultInitDirCtx(name).bind(name, obj, attrs); 159 } 160 161 public void bind(Name name, Object obj, Attributes attrs) 162 throws NamingException { 163 getURLOrDefaultInitDirCtx(name).bind(name, obj, attrs); 164 } 165 166 public void rebind(String name, Object obj, Attributes attrs) 167 throws NamingException { 168 getURLOrDefaultInitDirCtx(name).rebind(name, obj, attrs); 169 } 170 171 public void rebind(Name name, Object obj, Attributes attrs) 172 throws NamingException { 173 getURLOrDefaultInitDirCtx(name).rebind(name, obj, attrs); 174 } 175 176 public DirContext createSubcontext(String name, Attributes attrs) 177 throws NamingException { 178 return getURLOrDefaultInitDirCtx(name).createSubcontext(name, attrs); 179 } 180 181 public DirContext createSubcontext(Name name, Attributes attrs) 182 throws NamingException { 183 return getURLOrDefaultInitDirCtx(name).createSubcontext(name, attrs); 184 } 185 186 public DirContext getSchema(String name) throws NamingException { 187 return getURLOrDefaultInitDirCtx(name).getSchema(name); 188 } 189 190 public DirContext getSchema(Name name) throws NamingException { 191 return getURLOrDefaultInitDirCtx(name).getSchema(name); 192 } 193 194 public DirContext getSchemaClassDefinition(String name) 195 throws NamingException { 196 return getURLOrDefaultInitDirCtx(name).getSchemaClassDefinition(name); 197 } 198 199 public DirContext getSchemaClassDefinition(Name name) 200 throws NamingException { 201 return getURLOrDefaultInitDirCtx(name).getSchemaClassDefinition(name); 202 } 203 204 206 public NamingEnumeration<SearchResult > 207 search(String name, Attributes matchingAttributes) 208 throws NamingException 209 { 210 return getURLOrDefaultInitDirCtx(name).search(name, matchingAttributes); 211 } 212 213 public NamingEnumeration<SearchResult > 214 search(Name name, Attributes matchingAttributes) 215 throws NamingException 216 { 217 return getURLOrDefaultInitDirCtx(name).search(name, matchingAttributes); 218 } 219 220 public NamingEnumeration<SearchResult > 221 search(String name, 222 Attributes matchingAttributes, 223 String [] attributesToReturn) 224 throws NamingException 225 { 226 return getURLOrDefaultInitDirCtx(name).search(name, 227 matchingAttributes, 228 attributesToReturn); 229 } 230 231 public NamingEnumeration<SearchResult > 232 search(Name name, 233 Attributes matchingAttributes, 234 String [] attributesToReturn) 235 throws NamingException 236 { 237 return getURLOrDefaultInitDirCtx(name).search(name, 238 matchingAttributes, 239 attributesToReturn); 240 } 241 242 public NamingEnumeration<SearchResult > 243 search(String name, 244 String filter, 245 SearchControls cons) 246 throws NamingException 247 { 248 return getURLOrDefaultInitDirCtx(name).search(name, filter, cons); 249 } 250 251 public NamingEnumeration<SearchResult > 252 search(Name name, 253 String filter, 254 SearchControls cons) 255 throws NamingException 256 { 257 return getURLOrDefaultInitDirCtx(name).search(name, filter, cons); 258 } 259 260 public NamingEnumeration<SearchResult > 261 search(String name, 262 String filterExpr, 263 Object [] filterArgs, 264 SearchControls cons) 265 throws NamingException 266 { 267 return getURLOrDefaultInitDirCtx(name).search(name, filterExpr, 268 filterArgs, cons); 269 } 270 271 public NamingEnumeration<SearchResult > 272 search(Name name, 273 String filterExpr, 274 Object [] filterArgs, 275 SearchControls cons) 276 throws NamingException 277 { 278 return getURLOrDefaultInitDirCtx(name).search(name, filterExpr, 279 filterArgs, cons); 280 } 281 } 282 | Popular Tags |