001: package de.webman.acl.db;
002:
003: import java.sql.ResultSet;
004: import java.sql.SQLException;
005: import com.teamkonzept.db.TKQuery;
006: import com.teamkonzept.lib.TKVector;
007: import de.webman.acl.Login;
008:
009: /**
010: * $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/db/LoginDBData.java,v 1.1 2001/08/20 08:25:08 mischa Exp $
011: *
012: * Data container for logins.
013: *
014: * @version 0.10
015: * @since 0.10
016: * @author © 2000 Team-Konzept
017: */
018: public class LoginDBData extends ObjectDBData {
019:
020: // Attributes
021:
022: /**
023: * The login field of the data container.
024: */
025: private String login = null;
026:
027: /**
028: * The name field of the data container.
029: */
030: private String name = null;
031:
032: /**
033: * The type field of the data container.
034: */
035: private String type = null;
036:
037: // Constructors
038:
039: /**
040: * Creates a data container for logins.
041: *
042: * @param id the ID of the login.
043: * @param login the login of the login.
044: * @param name the name of the login.
045: * @param type the type of the login.
046: */
047: public LoginDBData(Integer id, String login, String name,
048: String type) {
049: super (id);
050:
051: this .name = name;
052: this .login = login;
053: this .type = type;
054: }
055:
056: /**
057: * Creates a data container for logins.
058: *
059: * @param login the login.
060: */
061: public LoginDBData(Login login) {
062: super (login);
063:
064: this .login = login.getLogin();
065: this .name = login.getName();
066: this .type = login.isUser() ? LoginDBInterface.TYPE_USER
067: : LoginDBInterface.TYPE_PROFILE;
068: }
069:
070: // Method implementations
071:
072: /**
073: * Returns the database interface.
074: *
075: * @return the database interface.
076: */
077: public final ObjectDBInterface getDBInterface() {
078: return LoginDBInterface.getInstance();
079: }
080:
081: /**
082: * Inserts initial data into the given query.
083: * <P>
084: * This method is used for <CODE>INSERT</CODE> statements.
085: *
086: * @param query the query to be executed.
087: * @exception java.sql.SQLException if an database error occured.
088: */
089: public void insertInitialIntoQuery(TKQuery query)
090: throws SQLException {
091: super .insertInitialIntoQuery(query);
092:
093: query.setQueryParams(LoginDBInterface.LOGIN_COLUMN, this .login);
094: query.setQueryParams(LoginDBInterface.NAME_COLUMN, this .name);
095: query.setQueryParams(LoginDBInterface.TYPE_COLUMN, this .type);
096: }
097:
098: /**
099: * Reads all data from the given result set.
100: * <P>
101: * This method is used for <CODE>SELECT</CODE> and
102: * <CODE>INSERT</CODE> statements.
103: *
104: * @param result the result set to be read.
105: * @exception java.sql.SQLException if an database error occured.
106: */
107: public void fill(ResultSet result) throws SQLException {
108: this .login = result.getString(LoginDBInterface.LOGIN_COLUMN);
109: this .name = result.getString(LoginDBInterface.NAME_COLUMN);
110: this .type = result.getString(LoginDBInterface.TYPE_COLUMN);
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 getName() {
121: return this .name;
122: }
123:
124: /**
125: * Returns the login field of the data container.
126: *
127: * @return the login field of the data container.
128: */
129: public final String getLogin() {
130: return this .login;
131: }
132:
133: /**
134: * Checks wether the data container belongs to a user.
135: *
136: * @return <CODE>true</CODE> if the data container belongs to a user,
137: * otherwise <CODE>false</CODE>.
138: */
139: public final boolean isUser() {
140: return type != null && type.equals(LoginDBInterface.TYPE_USER);
141: }
142:
143: /**
144: * Checks wether the data container belongs to a profile.
145: *
146: * @return <CODE>true</CODE> if the data container belongs to a profile,
147: * otherwise <CODE>false</CODE>.
148: */
149: public final boolean isProfile() {
150: return type != null
151: && type.equals(LoginDBInterface.TYPE_PROFILE);
152: }
153:
154: }
|