FileDocCategorySizeDatePackage
list.javaAPI DocExample1574Wed Apr 05 11:25:42 BST 2000None

list

public class list extends Object implements Command

Fields Summary
Constructors Summary
Methods Summary
public voidexecute(javax.naming.Context c, java.util.Vector v)

        
    String name = "";
        
    // An empty string is OK for a list operation as it means
    // list children of the current context.
    if (!(v.isEmpty()))
      name = (String)v.firstElement();
        
    // Check for current context; throw an exception if there isn’t one
    if (NamingShell.getCurrentContext() == null)
      throw new CommandException(new Exception(), 
        "Error: no current context.");

    // Call list() and then loop through the results, printing the names
    // and class names of the children
    try {
      NamingEnumeration enum = c.list(name);                
      while (enum.hasMore()) {
        NameClassPair ncPair = (NameClassPair)enum.next();
        System.out.print(ncPair.getName() + " (type ");
        System.out.println(ncPair.getClassName() + ")");
      }
    }
    catch (NamingException e) {
      throw new CommandException(e, "Couldn't list " + name);
    }
  
public voidhelp()

 System.out.println("Usage: list [name]");