This project has retired. For details please refer to its Attic page.
MustacheScopeExtractor xref
View Javadoc

1   /*
2    * Copyright 2012 Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.tiles.request.mustache;
18  
19  import java.util.Collections;
20  import java.util.Enumeration;
21  import java.util.Map;
22  import java.util.Set;
23  
24  import org.apache.tiles.request.attribute.AttributeExtractor;
25  
26  
27  public final class MustacheScopeExtractor  implements AttributeExtractor {
28      private final Map<String,Object> scope;
29  
30      public MustacheScopeExtractor(Map<String,Object> scope) {
31          this.scope = scope;
32      }
33  
34      @Override
35      public void removeValue(String key) {
36          scope.remove(key);
37      }
38  
39      @Override
40      public Enumeration<String> getKeys() {
41          return (Enumeration<String>) Collections.enumeration((Set<?>)scope.keySet());
42      }
43  
44      @Override
45      public Object getValue(String key) {
46          return scope.get(key);
47      }
48  
49      @Override
50      public void setValue(String key, Object value) {
51          scope.put(key, value);
52      }
53  }