|
ShellCommand |
|
1 // joi/6/juno/ShellCommand.java 2 // 3 // 4 // Copyright 2003 Ethan Bolker and Bill Campbell 5 6 import java.util.*; 7 8 /** 9 * Model those features common to all ShellCommands. 10 * 11 * Each concrete extension of this class provides a constructor 12 * and an implementation for method doIt. 13 * 14 * @version 6 15 */ 16 17 public abstract class ShellCommand 18 { 19 private String helpString; // documents the command 20 private String argString; // any args to the command 21 22 /** 23 * A constructor, always called (as super()) by the subclass. 24 * Used only for commands that have arguments. 25 * 26 * @param helpString a brief description of what the command does. 27 * @param argString a prototype illustrating the required arguments. 28 */ 29 30 protected ShellCommand( String helpString, String argString ) 31 { 32 this.argString = argString; 33 this.helpString = helpString; 34 } 35 36 /** 37 * A constructor for commands having no arguments. 38 * 39 * @param helpString a brief description of what the command does. 40 */ 41 42 protected ShellCommand( String helpString ) 43 { 44 this( helpString, "" ); 45 } 46 47 /** 48 * Execute the command. 49 * 50 * @param args the remainder of the command line. 51 * @param sh the current shell 52 */ 53 54 public abstract void doIt( StringTokenizer args, Shell sh ); 55 56 /** 57 * Help for this command. 58 * 59 * @return the help string. 60 */ 61 62 public String getHelpString() 63 { 64 return helpString; 65 } 66 67 /** 68 * The argument string prototype. 69 * 70 * @return the argument string prototype. 71 */ 72 73 public String getArgString() 74 { 75 return argString; 76 } 77 } 78
|
ShellCommand |
|