Class SimpleContextManager

java.lang.Object
com.techcognita.javachatx.context.SimpleContextManager
All Implemented Interfaces:
ContextManager

public class SimpleContextManager extends Object implements ContextManager
Simple implementation of the ContextManager interface. Manages session context using in-memory storage.
  • Constructor Details

    • SimpleContextManager

      public SimpleContextManager()
  • Method Details

    • setContext

      public void setContext(String sessionId, String key, Object value)
      Description copied from interface: ContextManager
      Store context data for a session.
      Specified by:
      setContext in interface ContextManager
      Parameters:
      sessionId - The session identifier
      key - The context key
      value - The context value
    • getContext

      public Object getContext(String sessionId, String key)
      Description copied from interface: ContextManager
      Retrieve context data for a session.
      Specified by:
      getContext in interface ContextManager
      Parameters:
      sessionId - The session identifier
      key - The context key
      Returns:
      The context value, or null if not found
    • getSessionContext

      public com.google.gson.JsonObject getSessionContext(String sessionId)
      Description copied from interface: ContextManager
      Get all context data for a session as a JSON object.
      Specified by:
      getSessionContext in interface ContextManager
      Parameters:
      sessionId - The session identifier
      Returns:
      All context data for the session
    • clearContext

      public void clearContext(String sessionId)
      Description copied from interface: ContextManager
      Clear context data for a session.
      Specified by:
      clearContext in interface ContextManager
      Parameters:
      sessionId - The session identifier
    • addToHistory

      public void addToHistory(String sessionId, com.google.gson.JsonObject message)
      Description copied from interface: ContextManager
      Add a message to the conversation history.
      Specified by:
      addToHistory in interface ContextManager
      Parameters:
      sessionId - The session identifier
      message - The message to add to history
    • getHistory

      public com.google.gson.JsonObject getHistory(String sessionId)
      Description copied from interface: ContextManager
      Get the conversation history for a session.
      Specified by:
      getHistory in interface ContextManager
      Parameters:
      sessionId - The session identifier
      Returns:
      The conversation history