1 package org.apache.maven.plugin.invoker;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Collection;
23 import java.util.Map;
24 import java.util.Properties;
25 import java.util.Set;
26
27 import org.apache.maven.project.MavenProject;
28 import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
29
30
31
32
33
34
35
36
37 class CompositeMap
38 implements Map
39 {
40
41
42
43
44 private MavenProject mavenProject;
45
46
47
48
49 private Map properties;
50
51
52
53
54
55
56
57
58 protected CompositeMap( MavenProject mavenProject, Map properties )
59 {
60 if ( mavenProject == null )
61 {
62 throw new IllegalArgumentException( "no project specified" );
63 }
64 this.mavenProject = mavenProject;
65 this.properties = properties == null ? new Properties() : properties;
66 }
67
68
69
70
71
72
73 public void clear()
74 {
75
76 }
77
78
79
80
81
82
83 public boolean containsKey( Object key )
84 {
85 if ( !( key instanceof String ) )
86 {
87 return false;
88 }
89
90 String expression = (String) key;
91 if ( expression.startsWith( "project." ) || expression.startsWith( "pom." ) )
92 {
93 try
94 {
95 Object evaluated = ReflectionValueExtractor.evaluate( expression, this.mavenProject );
96 if ( evaluated != null )
97 {
98 return true;
99 }
100 }
101 catch ( Exception e )
102 {
103
104 }
105 }
106
107 return properties.containsKey( key ) || mavenProject.getProperties().containsKey( key );
108 }
109
110
111
112
113
114
115 public boolean containsValue( Object value )
116 {
117 throw new UnsupportedOperationException();
118 }
119
120
121
122
123
124
125 public Set entrySet()
126 {
127 throw new UnsupportedOperationException();
128 }
129
130
131
132
133
134
135 public Object get( Object key )
136 {
137 if ( !( key instanceof String ) )
138 {
139 return null;
140 }
141
142 String expression = (String) key;
143 if ( expression.startsWith( "project." ) || expression.startsWith( "pom." ) )
144 {
145 try
146 {
147 Object evaluated = ReflectionValueExtractor.evaluate( expression, this.mavenProject );
148 if ( evaluated != null )
149 {
150 return evaluated;
151 }
152 }
153 catch ( Exception e )
154 {
155
156 }
157 }
158
159 Object value = properties.get( key );
160
161 return ( value != null ? value : this.mavenProject.getProperties().get( key ) );
162
163 }
164
165
166
167
168
169
170 public boolean isEmpty()
171 {
172 return this.mavenProject == null && this.mavenProject.getProperties().isEmpty() && this.properties.isEmpty();
173 }
174
175
176
177
178
179
180 public Set keySet()
181 {
182 throw new UnsupportedOperationException();
183 }
184
185
186
187
188
189
190 public Object put( Object key, Object value )
191 {
192 throw new UnsupportedOperationException();
193 }
194
195
196
197
198
199
200 public void putAll( Map t )
201 {
202 throw new UnsupportedOperationException();
203 }
204
205
206
207
208
209
210 public Object remove( Object key )
211 {
212 throw new UnsupportedOperationException();
213 }
214
215
216
217
218
219
220 public int size()
221 {
222 throw new UnsupportedOperationException();
223 }
224
225
226
227
228
229
230 public Collection values()
231 {
232 throw new UnsupportedOperationException();
233 }
234 }