KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > acl > db > TaskDBData


1 package de.webman.acl.db;
2
3 import java.sql.ResultSet JavaDoc;
4 import java.sql.SQLException JavaDoc;
5 import com.teamkonzept.db.TKQuery;
6 import com.teamkonzept.lib.TKVector;
7 import de.webman.acl.Task;
8
9 /**
10  * $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/db/TaskDBData.java,v 1.1 2001/08/20 08:25:08 mischa Exp $
11  *
12  * Data container for tasks.
13  *
14  * @version 0.10
15  * @since 0.10
16  * @author © 2000 Team-Konzept
17  */

18 public class TaskDBData
19     extends ObjectDBData
20 {
21
22     // Attributes
23

24     /**
25      * The name field of the data container.
26      */

27     private String JavaDoc name = null;
28
29     /**
30      * The context field of the data container.
31      */

32     private Integer JavaDoc context = null;
33
34
35     // Constructors
36

37     /**
38      * Creates a data container for tasks.
39      *
40      * @param id the ID of the task.
41      * @param name the name of the task.
42      * @param context the context of the task.
43      */

44     public TaskDBData (Integer JavaDoc id,
45                          String JavaDoc name,
46                          Integer JavaDoc context)
47     {
48         super(id);
49
50         this.name = name;
51         this.context = context;
52     }
53
54     /**
55      * Creates a data container for tasks.
56      *
57      * @param task the task.
58      */

59     public TaskDBData (Task task)
60     {
61         super(task);
62
63         this.name = task.getName();
64         this.context = task.getContextID();
65     }
66
67
68     // Method implementations
69

70     /**
71      * Returns the database interface.
72      *
73      * @return the database interface.
74      */

75     public final ObjectDBInterface getDBInterface ()
76     {
77         return TaskDBInterface.getInstance();
78     }
79
80     /**
81      * Inserts initial data into the given query.
82      * <P>
83      * This method is used for <CODE>INSERT</CODE> statements.
84      *
85      * @param query the query to be executed.
86      * @exception java.sql.SQLException if an database error occured.
87      */

88     public void insertInitialIntoQuery (TKQuery query)
89         throws SQLException JavaDoc
90     {
91         super.insertInitialIntoQuery(query);
92
93         query.setQueryParams("NAME", this.name);
94         query.setQueryParams(ContextDBInterface.getInstance().getPrimaryKeyName(), this.context);
95     }
96
97     /**
98      * Reads all data from the given result set.
99      * <P>
100      * This method is used for <CODE>SELECT</CODE> and
101      * <CODE>INSERT</CODE> statements.
102      *
103      * @param result the result set to be read.
104      * @exception java.sql.SQLException if an database error occured.
105      */

106     public void fill (ResultSet JavaDoc result)
107         throws SQLException JavaDoc
108     {
109         this.name = result.getString("NAME");
110         this.context = new Integer JavaDoc(result.getInt(ContextDBInterface.getInstance().getPrimaryKeyName()));
111
112         super.fill(result);
113     }
114
115     /**
116      * Returns the name field of the data container.
117      *
118      * @return the name field of the data container.
119      */

120     public final String JavaDoc getName ()
121     {
122         return this.name;
123     }
124
125     /**
126      * Returns the context field of the data container.
127      *
128      * @return the context field of the data container.
129      */

130     public final Integer JavaDoc getContext ()
131     {
132         return this.context;
133     }
134
135 }
136
Popular Tags