KickJava   Java API By Example, From Geeks To Geeks.

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


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.Login;
8
9 /**
10  * $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/db/LoginDBData.java,v 1.1 2001/08/20 08:25:08 mischa Exp $
11  *
12  * Data container for logins.
13  *
14  * @version 0.10
15  * @since 0.10
16  * @author © 2000 Team-Konzept
17  */

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

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

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

32     private String JavaDoc name = null;
33
34     /**
35      * The type field of the data container.
36      */

37     private String JavaDoc type = null;
38
39
40     // Constructors
41

42     /**
43      * Creates a data container for logins.
44      *
45      * @param id the ID of the login.
46      * @param login the login of the login.
47      * @param name the name of the login.
48      * @param type the type of the login.
49      */

50     public LoginDBData (Integer JavaDoc id,
51                           String JavaDoc login,
52                           String JavaDoc name,
53                           String JavaDoc type)
54     {
55         super(id);
56
57         this.name = name;
58         this.login = login;
59         this.type = type;
60     }
61
62     /**
63      * Creates a data container for logins.
64      *
65      * @param login the login.
66      */

67     public LoginDBData (Login login)
68     {
69         super(login);
70
71         this.login = login.getLogin();
72         this.name = login.getName();
73         this.type = login.isUser()
74                          ? LoginDBInterface.TYPE_USER
75                          : LoginDBInterface.TYPE_PROFILE;
76     }
77
78
79     // Method implementations
80

81     /**
82      * Returns the database interface.
83      *
84      * @return the database interface.
85      */

86     public final ObjectDBInterface getDBInterface ()
87     {
88         return LoginDBInterface.getInstance();
89     }
90
91     /**
92      * Inserts initial data into the given query.
93      * <P>
94      * This method is used for <CODE>INSERT</CODE> statements.
95      *
96      * @param query the query to be executed.
97      * @exception java.sql.SQLException if an database error occured.
98      */

99     public void insertInitialIntoQuery (TKQuery query)
100         throws SQLException JavaDoc
101     {
102         super.insertInitialIntoQuery(query);
103
104         query.setQueryParams(LoginDBInterface.LOGIN_COLUMN, this.login);
105         query.setQueryParams(LoginDBInterface.NAME_COLUMN, this.name);
106         query.setQueryParams(LoginDBInterface.TYPE_COLUMN, this.type);
107     }
108
109     /**
110      * Reads all data from the given result set.
111      * <P>
112      * This method is used for <CODE>SELECT</CODE> and
113      * <CODE>INSERT</CODE> statements.
114      *
115      * @param result the result set to be read.
116      * @exception java.sql.SQLException if an database error occured.
117      */

118     public void fill (ResultSet JavaDoc result)
119         throws SQLException JavaDoc
120     {
121         this.login = result.getString(LoginDBInterface.LOGIN_COLUMN);
122         this.name = result.getString(LoginDBInterface.NAME_COLUMN);
123         this.type = result.getString(LoginDBInterface.TYPE_COLUMN);
124
125         super.fill(result);
126     }
127
128     /**
129      * Returns the name field of the data container.
130      *
131      * @return the name field of the data container.
132      */

133     public final String JavaDoc getName ()
134     {
135         return this.name;
136     }
137
138     /**
139      * Returns the login field of the data container.
140      *
141      * @return the login field of the data container.
142      */

143     public final String JavaDoc getLogin ()
144     {
145         return this.login;
146     }
147
148     /**
149      * Checks wether the data container belongs to a user.
150      *
151      * @return <CODE>true</CODE> if the data container belongs to a user,
152      * otherwise <CODE>false</CODE>.
153      */

154     public final boolean isUser ()
155     {
156         return type != null && type.equals(LoginDBInterface.TYPE_USER);
157     }
158
159     /**
160      * Checks wether the data container belongs to a profile.
161      *
162      * @return <CODE>true</CODE> if the data container belongs to a profile,
163      * otherwise <CODE>false</CODE>.
164      */

165     public final boolean isProfile ()
166     {
167         return type != null && type.equals(LoginDBInterface.TYPE_PROFILE);
168     }
169
170 }
171
Popular Tags