Class SimpleHash

    • Method Detail

      • copyMap

        protected Map copyMap​(Map map)
      • put

        public void put​(String key,
                        Object value)
        Adds a key-value entry to this hash.
        Parameters:
        key - The name by which the object is identified in the template.
        value - The value to which the name will be associated. This will only be wrapped to TemplateModel lazily when it's first read.
      • put

        public void put​(String key,
                        boolean b)
        Puts a boolean in the map
        Parameters:
        key - the name by which the resulting TemplateModel is identified in the template.
        b - the boolean to store.
      • containsKey

        public boolean containsKey​(String key)
        Tells if the map contains a key or not, regardless if the associated value is null or not.
        Since:
        2.3.20
      • remove

        public void remove​(String key)
        Removes the given key from the underlying map.
        Parameters:
        key - the key to be removed
      • putAll

        public void putAll​(Map m)
        Adds all the key/value entries in the map
        Parameters:
        m - the map with the entries to add, the keys are assumed to be strings.
      • toMap

        public Map toMap()
                  throws TemplateModelException
        Note that this method creates and returns a deep-copy of the underlying hash used internally. This could be a gotcha for some people at some point who want to alter something in the data model, but we should maintain our immutability semantics (at least using default SimpleXXX wrappers) for the data model. It will recursively unwrap the stuff in the underlying container.
        Throws:
        TemplateModelException
      • toString

        public String toString()
        Returns the toString() of the underlying Map.
        Overrides:
        toString in class Object
      • size

        public int size()
        Specified by:
        size in interface TemplateHashModelEx
        Returns:
        the number of key/value mappings in the hash.
      • synchronizedWrapper

        public SimpleHash synchronizedWrapper()