Class EmailScanner

java.lang.Object
org.nibor.autolink.internal.EmailScanner
All Implemented Interfaces:
Scanner

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

    • domainMustHaveDot

      private final boolean domainMustHaveDot
  • Constructor Details

    • EmailScanner

      public EmailScanner(boolean domainMustHaveDot)
  • Method Details

    • scan

      public LinkSpan scan(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(CharSequence input, int beginIndex, int rewindIndex)
    • findLast

      private int findLast(CharSequence input, int beginIndex)
    • localAtomAllowed

      private boolean localAtomAllowed(char c)
    • subDomainAllowed

      private boolean subDomainAllowed(char c)