1 /*** 2 * 3 */ 4 package de.cohesion.bssh; 5 6 /*** 7 * @author schulzs 8 */ 9 public class Timeout extends Option { 10 11 public static final String KEY = "timeout"; 12 13 private static final String HELP_TEXT = "<t>\twhere t is the timeout (per command) in milliseconds"; 14 15 private long timeout; 16 17 public Timeout() { 18 super(KEY, 1, HELP_TEXT); 19 timeout = Long.MAX_VALUE; 20 } 21 22 @Override 23 protected void parse(final String raw) throws ParseException { 24 String stripped = raw.substring(raw.indexOf(' ')).trim(); 25 long value = Long.parseLong(stripped); 26 if (value <= 0) { 27 throw new IllegalArgumentException( 28 "negative or zero timeout not allowed"); 29 } 30 timeout = value; 31 setActive(true); 32 } 33 34 public long getTimeout() { 35 return timeout; 36 } 37 38 }