1 33 34 package edu.rice.cs.drjava.config; 35 import java.util.Collection ; 36 import java.util.Iterator ; 37 38 39 45 public class ForcedChoiceOption extends Option<String > 46 { 47 private Collection <String > _choices; 48 49 54 public ForcedChoiceOption(String key, String def, Collection <String > choices) { 55 super(key,def); 56 _choices = choices; 57 } 58 59 66 public boolean isLegal(String s) { 67 return _choices.contains(s); 68 } 69 70 74 public Iterator <String > getLegalValues() { 75 return _choices.iterator(); 76 } 77 78 82 public int getNumValues() { 83 return _choices.size(); 84 } 85 86 92 public String parse(String s) 93 { 94 if (isLegal(s)) { 95 return s; 96 } 97 else { 98 throw new OptionParseException(name, s, "Value is not an acceptable choice for this option."); 99 } 100 } 101 102 106 public String format(String s) { 107 return s; 108 } 109 } 110 | Popular Tags |