1 /*** 2 * 3 */ 4 package de.cohesion.bssh; 5 6 /*** 7 * @author schulzs 8 */ 9 public class Concurrency extends Option { 10 11 public static final String KEY = "concurrency"; 12 13 private static final String HELP_TEXT = "<n> \twhere n is the number of concurrent command threads"; 14 15 public enum Level { 16 FIXED, UNLIMITED; 17 18 private int value; 19 20 void setValue(int value) { 21 this.value = value; 22 } 23 24 public int getValue() { 25 return value; 26 } 27 28 } 29 30 private Level level; 31 32 public Concurrency() { 33 super(KEY, 1, HELP_TEXT); 34 level = Level.UNLIMITED; 35 } 36 37 @Override 38 protected void parse(final String raw) throws ParseException { 39 String stripped = raw.substring(raw.indexOf(' ')).trim(); 40 int value = Integer.parseInt(stripped); 41 if (value <= 0) { 42 throw new IllegalArgumentException( 43 "negative or zero concurrency not allowed"); 44 } 45 level = Level.FIXED; 46 level.setValue(value); 47 setActive(true); 48 } 49 50 public Level getLevel() { 51 return level; 52 } 53 54 }