Changeset 223
- Timestamp:
- 12/29/07 22:45:45 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lex/trunk/src/com/qwirx/lex/emdros/EmdrosDatabase.java
r168 r223 11 11 import java.sql.ResultSet; 12 12 import java.sql.SQLException; 13 import java.util.ArrayList; 13 14 import java.util.Hashtable; 15 import java.util.List; 14 16 import java.util.Map; 15 17 16 18 import jemdros.BadMonadsException; 17 import jemdros.EMdFDBDBError;18 19 import jemdros.EmdrosEnv; 19 import jemdros.EmdrosException;20 20 import jemdros.MatchedObject; 21 21 import jemdros.MonadSetElement; … … 83 83 bDBResult = env.executeString(query, bCompilerResult, false, false); 84 84 } 85 catch (TableException e) 86 { 87 throw new DatabaseException("Failed to execute query", e, query); 88 } 89 catch (BadMonadsException e) 90 { 91 throw new DatabaseException("Failed to execute query", e, query); 92 } 93 catch (EMdFDBDBError e) 94 { 95 throw new DatabaseException("Failed to execute query", e, query); 96 } 97 catch (EmdrosException e) 85 catch (Exception e) 98 86 { 99 87 throw new DatabaseException("Failed to execute query", e, query); … … 175 163 } 176 164 177 public Map getEnumerationConstants(String type, boolean byName) 165 public Map<String, String> getEnumerationConstants(String type, 166 boolean byName) 178 167 throws DatabaseException 179 168 { 180 Hashtable result = new Hashtable();169 Hashtable<String, String> result = new Hashtable<String, String>(); 181 170 182 171 Table table = getTable("SELECT ENUMERATION CONSTANTS FROM "+type); … … 194 183 195 184 if (byName) 185 { 196 186 result.put(name, number); 197 else 198 result.put(number, name); 187 } 188 else 189 { 190 result.put(number, name); 191 } 199 192 } 200 193 } … … 207 200 return result; 208 201 } 209 202 203 public List<String> getEnumerationConstantNames(String type) 204 throws DatabaseException 205 { 206 List<String> result = new ArrayList<String>(); 207 208 String query = "SELECT ENUMERATION CONSTANTS FROM " + type; 209 Table table = getTable(query); 210 211 TableIterator rows = table.iterator(); 212 213 try 214 { 215 while (rows.hasNext()) 216 { 217 TableRow row = rows.next(); 218 String name = row.getColumn(1); 219 // String number = row.getColumn(2); 220 result.add(name); 221 } 222 } 223 catch (TableException e) 224 { 225 throw new DatabaseException("Failed to get enumeration constants", 226 e, query); 227 } 228 229 return result; 230 } 231 232 public String getEnumConstNameFromValue(String enumName, int value) 233 throws DatabaseException 234 { 235 boolean[] dbOK = new boolean[1]; 236 237 String result = env.getEnumConstNameFromValue(value, enumName, dbOK); 238 239 if (!dbOK[0]) 240 { 241 throw new DatabaseException("Failed to get name for enum " + 242 enumName + " value " + value, 243 new Exception(env.getDBError())); 244 } 245 246 return result; 247 } 248 210 249 public String getMonadSet(String query) 211 250 throws DatabaseException
