1/*2 * $Id: ScopeExtractor.java 1066790 2011-02-03 12:06:20Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */21package org.apache.tiles.request.jsp.extractor;
2223import java.util.Enumeration;
2425import javax.servlet.jsp.JspContext;
2627import org.apache.tiles.request.attribute.AttributeExtractor;
2829/**30 * Extracts attributes from a numbered scope from {@link JspContext}.31 *32 * @version $Rev: 1066790 $ $Date: 2011-02-03 23:06:20 +1100 (Thu, 03 Feb 2011) $33 */34publicclassScopeExtractorimplementsAttributeExtractor {
3536/**37 * The JSP context.38 */39private JspContext context;
4041/**42 * The scope number to use.43 */44privateint scope;
4546/**47 * Constructor.48 *49 * @param context The JSP context.50 * @param scope The scope number.51 */52publicScopeExtractor(JspContext context, int scope) {
53this.context = context;
54this.scope = scope;
55 }
5657 @Override
58publicvoid removeValue(String name) {
59 context.removeAttribute(name, scope);
60 }
6162 @Override
63public Enumeration<String> getKeys() {
64return context.getAttributeNamesInScope(scope);
65 }
6667 @Override
68public Object getValue(String key) {
69return context.getAttribute(key, scope);
70 }
7172 @Override
73publicvoid setValue(String key, Object value) {
74 context.setAttribute(key, value, scope);
75 }
76 }