KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sslexplorer.security;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4
5 import com.sslexplorer.core.CoreUtil;
6 import com.sslexplorer.table.TableItem;
7
8
9 /**
10  * Wrapper object for {@link IpRestriction} represented as items in tables in
11  * the user interface.
12  *
13  * @author Brett Smith <a HREF="mailto:brett@3sp.com">&lt;brett@3sp.com&gt;</a>
14  */

15 public class IpRestrictionItem implements TableItem {
16     
17     // Private instance variables
18

19     private IpRestriction ipRestriction;
20     private boolean canMoveUp, canMoveDown, canDelete;
21
22
23     /**
24      * Constructor
25      *
26      * @param ipRestriction restriction to wrapo
27      * @param canMoveUp restriction can be moved up
28      * @param canMoveDown restriction can be moved dowb
29      * @param canDelete restriction can be deleted
30      */

31     public IpRestrictionItem(IpRestriction ipRestriction, boolean canMoveUp, boolean canMoveDown, boolean canDelete) {
32         this.ipRestriction = ipRestriction;
33         this.canMoveUp = canMoveUp;
34         this.canMoveDown = canMoveDown;
35         this.canDelete = canDelete;
36     }
37     
38     /**
39      * Get if this item may be deleted. As a rule, all restrictions may be
40      * deleted except for the default one.
41      *
42      * @return item can be deleted
43      */

44     public boolean isCanDelete() {
45         return canDelete;
46     }
47     
48     /**
49      * Get if this item may be moved up one row. This will be <code>false</code>
50      * if the item is the first in the list.
51      *
52      * @return item can move up
53      */

54     public boolean isCanMoveUp() {
55         return canMoveUp;
56     }
57     
58     /**
59      * Get if this item may be moved up down row. This will be <code>false</code>
60      * if the item is the last in the list.
61      *
62      * @return item can move down
63      */

64     public boolean isCanMoveDown() {
65         return canMoveDown;
66     }
67     
68     /*
69      * (non-Javadoc)
70      *
71      * @see com.sslexplorer.table.TableItem#getColumnValue(int)
72      */

73     public Object JavaDoc getColumnValue(int col) {
74         switch (col) {
75             case 0:
76                 return ipRestriction.getAddress();
77             default:
78                 return new Boolean JavaDoc("true");
79         }
80     }
81     
82     /**
83      * Get the {@link IpRestriction} this object wraps.
84      *
85      * @return ip restriction
86      */

87     public IpRestriction getIpRestriction() {
88             return ipRestriction;
89     }
90     
91     public String JavaDoc getSmallIconPath(HttpServletRequest JavaDoc request) {
92         if (ipRestriction.getAllowed()){
93             return CoreUtil.getThemePath(request.getSession()) + "/images/actions/allowed.gif";
94         }
95         else {
96             return CoreUtil.getThemePath(request.getSession()) + "/images/actions/denied.gif";
97         }
98     }
99
100 }
101
Popular Tags