Class EmailScanner

  • All Implemented Interfaces:
    Scanner

    public class EmailScanner
    extends java.lang.Object
    implements Scanner
    Scan for email address starting from the trigger character "@".

    Based on RFC 6531, but also scans invalid IDN. Doesn't match IP address in domain part or quoting in local part.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean domainMustHaveDot  
    • Constructor Summary

      Constructors 
      Constructor Description
      EmailScanner​(boolean domainMustHaveDot)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private int findFirst​(java.lang.CharSequence input, int beginIndex, int rewindIndex)  
      private int findLast​(java.lang.CharSequence input, int beginIndex)  
      private boolean localAtomAllowed​(char c)  
      LinkSpan scan​(java.lang.CharSequence input, int triggerIndex, int rewindIndex)  
      private boolean subDomainAllowed​(char c)  
      • Methods inherited from class java.lang.Object

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

      • domainMustHaveDot

        private final boolean domainMustHaveDot
    • Constructor Detail

      • EmailScanner

        public EmailScanner​(boolean domainMustHaveDot)
    • Method Detail

      • scan

        public LinkSpan scan​(java.lang.CharSequence input,
                             int triggerIndex,
                             int rewindIndex)
        Specified by:
        scan in interface Scanner
        Parameters:
        input - input text
        triggerIndex - the index at which the trigger character for this scanner was
        rewindIndex - the index that can maximally be rewound to (either the very first character of the input or the character after the last matched link) need to be set to be set here
        Returns:
        the matched link, or null if no link matched
      • findFirst

        private int findFirst​(java.lang.CharSequence input,
                              int beginIndex,
                              int rewindIndex)
      • findLast

        private int findLast​(java.lang.CharSequence input,
                             int beginIndex)
      • localAtomAllowed

        private boolean localAtomAllowed​(char c)
      • subDomainAllowed

        private boolean subDomainAllowed​(char c)