KickJava   Java API By Example, From Geeks To Geeks.

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


1 package de.webman.acl.db;
2
3 import java.sql.ResultSet JavaDoc;
4 import java.sql.SQLException JavaDoc;
5 import com.teamkonzept.db.TKDBTableData;
6 import com.teamkonzept.db.TKQuery;
7
8 /**
9  * $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/db/ObjectCollectionDBData.java,v 1.1 2001/08/20 08:25:08 mischa Exp $
10  *
11  * Data container for object collections.
12  * <P>
13  * Intended use is the selection of a number of object IDs. The selection
14  * may be restricted by an arbitrary parameter.
15  *
16  * @version 0.10
17  * @since 0.10
18  * @author &copy; 2000 Team-Konzept
19  */

20 public class ObjectCollectionDBData
21     extends TKDBTableData
22 {
23
24     // Attributes
25

26     /**
27      * The name of the restricting column.
28      */

29     protected String JavaDoc restrictorName = null;
30
31     /**
32      * The value of the restricting column.
33      */

34     protected Object JavaDoc restrictorValue = null;
35
36     /**
37      * The name of the selecting column.
38      */

39     protected String JavaDoc selectorName = null;
40
41     /**
42      * The value of the selecting column.
43      */

44     protected Integer JavaDoc selectorValue = null;
45
46
47     // Constructors
48

49     /**
50      * Creates a data container for object collections.
51      *
52      * @param restrictorName the name of the restricting column.
53      * @param restrictorValue the value of the restricting column.
54      * @param selectorName the name of the selecting column.
55      * @param selectorValue the value of the selecting column.
56      */

57     public ObjectCollectionDBData (String JavaDoc restrictorName,
58                                      Object JavaDoc restrictorValue,
59                                      String JavaDoc selectorName,
60                                      Integer JavaDoc selectorValue)
61     {
62         this.restrictorName = restrictorName;
63         this.restrictorValue = restrictorValue;
64         this.selectorName = selectorName;
65         this.selectorValue = selectorValue;
66     }
67
68
69     // Method implementations
70

71     /**
72      * Inserts the values of the foreign keys into the given query.
73      *
74      * @param query the query to be executed.
75      * @exception java.sql.SQLException if an database error occured.
76      */

77     public void insertIntoQuery (TKQuery query)
78         throws SQLException JavaDoc
79     {
80         if (this.restrictorName != null)
81         {
82             query.setQueryParams(this.restrictorName, this.restrictorValue);
83         }
84
85         if (this.selectorName != null)
86         {
87             query.setQueryParams(this.selectorName, this.selectorValue);
88         }
89     }
90
91     /**
92      * Returns a data container with the values of the given result set.
93      *
94      * @param result the result set.
95      * @return a data container with the values of the given result set.
96      * @exception java.sql.SQLException if an database error occured.
97      */

98     public TKDBTableData newFromResultSet (ResultSet JavaDoc result)
99         throws SQLException JavaDoc
100     {
101         return new ObjectCollectionDBData(null,
102                                             null,
103                                             null,
104                                             new Integer JavaDoc(result.getInt(this.selectorName)));
105     }
106
107     /**
108      * Returns a data container with the given value.
109      *
110      * @param value the value.
111      * @return a data container with the given value.
112      */

113     public TKDBTableData newFromValue (Integer JavaDoc value)
114     {
115         return new ObjectCollectionDBData(this.restrictorName,
116                                             this.restrictorValue,
117                                             this.selectorName,
118                                             value);
119     }
120
121     /**
122      * Returns the value of the selecting column.
123      *
124      * @return the value of the selecting column.
125      */

126     public Integer JavaDoc getValue ()
127     {
128         return this.selectorValue;
129     }
130
131 }
132
Popular Tags