KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > console > examples > HelloWorldFactory


1 package org.sapia.console.examples;
2
3 import org.sapia.console.Command;
4 import org.sapia.console.CommandFactory;
5 import org.sapia.console.CommandNotFoundException;
6
7
8 /**
9  * @author Yanick Duchesne
10  * 2-May-2003
11  */

12 public class HelloWorldFactory implements CommandFactory {
13   /**
14    * Constructor for HelloWorldFactory.
15    */

16   public HelloWorldFactory() {
17     super();
18   }
19
20   /**
21    * @see org.sapia.console.CommandFactory#getCommandFor(String)
22    */

23   public Command getCommandFor(String JavaDoc name) throws CommandNotFoundException {
24     if (name.equalsIgnoreCase("hello")) {
25       return new HelloWorldCommand();
26     } else if (name.equalsIgnoreCase("quit") || name.equalsIgnoreCase("exit")) {
27       return new QuitCommand();
28     } else {
29       throw new CommandNotFoundException(name);
30     }
31   }
32 }
33
Popular Tags