1
2
3
4
5
6 package net.sf.navigator.example;
7
8 import java.util.ArrayList;
9
10 import net.sf.navigator.menu.MenuComponent;
11 import net.sf.navigator.menu.PermissionsAdapter;
12
13
14 /**
15 *
16 * @author ssayles
17 */
18 public class SimplePermissionsAdapter implements PermissionsAdapter {
19
20
21 private ArrayList menuNames;
22
23
24
25 /**
26 * Creates a new instance of SimplePermissionAdapter
27 */
28 public SimplePermissionsAdapter(String[] theMenuNames) {
29 menuNames = new ArrayList();
30
31 if (theMenuNames != null) {
32 for (int i = 0; i < theMenuNames.length; i++) {
33 menuNames.add(theMenuNames[i]);
34 }
35 }
36 }
37
38
39
40 /**
41 * If the menu is allowed, this should return true.
42 *
43 * @return whether or not the menu is allowed.
44 */
45 public boolean isAllowed(MenuComponent menu) {
46 return !menuNames.contains(menu.getName());
47 }
48 }