Package spark

Class FilterImpl

  • All Implemented Interfaces:
    Filter, Wrapper

    public abstract class FilterImpl
    extends java.lang.Object
    implements Filter, Wrapper
    FilterImpl is created from a path, acceptType and Filter. This is encapsulate the information needed in the route matcher in a single container.
    • Field Detail

      • path

        private java.lang.String path
      • acceptType

        private java.lang.String acceptType
      • delegate

        private Filter delegate
    • Constructor Detail

      • FilterImpl

        protected FilterImpl​(java.lang.String path,
                             java.lang.String acceptType)
      • FilterImpl

        protected FilterImpl​(java.lang.String path,
                             java.lang.String acceptType,
                             Filter filter)
    • Method Detail

      • create

        static FilterImpl create​(java.lang.String path,
                                 Filter filter)
        Wraps the filter in FilterImpl
        Parameters:
        path - the path
        filter - the filter
        Returns:
        the wrapped route
      • create

        static FilterImpl create​(java.lang.String path,
                                 java.lang.String acceptType,
                                 Filter filter)
        Wraps the filter in FilterImpl
        Parameters:
        path - the path
        acceptType - the accept type
        filter - the filter
        Returns:
        the wrapped route
      • handle

        public abstract void handle​(Request request,
                                    Response response)
                             throws java.lang.Exception
        Invoked when a request is made on this filter's corresponding path e.g. '/hello'
        Specified by:
        handle in interface Filter
        Parameters:
        request - The request object providing information about the HTTP request
        response - The response object providing functionality for modifying the response
        Throws:
        java.lang.Exception - when handle fails
      • getAcceptType

        public java.lang.String getAcceptType()
      • getPath

        public java.lang.String getPath()
        Returns this route's path
      • delegate

        public java.lang.Object delegate()
        Specified by:
        delegate in interface Wrapper
        Returns:
        the filter used to create the filter implementation