Class MimeTypeValidator

  • All Implemented Interfaces:
    Validator

    public class MimeTypeValidator
    extends Object
    implements Validator
    This class determines the validity of a response by its mime type.

    A mime type that matches the pattern should return Status.INVALID_CONTENT, or Status.VALID otherwise.

    Author:
    Maksim Tkachenko, Ween Jiann Lee
    • Constructor Detail

      • MimeTypeValidator

        public MimeTypeValidator​(String regex)
        Constructs mime type validator.
        Parameters:
        regex - A regex string to match valid mime type
      • MimeTypeValidator

        public MimeTypeValidator​(Pattern regex)
        Constructs mime type validator.
        Parameters:
        regex - A regex pattern to match valid mime type
    • Method Detail

      • isValid

        public final Validator.Status isValid​(Request request,
                                              Response response)
        Description copied from interface: Validator
        Method will be called when a response need validation.
        Specified by:
        isValid in interface Validator
        Parameters:
        request - request sent to fetch a response
        response - response fetched
        Returns:
        the status of validation