Class MimeTypeValidator

  • All Implemented Interfaces:
    Validator

    public class MimeTypeValidator
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      MimeTypeValidator​(java.lang.String regex)
      Constructs mime type validator.
      MimeTypeValidator​(java.util.regex.Pattern regex)
      Constructs mime type validator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Validator.Status isValid​(Request request, Response response)
      Method will be called when a response need validation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MimeTypeValidator

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

        public MimeTypeValidator​(java.util.regex.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