1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.shared_orchestra.util.el;
20
21 import java.util.*;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 public abstract class ActionsMap implements Map {
44
45 private Set keys;
46
47 public ActionsMap(){
48
49 }
50
51 public ActionsMap(Set keys){
52 this.keys = keys;
53 }
54
55
56
57
58 public abstract void performAction(String command);
59
60 public int size() {
61 return keys.size();
62 }
63
64 public boolean isEmpty() {
65 return keys.isEmpty();
66 }
67
68 public boolean containsKey(Object key) {
69 return keys.contains( key );
70 }
71
72 public boolean containsValue(Object value) {
73 if( ! (value instanceof Boolean) )
74 return false;
75 return ((Boolean)value).booleanValue();
76 }
77
78 public Object get( Object key) {
79 return Boolean.FALSE;
80 }
81
82 public Boolean put(String key, Boolean value) {
83 if( value!=null && value.booleanValue() )
84 performAction( key );
85 return Boolean.FALSE;
86 }
87
88 public Object remove(Object key) {
89 if( keys.remove( key ) )
90 return Boolean.FALSE;
91 return null;
92 }
93
94 public void putAll(Map map) {
95 Iterator it = map.entrySet().iterator();
96
97 while (it.hasNext())
98 {
99 Entry entry = (Entry) it.next();
100 Object obj = entry.getValue();
101 if( (obj instanceof Boolean) && ((Boolean) obj).booleanValue() )
102 performAction( (String) entry.getKey() );
103 }
104 }
105
106 public void clear() {
107 keys.clear();
108 }
109
110 public Set keySet() {
111 return keys;
112 }
113
114 public Collection values() {
115 return Collections.nCopies(keys.size(), Boolean.FALSE);
116 }
117
118 public Set entrySet() {
119 Set set = new HashSet( keys.size() );
120
121 Iterator it = keys.iterator();
122
123 while (it.hasNext())
124 {
125 String command = (String) it.next();
126 set.add( new CommandEntry(command) );
127 }
128
129 return set;
130 }
131
132 private class CommandEntry implements Entry{
133
134 private final String command;
135 private boolean commandPerformed = false;
136
137 public CommandEntry(String command){
138 this.command = command;
139 }
140
141 public Object getKey() {
142 return command;
143 }
144
145 public Object getValue() {
146 return Boolean.valueOf(commandPerformed);
147 }
148
149 public Object setValue(Object performCommand) {
150 if( (performCommand instanceof Boolean) && ((Boolean)performCommand).booleanValue() ){
151 performAction( command );
152 commandPerformed = true;
153 }
154 return Boolean.valueOf(commandPerformed);
155 }
156 }
157 }
158