io.higgs.http.server.params.HttpSession Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-s3 Show documentation
Show all versions of http-s3 Show documentation
Higgs HTTP S3 (Single Site Server)
package io.higgs.http.server.params;
import java.util.HashMap;
/**
* @author Courtney Robinson
*/
public class HttpSession extends HashMap {
private final HashMap flash = new HashMap<>();
/**
* Adds a key value pair to the session which is good for one use.
* Once the object is retrieved it is automatically removed
*/
public V flash(K key, V value) {
return flash.put(key, value);
}
@Override
public V get(Object key) {
V val = super.get(key);
if (val == null) {
val = flash.get(key);
if (val != null) {
flash.remove(key);
}
}
return val;
}
/**
* @return Total combination of normal session objects and flash objects
*/
public int getSize() {
return size() + flash.size();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy