Changeset 288

Show
Ignore:
Timestamp:
05/19/08 20:23:48 (8 months ago)
Author:
chris
Message:

Catch SQLException and throw DatabaseException? in Lexeme.load()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lex/trunk/src/com/qwirx/lex/lexicon/Lexeme.java

    r259 r288  
    261261 
    262262    private static Lexeme load(SqlDatabase sqldb, ResultSet rs)  
    263     throws SQLException 
    264     { 
    265         Lexeme l = new Lexeme(sqldb); 
    266          
    267         l.id       = rs.getInt("ID"); 
    268         l.surface  = rs.getString("Lexeme"); 
    269         l.m_Gloss    = rs.getString("Gloss"); 
    270         l.label    = rs.getString("Domain_Label"); 
    271         l.desc     = rs.getString("Domain_Desc"); 
    272         l.parentId = rs.getInt("Domain_Parent_ID"); 
    273         l.numSyntacticArgs = rs.getInt("Syntactic_Args"); 
    274  
    275         l.setCaused         (rs.getInt("Caused")           == 1); 
    276         l.setPunctual       (rs.getInt("Punctual")         == 1); 
    277         l.setHasResultState (rs.getInt("Has_Result_State") == 1); 
    278         l.setTelic          (rs.getInt("Telic")            == 1); 
    279         l.setDynamic        (rs.getInt("Dynamic")          == 1); 
    280         l.setHasEndpoint    (rs.getInt("Has_Endpoint")     == 1); 
    281  
    282         l.setPredicate      (rs.getString("Predicate")); 
    283         l.setResultPredicate(rs.getString("Result_Predicate")); 
    284         l.setResultPredicateArg(rs.getString("Result_Predicate_Arg")); 
    285          
    286         l.setThematicRelation(ThematicRelation.get( 
    287             rs.getString("Thematic_Relation"))); 
    288          
    289         return l; 
     263    throws DatabaseException 
     264    { 
     265        try 
     266        { 
     267            Lexeme l = new Lexeme(sqldb); 
     268             
     269            l.id       = rs.getInt("ID"); 
     270            l.surface  = rs.getString("Lexeme"); 
     271            l.m_Gloss    = rs.getString("Gloss"); 
     272            l.label    = rs.getString("Domain_Label"); 
     273            l.desc     = rs.getString("Domain_Desc"); 
     274            l.parentId = rs.getInt("Domain_Parent_ID"); 
     275            l.numSyntacticArgs = rs.getInt("Syntactic_Args"); 
     276     
     277            l.setCaused         (rs.getInt("Caused")           == 1); 
     278            l.setPunctual       (rs.getInt("Punctual")         == 1); 
     279            l.setHasResultState (rs.getInt("Has_Result_State") == 1); 
     280            l.setTelic          (rs.getInt("Telic")            == 1); 
     281            l.setDynamic        (rs.getInt("Dynamic")          == 1); 
     282            l.setHasEndpoint    (rs.getInt("Has_Endpoint")     == 1); 
     283     
     284            l.setPredicate      (rs.getString("Predicate")); 
     285            l.setResultPredicate(rs.getString("Result_Predicate")); 
     286            l.setResultPredicateArg(rs.getString("Result_Predicate_Arg")); 
     287             
     288            l.setThematicRelation(ThematicRelation.get( 
     289                rs.getString("Thematic_Relation"))); 
     290             
     291            return l; 
     292        } 
     293        catch (SQLException e) 
     294        { 
     295            throw new DatabaseException("Failed to load lexeme from ResultSet", 
     296                e); 
     297        } 
    290298    } 
    291299     
     
    300308 
    301309    public static Lexeme load(SqlDatabase sqldb, int id) 
    302     throws DatabaseException, SQLException 
     310    throws DatabaseException 
    303311    { 
    304312        Lexeme result = null; 
     
    319327            result = load(sqldb, rs); 
    320328        }  
     329        catch (SQLException e) 
     330        { 
     331            throw new DatabaseException("Failed to load lexeme", e); 
     332        } 
    321333        finally  
    322334        {