1 18 package org.apache.beehive.netui.script.common; 19 20 22 import java.util.ArrayList ; 23 import java.util.Iterator ; 24 import java.util.Map ; 25 import java.util.Set ; 26 27 import javax.servlet.ServletRequest ; 28 import javax.servlet.http.HttpServletRequest ; 29 30 import org.apache.beehive.netui.pageflow.PageFlowUtils; 32 import org.apache.beehive.netui.pageflow.internal.InternalUtils; 33 import org.apache.beehive.netui.util.logging.Logger; 34 35 37 45 public class ScriptablePageInput 46 extends AbstractScriptableMap { 47 48 private static final Logger _logger = Logger.getInstance(ScriptablePageInput.class); 49 50 private HttpServletRequest _request = null; 51 private Set _entrySet = null; 52 53 public ScriptablePageInput(ServletRequest request) { 54 assert request instanceof HttpServletRequest ; 55 56 _request = (HttpServletRequest )request; 57 } 58 59 public Object get(Object name) { 60 if(_logger.isDebugEnabled()) _logger.debug("page input get: " + name); 61 62 assert name instanceof String ; 63 64 return PageFlowUtils.getActionOutput((String )name, _request); 65 } 66 67 75 public Set entrySet() { 76 if(_entrySet == null) { 77 Map piMap = InternalUtils.getPageInputMap(_request); 78 ArrayList list = new ArrayList (); 79 if(piMap != null) { 80 Iterator iterator = piMap.keySet().iterator(); 81 while(iterator.hasNext()) { 82 Object name = iterator.next(); 83 Object value = piMap.get(name); 84 list.add(new Entry(name, value)); 85 } 86 } 87 88 _entrySet = new EntrySet((Entry[])list.toArray(new Entry[]{})); 89 } 90 91 return _entrySet; 92 } 93 94 public boolean equals(Object obj) { 95 if(obj == null || !(obj instanceof ScriptablePageInput)) 96 return false; 97 return super.equals(obj); 98 } 99 100 public boolean containsKey(Object key) { 101 Map piMap = InternalUtils.getPageInputMap(_request); 102 return (piMap != null ? piMap.containsKey(key) : false); 103 } 104 } 105 | Popular Tags |