|
JunoTerminal |
|
1 // joi/10/juno/JunoTerminal.java 2 // 3 // 4 // Copyright 2003 Bill Campbell and Ethan Bolker 5 6 /** 7 * A Command line interface terminal for Juno. 8 * 9 * @version 10 10 */ 11 12 public class JunoTerminal 13 implements InputInterface, OutputInterface 14 { 15 private Terminal terminal; // the delegate terminal 16 private boolean echo; // are we echoing input? 17 18 /** 19 * Construct a JunoTerminal 20 * 21 * Allows for input echo, when, for example, input is redirected 22 * from a file. 23 * 24 * @param echo whether or not input should be echoed. 25 */ 26 27 public JunoTerminal( boolean echo ) 28 { 29 this.echo = echo; 30 terminal = new Terminal( echo ); 31 } 32 33 // Implement InputInterface 34 35 /** 36 * Read a line (terminated by a newline). 37 * 38 * @param promptString output string to prompt for input 39 * @return the string (without the newline character) 40 */ 41 42 public String readLine( String promptString ) 43 { 44 return terminal.readLine( promptString ); 45 } 46 47 // Implement OutputInterface 48 49 /** 50 * Write a String followed by a newline 51 * to console output location. 52 * 53 * @param str - the string to write 54 */ 55 56 public void println(String str ) 57 { 58 terminal.println( str ); 59 } 60 61 /** 62 * Write a String followed by a newline 63 * to console error output location. 64 * 65 * @param str - the String to write 66 */ 67 68 public void errPrintln(String str ) 69 { 70 terminal.errPrintln( str ); 71 } 72 73 /** 74 * Query what kind of console this is. 75 * 76 * @return true if and only if echoing input. 77 */ 78 79 public boolean isEchoInput() 80 { 81 return echo; 82 } 83 84 /** 85 * Query what kind of console this is. 86 * 87 * @return false, since it is not a GUI 88 */ 89 90 public boolean isGUI() 91 { 92 return false; 93 } 94 95 /** 96 * Query what kind of console this is. 97 * 98 * @return false, since it is not remote. 99 */ 100 101 public boolean isRemote() 102 { 103 return false; 104 } 105 } 106
|
JunoTerminal |
|