1 16 package org.apache.cocoon.faces.context; 17 18 import org.apache.cocoon.environment.Session; 19 20 import java.util.Enumeration ; 21 import java.util.HashSet ; 22 import java.util.Set ; 23 24 30 class SessionMap extends BaseMap { 31 32 private Session session; 33 34 35 SessionMap(Session session) { 36 this.session = session; 37 } 38 39 public Object get(Object key) { 40 return session.getAttribute(key.toString()); 41 } 42 43 public Object put(Object key, Object value) { 44 String sKey = key.toString(); 45 Object old = session.getAttribute(sKey); 46 session.setAttribute(sKey, value); 47 return old; 48 } 49 50 public Object remove(Object key) { 51 String sKey = key.toString(); 52 Object old = session.getAttribute(sKey); 53 session.removeAttribute(sKey); 54 return old; 55 } 56 57 public Set entrySet() { 58 Set entries = new HashSet (); 59 for (Enumeration e = session.getAttributeNames(); e.hasMoreElements();) { 60 String name = (String ) e.nextElement(); 61 entries.add(new BaseMap.Entry(name, session.getAttribute(name))); 62 } 63 64 return entries; 65 } 66 67 public boolean equals(Object obj) { 68 if (obj == null || !(obj instanceof SessionMap)) { 69 return false; 70 } 71 72 return super.equals(obj); 73 } 74 } 75 | Popular Tags |