Class AbstractContext

  • All Implemented Interfaces:
    IContext
    Direct Known Subclasses:
    AbstractExpressionContext, Context, WebContext

    public abstract class AbstractContext
    extends 
    implements IContext

    Abstract base class for most IContext implementations.

    Note a class with this name existed since 1.0, but it was completely reimplemented in Thymeleaf 3.0

    Since:
    3.0.0
    Author:
    Daniel Fernández
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractContext()  
      protected  locale)  
      protected  locale, <,​> variables)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearVariables()
      Removes all the variables from the context.
      boolean  name)
      Checks whether a specific variable is already contained in this context or not.
      getLocale()
      Returns the locale that should be used for processing the template.
       name)
      Retrieve a specific variable, by name.
      <> getVariableNames()
      Get a list with all the names of variables contained at this context.
      void  name)
      Removes a variable from the context.
      void  locale)
      Sets the locale to be used.
      void  name,  value)
      Sets a new variable into the context.
      void <,​> variables)
      Sets several variables at a time into the context.
      • Methods inherited from class java.lang.

        , , , , , , , , , ,
    • Constructor Detail

      • AbstractContext

        protected AbstractContext()
      • AbstractContext

        protected AbstractContext​( locale)
      • AbstractContext

        protected AbstractContext​( locale,
                                  <,​> variables)
    • Method Detail

      • getLocale

        public final  getLocale()
        Description copied from interface: IContext

        Returns the locale that should be used for processing the template.

        Specified by:
        getLocale in interface IContext
        Returns:
        the locale to be used.
      • containsVariable

        public final boolean containsVariable​( name)
        Description copied from interface: IContext

        Checks whether a specific variable is already contained in this context or not.

        Specified by:
        containsVariable in interface IContext
        Parameters:
        name - the name of the variable to be checked.
        Returns:
        true if the variable is already contained, false if not.
      • getVariableNames

        public final <> getVariableNames()
        Description copied from interface: IContext

        Get a list with all the names of variables contained at this context.

        Specified by:
        getVariableNames in interface IContext
        Returns:
        the variable names.
      • getVariable

        public final  getVariable​( name)
        Description copied from interface: IContext

        Retrieve a specific variable, by name.

        Specified by:
        getVariable in interface IContext
        Parameters:
        name - the name of the variable to be retrieved.
        Returns:
        the variable's value.
      • setLocale

        public void setLocale​( locale)

        Sets the locale to be used.

        Parameters:
        locale - the locale.
      • setVariable

        public void setVariable​( name,
                                 value)

        Sets a new variable into the context.

        Parameters:
        name - the name of the variable.
        value - the value of the variable.
      • setVariables

        public void setVariables​(<,​> variables)

        Sets several variables at a time into the context.

        Parameters:
        variables - the variables to be set.
      • removeVariable

        public void removeVariable​( name)

        Removes a variable from the context.

        Parameters:
        name - the name of the variable to be removed.
      • clearVariables

        public void clearVariables()

        Removes all the variables from the context.