KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jxpath > servlet > PageScopeContext


1 /*
2  * Copyright 1999-2004 The 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 package org.apache.commons.jxpath.servlet;
17
18 import java.util.Enumeration JavaDoc;
19
20 import javax.servlet.jsp.PageContext JavaDoc;
21
22 /**
23  * A lightweight wrapper for PageContext that restricts access
24  * to attributes of the "page" scope. This object is needed so that
25  * XPath "foo" would lookup the attribute "foo" in all scopes, while
26  * "$page/foo" would only look in the "page" scope.
27  *
28  * @author Dmitri Plotnikov
29  * @version $Revision: 1.5 $ $Date: 2004/02/29 14:17:40 $
30  */

31 public class PageScopeContext {
32     private PageContext JavaDoc pageContext;
33
34     public PageScopeContext(PageContext JavaDoc pageContext) {
35         this.pageContext = pageContext;
36     }
37
38     /**
39      * Returns attributes of the pageContext declared in the "page" scope.
40      */

41     public Enumeration JavaDoc getAttributeNames() {
42         return pageContext.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
43     }
44
45     public Object JavaDoc getAttribute(String JavaDoc attribute) {
46         return pageContext.getAttribute(attribute, PageContext.PAGE_SCOPE);
47     }
48
49     public void setAttribute(String JavaDoc attribute, Object JavaDoc value) {
50         pageContext.setAttribute(attribute, value, PageContext.PAGE_SCOPE);
51     }
52 }
53
Popular Tags