KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ashkelon > ThrownException


1 package org.ashkelon;
2 /**
3  * Ashkelon
4  * Copyright UptoData Inc. 2001
5  * March 2001
6  */

7
8 import java.io.Serializable JavaDoc;
9 import java.sql.Connection JavaDoc;
10 import java.sql.SQLException JavaDoc;
11 import java.util.HashMap JavaDoc;
12 import java.util.Map JavaDoc;
13
14 import org.ashkelon.db.DBUtils;
15 import org.ashkelon.util.StringUtils;
16
17 /**
18  * Part of Persistable javadoc object model
19  * Analog of com.sun.javadoc.ThrowsTag
20  *
21  * @author Eitan Suez
22  * @version 2.0
23  */

24 public class ThrownException implements Serializable JavaDoc
25 {
26    private ExecMember thrower;
27    private ClassType exception;
28    private String JavaDoc name;
29    private String JavaDoc description;
30    
31    private static String JavaDoc TABLENAME = "THROWNEXCEPTION";
32    
33    public ThrownException(String JavaDoc name)
34    {
35       setName(name);
36       setDescription("");
37    }
38    
39    public ThrownException(String JavaDoc name, String JavaDoc description, ExecMember thrower)
40    {
41       setName(name);
42       setDescription(description);
43       setThrower(thrower);
44    }
45    
46    public void store(Connection JavaDoc conn) throws SQLException JavaDoc
47    {
48       Map JavaDoc fieldInfo = new HashMap JavaDoc(5);
49       fieldInfo.put("NAME", StringUtils.truncate(getName(), 150));
50       fieldInfo.put("DESCRIPTION", getDescription());
51       fieldInfo.put("THROWERID", new Integer JavaDoc(getThrower().getId(conn)));
52       
53       try
54       {
55          DBUtils.insert(conn, TABLENAME, fieldInfo);
56       }
57       catch (SQLException JavaDoc 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 JavaDoc getName() { return name; }
71    public void setName(String JavaDoc name) { this.name = name; }
72    
73    public String JavaDoc getDescription() { return description; }
74    public void setDescription(String JavaDoc description) { this.description = description; }
75   
76 }
Popular Tags