Source code: com/RuntimeCollective/webapps/bean/SimpleActor.java
1 /* $Header: /home/CVS/rjp/src/com/RuntimeCollective/webapps/bean/SimpleActor.java,v 1.10 2003/09/30 15:13:09 joe Exp $
2 * $Revision: 1.10 $
3 * $Date: 2003/09/30 15:13:09 $
4 *
5 * ====================================================================
6 *
7 * Josephine : http://www.runtime-collective.com/josephine/index.html
8 *
9 * Copyright (C) 2003 Runtime Collective
10 *
11 * This product includes software developed by the
12 * Apache Software Foundation (http://www.apache.org/).
13 *
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 */
29
30 package com.RuntimeCollective.webapps.bean;
31
32 import java.util.Date;
33 import java.sql.SQLException;
34
35 /** A simple abstract implementation of the Actor interface that exposes the properties of the underlying User.
36 *
37 * @see com.RuntimeCollective.webapps.bean.SimpleUser
38 * @see com.RuntimeCollective.webapps.bean.User
39 * @see com.RuntimeCollective.webapps.bean.Actor
40 * @version $Id: SimpleActor.java,v 1.10 2003/09/30 15:13:09 joe Exp $
41 */
42 public abstract class SimpleActor implements Actor {
43
44
45 /** The User that this actor wraps. */
46 protected User user;
47 /** Get the User that this Actor wraps. */
48 public User getUser() { return this.user; }
49 /** Set the User that this Actor wraps. */
50 public void setUser( User user ) { this.user=user; }
51
52 /** The ID of this actor.
53 * NB. this will be different from the id of the underlying user. */
54 protected int id;
55 /** Get the actor's ID.
56 * NB. this will be different from the id of the underlying user. */
57 public int getId() { return (this.id); }
58 /** Set the actor's ID.
59 * NB. this will be different from the id of the underlying user. */
60 public void setId(int id) { this.id = id; }
61
62 // Expose the properties of the underlying user:
63 public void setEmail( String email ) { user.setEmail( email ); }
64 public String getEmail() { return user.getEmail(); }
65 public void setPassword( String password ) { user.setPassword( password ); }
66 public String getPassword() { return user.getPassword(); }
67 public String getFirstName() { return user.getFirstName(); }
68 public void setFirstName( String firstName) { user.setFirstName( firstName); }
69 public String getLastName() { return user.getLastName(); }
70 public void setLastName( String lastName) { user.setLastName( lastName); }
71 public void setCreateDate( Date createDate ) { user.setCreateDate( createDate ); }
72 public Date getCreateDate() { return user.getCreateDate(); }
73 public void setRoles(int[] roles) { user.setRoles( roles ); }
74 public int[] getRoles() { return user.getRoles(); }
75 public boolean hasRole(int role){ return user.hasRole( role ); }
76 public void setAddress( Address address) { user.setAddress(address); }
77 public Address getAddress() { return user.getAddress(); }
78
79 public void addRole(int role) throws SQLException { user.addRole(role); }
80 public void removeRole(int role) throws SQLException { user.removeRole(role); }
81
82
83 /** Get the value of an attribute. Null is returned if the attribute for this name has not been.
84 */
85 public Object getAttribute( String name ) {
86 return user.getAttribute( name );
87 }
88
89 /** Set the value of an attribute. */
90 public void setAttribute( String name, Object value ) {
91 user.setAttribute( name, value );
92 }
93 }