1 package org.ashkelon; 2 7 8 import java.io.Serializable ; 9 import java.sql.Connection ; 10 import java.sql.SQLException ; 11 import java.util.HashMap ; 12 import java.util.Map ; 13 14 import org.ashkelon.db.DBUtils; 15 import org.ashkelon.util.StringUtils; 16 17 24 public class ThrownException implements Serializable 25 { 26 private ExecMember thrower; 27 private ClassType exception; 28 private String name; 29 private String description; 30 31 private static String TABLENAME = "THROWNEXCEPTION"; 32 33 public ThrownException(String name) 34 { 35 setName(name); 36 setDescription(""); 37 } 38 39 public ThrownException(String name, String description, ExecMember thrower) 40 { 41 setName(name); 42 setDescription(description); 43 setThrower(thrower); 44 } 45 46 public void store(Connection conn) throws SQLException 47 { 48 Map fieldInfo = new HashMap (5); 49 fieldInfo.put("NAME", StringUtils.truncate(getName(), 150)); 50 fieldInfo.put("DESCRIPTION", getDescription()); 51 fieldInfo.put("THROWERID", new Integer (getThrower().getId(conn))); 52 53 try 54 { 55 DBUtils.insert(conn, TABLENAME, fieldInfo); 56 } 57 catch (SQLException ex) 58 { 59 fieldInfo.put("DESCRIPTION", StringUtils.truncate(getDescription(), 350)); 60 DBUtils.insert(conn, TABLENAME, fieldInfo); 61 } 62 } 63 64 public ExecMember getThrower() { return thrower; } 65 public void setThrower(ExecMember thrower) { this.thrower = thrower; } 66 67 public ClassType getException() { return exception; } 68 public void setException(ClassType exception) { this.exception = exception; } 69 70 public String getName() { return name; } 71 public void setName(String name) { this.name = name; } 72 73 public String getDescription() { return description; } 74 public void setDescription(String description) { this.description = description; } 75 76 } | Popular Tags |