1.6 Narrowing

Narrowing is the act of casting an object to a particular class. In JNDI you will typically narrow objects from a JNDI interface, such as Context or DirContext, to its concrete class, typically part of a Novell provider package.

Narrowing involves using the dynamic features of Java, specifically Java’s syntactical ability to return a string value for the name of a class. This is useful because you can learn the object’s class name, then perform methods supported by the class.

For example, if you were working with an NCPExtensionDirContext, you would narrow the java.lang.Object returned from getValues( ) to the appropriate NJCL class for an NCP extension.