Class MessageMatcher


  • public class MessageMatcher
    extends java.lang.Object
    Searches an email for content.
    • Field Detail

      • logger

        private final org.slf4j.Logger logger
      • searchContents

        private final java.util.List<java.lang.CharSequence> searchContents
      • contentTypes

        private final java.util.List<java.lang.String> contentTypes
      • isCaseInsensitive

        private final boolean isCaseInsensitive
      • includeHeaders

        private final boolean includeHeaders
      • ignoringMime

        private final boolean ignoringMime
    • Constructor Detail

      • MessageMatcher

        private MessageMatcher​(java.util.List<java.lang.CharSequence> searchContents,
                               boolean isCaseInsensitive,
                               boolean includeHeaders,
                               boolean ignoringMime,
                               java.util.List<java.lang.String> contentTypes,
                               org.slf4j.Logger logger)
    • Method Detail

      • messageMatches

        public boolean messageMatches​(java.io.InputStream input)
                               throws java.io.IOException,
                                      MimeException
        Is searchContents found in the given input?
        Parameters:
        input - InputStream containing an email
        Returns:
        true if the content exists and the stream contains the content, false otherwise. It takes the mime structure into account.
        Throws:
        java.io.IOException
        MimeException
      • matchBufferInMailBeingMimeAware

        private boolean matchBufferInMailBeingMimeAware​(java.io.InputStream input,
                                                        java.nio.CharBuffer buffer)
                                                 throws java.io.IOException,
                                                        MimeException
        Throws:
        java.io.IOException
        MimeException
      • checkHeader

        private boolean checkHeader​(java.nio.CharBuffer buffer,
                                    MimeTokenStream parser)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • checkBody

        private boolean checkBody​(java.nio.CharBuffer buffer,
                                  MimeTokenStream parser)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • createBuffer

        private java.nio.CharBuffer createBuffer​(java.lang.CharSequence searchContent)
      • handle

        protected void handle​(java.lang.Exception e)
                       throws java.io.IOException,
                              MimeException
        Throws:
        java.io.IOException
        MimeException
      • isFoundIn

        public boolean isFoundIn​(java.io.Reader reader,
                                 java.nio.CharBuffer buffer)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • computeNextChar

        private char computeNextChar​(boolean isCaseInsensitive,
                                     char read)
      • matches

        private boolean matches​(java.nio.CharBuffer buffer,
                                char next)