Class FlexibleServletAccessor<T>

  • All Implemented Interfaces:
    java.io.Serializable

    public class FlexibleServletAccessor<T>
    extends java.lang.Object
    implements java.io.Serializable
    Used to flexibly access Map values, supporting the "." (dot) syntax for accessing sub-map values and the "[]" (square bracket) syntax for accessing list elements. See individual Map operations for more information.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      The equals and hashCode methods are implemented just case this object is ever accidently used as a Map key
      T get​(javax.servlet.http.HttpSession session, java.util.Map<java.lang.String,​java.lang.Object> expandContext)
      Based on name get from HttpSession or from List in HttpSession
      T get​(javax.servlet.ServletRequest request, java.util.Map<java.lang.String,​java.lang.Object> expandContext)
      Based on name get from ServletRequest or from List in ServletRequest
      int hashCode()
      The equals and hashCode methods are implemented just case this object is ever accidently used as a Map key *
      protected void init​(java.lang.String name)  
      boolean isEmpty()  
      void put​(javax.servlet.http.HttpSession session, T value, java.util.Map<java.lang.String,​java.lang.Object> expandContext)
      Based on name put in HttpSession or from List in HttpSession; If the brackets for a list are empty the value will be appended to the list, otherwise the value will be set in the position of the number in the brackets.
      void put​(javax.servlet.ServletRequest request, T value, java.util.Map<java.lang.String,​java.lang.Object> expandContext)
      Based on name put in ServletRequest or from List in ServletRequest; If the brackets for a list are empty the value will be appended to the list, otherwise the value will be set in the position of the number in the brackets.
      T remove​(javax.servlet.http.HttpSession session, java.util.Map<java.lang.String,​java.lang.Object> expandContext)
      Based on name remove from HttpSession or from List in HttpSession
      T remove​(javax.servlet.ServletRequest request, java.util.Map<java.lang.String,​java.lang.Object> expandContext)
      Based on name remove from ServletRequest or from List in ServletRequest
      java.lang.String toString()
      To be used for a string representation of the accessor, returns the original name.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • name

        protected java.lang.String name
      • attributeName

        protected java.lang.String attributeName
      • needsExpand

        protected boolean needsExpand
      • empty

        protected boolean empty
    • Constructor Detail

      • FlexibleServletAccessor

        public FlexibleServletAccessor​(java.lang.String name)
      • FlexibleServletAccessor

        public FlexibleServletAccessor​(java.lang.String name,
                                       java.lang.String defaultName)
    • Method Detail

      • init

        protected void init​(java.lang.String name)
      • isEmpty

        public boolean isEmpty()
      • get

        public T get​(javax.servlet.ServletRequest request,
                     java.util.Map<java.lang.String,​java.lang.Object> expandContext)
        Based on name get from ServletRequest or from List in ServletRequest
        Parameters:
        request - request to get the value from
        expandContext - the context to use for name expansion
        Returns:
        the object corresponding to this getter class
      • get

        public T get​(javax.servlet.http.HttpSession session,
                     java.util.Map<java.lang.String,​java.lang.Object> expandContext)
        Based on name get from HttpSession or from List in HttpSession
        Parameters:
        session -
        expandContext -
        Returns:
        the found value
      • put

        public void put​(javax.servlet.ServletRequest request,
                        T value,
                        java.util.Map<java.lang.String,​java.lang.Object> expandContext)
        Based on name put in ServletRequest or from List in ServletRequest; If the brackets for a list are empty the value will be appended to the list, otherwise the value will be set in the position of the number in the brackets. If a "+" (plus sign) is included inside the square brackets before the index number the value will inserted/added at that point instead of set at the point.
        Parameters:
        request -
        value -
        expandContext -
      • put

        public void put​(javax.servlet.http.HttpSession session,
                        T value,
                        java.util.Map<java.lang.String,​java.lang.Object> expandContext)
        Based on name put in HttpSession or from List in HttpSession; If the brackets for a list are empty the value will be appended to the list, otherwise the value will be set in the position of the number in the brackets. If a "+" (plus sign) is included inside the square brackets before the index number the value will inserted/added at that point instead of set at the point.
        Parameters:
        session -
        value -
        expandContext -
      • remove

        public T remove​(javax.servlet.ServletRequest request,
                        java.util.Map<java.lang.String,​java.lang.Object> expandContext)
        Based on name remove from ServletRequest or from List in ServletRequest
        Parameters:
        request -
        expandContext -
        Returns:
        the removed value
      • remove

        public T remove​(javax.servlet.http.HttpSession session,
                        java.util.Map<java.lang.String,​java.lang.Object> expandContext)
        Based on name remove from HttpSession or from List in HttpSession
        Parameters:
        session -
        expandContext -
        Returns:
        the removed value
      • hashCode

        public int hashCode()
        The equals and hashCode methods are implemented just case this object is ever accidently used as a Map key *
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashcode
      • equals

        public boolean equals​(java.lang.Object obj)
        The equals and hashCode methods are implemented just case this object is ever accidently used as a Map key
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj -
        Returns:
        whether this object is equal to the passed object
      • toString

        public java.lang.String toString()
        To be used for a string representation of the accessor, returns the original name.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the name of this accessor