1 2 23 package org.enhydra.tool.codegen; 24 25 import org.enhydra.tool.common.ResUtil; 27 28 import java.util.ArrayList ; 30 import java.util.Arrays ; 31 import java.util.ResourceBundle ; 32 33 36 public class OptionSet { 37 public static ResourceBundle res = ResourceBundle.getBundle("org.enhydra.tool.codegen.Res"); private GeneratorOption[] options = new GeneratorOption[0]; 40 41 44 public OptionSet() {} 45 46 57 public GeneratorOption lookup(String name) throws GeneratorException { 58 GeneratorOption option = null; 59 60 for (int i = 0; i < options.length; i++) { 61 if (options[i].getName().equalsIgnoreCase(name)) { 62 option = options[i]; 63 break; 64 } 65 } 66 if (option == null) { 67 throw new GeneratorException( 68 ResUtil.format(res.getString("Unable_to_lookup"), name)); 69 } 70 return option; 71 } 72 73 80 public void delete(String name) throws GeneratorException { 81 throw new GeneratorException("OptionSet:delete() not implemented"); } 83 84 92 public void add(GeneratorOption newOp) throws GeneratorException { 93 ArrayList list = null; 94 list = new ArrayList (Arrays.asList(options)); 95 list.add(newOp); 96 list.trimToSize(); 97 options = new GeneratorOption[list.size()]; 98 options = (GeneratorOption[]) list.toArray(options); 99 } 100 101 108 public GeneratorOption[] toArray() { 109 return options; 110 } 111 112 } 113 | Popular Tags |