Package ej.hoka.session
Class Session
- java.lang.Object
-
- ej.hoka.session.Session
-
public class Session extends java.lang.ObjectServer side Session.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAttribute(java.lang.String name)Get a session attribute.java.util.Set<java.lang.String>getAttributesNames()Gets the set of the session attributes names.longgetExpiration()Gets the expiration.java.lang.StringgetId()Gets the id.booleanhasExpired()Checks whether the session has expired or not.java.lang.StringremoveAttribute(java.lang.String name)Remove an attribute from this session.voidsetAttribute(java.lang.String name, java.lang.String value)Set a session attribute.protected voidsetExpiration(long expiration)Sets the expiration.
-
-
-
Constructor Detail
-
Session
public Session(java.lang.String id, long expiration)Constructs aSession.- Parameters:
id- the identifier of the session.expiration- the expiration date of the session.
-
-
Method Detail
-
getId
public java.lang.String getId()
Gets the id.- Returns:
- the id.
-
getExpiration
public long getExpiration()
Gets the expiration.- Returns:
- the expiration.
-
hasExpired
public boolean hasExpired()
Checks whether the session has expired or not.- Returns:
trueif the session has expired,falseotherwise.
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String value)Set a session attribute.- Parameters:
name- attribute namevalue- attribute value
-
getAttribute
@Nullable public java.lang.String getAttribute(java.lang.String name)
Get a session attribute.- Parameters:
name- attribute name- Returns:
- return attribute mapped to this name if it exists, null otherwise
-
removeAttribute
@Nullable public java.lang.String removeAttribute(java.lang.String name)
Remove an attribute from this session.- Parameters:
name- attribute name- Returns:
- the previous value associated with name, or null if there was no mapping for name.
-
getAttributesNames
public java.util.Set<java.lang.String> getAttributesNames()
Gets the set of the session attributes names.- Returns:
- the set of the session attributes names
-
setExpiration
protected void setExpiration(long expiration)
Sets the expiration.- Parameters:
expiration- the expiration to set in millis.
-
-