Class Session


  • public class Session
    extends java.lang.Object
    Server side Session.
    • Constructor Summary

      Constructors 
      Constructor Description
      Session​(java.lang.String id, long expiration)
      Constructs a Session.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getAttribute​(java.lang.String name)
      Get a session attribute.
      java.util.Set<java.lang.String> getAttributesNames()
      Gets the set of the session attributes names.
      long getExpiration()
      Gets the expiration.
      java.lang.String getId()
      Gets the id.
      boolean hasExpired()
      Checks whether the session has expired or not.
      java.lang.String removeAttribute​(java.lang.String name)
      Remove an attribute from this session.
      void setAttribute​(java.lang.String name, java.lang.String value)
      Set a session attribute.
      protected void setExpiration​(long expiration)
      Sets the expiration.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Session

        public Session​(java.lang.String id,
                       long expiration)
        Constructs a Session.
        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:
        true if the session has expired, false otherwise.
      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 java.lang.String value)
        Set a session attribute.
        Parameters:
        name - attribute name
        value - 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.