KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > security > RoleItem


1 /*
2  */

3 package com.sslexplorer.security;
4
5 import java.util.List JavaDoc;
6
7 import javax.servlet.http.HttpServletRequest JavaDoc;
8
9 import com.sslexplorer.core.CoreUtil;
10 import com.sslexplorer.table.TableItem;
11
12 /**
13  *
14  * Implementation of {@link TableItem} suitable for display configured
15  * <i>Groups</i> (previously known as <i>Roles</i>.
16  *
17  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
18  */

19 public class RoleItem implements TableItem {
20
21     // Private instance variables
22

23     private Role role;
24     private List JavaDoc accounts;
25
26     /**
27      * Constructor.
28      *
29      * @param role role
30      * @param accounts accounts
31      */

32     public RoleItem(Role role, List JavaDoc accounts) {
33         this.role = role;
34         this.accounts = accounts;
35     }
36     
37     /**
38      * Get the accounts ({@link User} objects attached to this
39      * role
40      */

41     public List JavaDoc getAccounts() {
42         return accounts;
43     }
44     
45     /**
46      * Get if there are multiple accounts attached to this role
47      *
48      * @return accounts
49      */

50     public boolean getMultipleAccounts() {
51         return accounts.size() > 1;
52     }
53     
54     /**
55      * Get the account name of the first user in this role
56      *
57      * @return first account in role
58      */

59     public String JavaDoc getFirstAccountName() {
60         return accounts.size() > 0 ? ((User)accounts.get(0)).getPrincipalName() : "";
61     }
62
63     /**
64      * Get the role this item wraps
65      *
66      * @return role
67      */

68     public Role getRole() {
69         return role;
70     }
71
72     public Object JavaDoc getColumnValue(int col) {
73         switch (col) {
74             case 0:
75                 return role.getPrincipalName();
76             default:
77                 return getFirstAccountName();
78         }
79     }
80     
81     /**
82      * @return String
83      */

84     public String JavaDoc getLink() {
85         return "#";
86     }
87     
88     /**
89      * @return String
90      */

91     public String JavaDoc getOnClick() {
92         return "";
93     }
94
95     public String JavaDoc getSmallIconPath(HttpServletRequest JavaDoc request) {
96         return CoreUtil.getThemePath(request.getSession()) + "/images/actions/group.gif";
97     }
98
99 }
100
Popular Tags