1 16 package org.apache.commons.jxpath.servlet; 17 18 import java.util.Enumeration ; 19 import java.util.HashSet ; 20 21 import javax.servlet.jsp.PageContext ; 22 23 import org.apache.commons.jxpath.DynamicPropertyHandler; 24 25 32 public class PageContextHandler implements DynamicPropertyHandler { 33 34 public String [] getPropertyNames(Object pageContext) { 35 HashSet list = new HashSet (); 36 Enumeration e = 37 ((PageContext ) pageContext).getAttributeNamesInScope( 38 PageContext.PAGE_SCOPE); 39 while (e.hasMoreElements()) { 40 list.add(e.nextElement()); 41 } 42 e = 43 ((PageContext ) pageContext).getAttributeNamesInScope( 44 PageContext.REQUEST_SCOPE); 45 while (e.hasMoreElements()) { 46 list.add(e.nextElement()); 47 } 48 e = 49 ((PageContext ) pageContext).getAttributeNamesInScope( 50 PageContext.SESSION_SCOPE); 51 while (e.hasMoreElements()) { 52 list.add(e.nextElement()); 53 } 54 e = 55 ((PageContext ) pageContext).getAttributeNamesInScope( 56 PageContext.APPLICATION_SCOPE); 57 while (e.hasMoreElements()) { 58 list.add(e.nextElement()); 59 } 60 return (String []) list.toArray(new String [0]); 61 } 62 63 66 public Object getProperty(Object pageContext, String property) { 67 return ((PageContext ) pageContext).findAttribute(property); 68 } 69 70 public void setProperty( 71 Object pageContext, 72 String property, 73 Object value) 74 { 75 ((PageContext ) pageContext).setAttribute( 76 property, 77 value, 78 PageContext.PAGE_SCOPE); 79 } 80 } 81 | Popular Tags |