Package spark

Class FilterImpl

java.lang.Object
spark.FilterImpl
All Implemented Interfaces:
Filter, Wrapper

public abstract class FilterImpl extends 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 Details

  • Constructor Details

    • FilterImpl

      protected FilterImpl(String path, String acceptType)
    • FilterImpl

      protected FilterImpl(String path, String acceptType, Filter filter)
  • Method Details

    • withPrefix

      public FilterImpl withPrefix(String prefix)
      Parameters:
      prefix - the prefix
      Returns:
      itself for easy chaining
    • create

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

      static FilterImpl create(String path, 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 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:
      Exception - when handle fails
    • getAcceptType

      public String getAcceptType()
    • getPath

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

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