1 16 package scriptella.util; 17 18 import java.util.Map ; 19 20 27 public class ColumnsMap { 28 private Map <String , Integer > map; 29 30 37 public void registerColumn(String name, int index) throws IllegalArgumentException { 38 if (index <= 0) { 39 throw new IllegalArgumentException ("Index must be positive integer"); 40 } 41 if (map == null) { 42 map = CollectionUtils.newCaseInsensitiveAsciiMap(); 43 } 44 map.put(name, index); 45 } 46 47 53 public Integer find(String name) { 54 if (name == null) { 55 throw new IllegalArgumentException ("Parameter name cannot be null"); 56 } 57 Integer index = map == null ? null : map.get(name); 58 if (index == null && StringUtils.isDecimalInt(name)) { 60 index = Integer.valueOf(name); } 62 return index; 63 } 64 65 66 } 67 | Popular Tags |