Class UXAddress

java.lang.Object
org.evolvis.tartools.rfc822.Path
org.evolvis.tartools.rfc822.UXAddress

public class UXAddress extends Path

Represents an RFC822 (and successors) eMail address header content, like Path, except the parser accepts more varying input, especially input by humans, and eventually will MIME-encode any nōn-ASCII characters. (For now they cause dropping the label part from the on-wire form.)

Currently implemented user-friendly parse changes are:

  • Allow trailing dot in domains
  • Accept semicolon as mailbox-list separator

Warning: This class is not yet fully implemented!

Author:
mirabilos (t.glaser@tarent.de)
See Also:
  • Constructor Details

    • UXAddress

      protected UXAddress(String input)
      Private constructor. Use the factory method of(String) instead.
      Parameters:
      input - string to analyse
  • Method Details

    • of

      public static UXAddress of(String addresses)
      Creates and initialises a new (forgiving) parser for eMail addresses.
      Parameters:
      addresses - to parse
      Returns:
      null if addresses was null or very large, the new parser instance otherwise
      See Also:
    • pDomainDotAtom

      protected Path.AddrSpecSIDE pDomainDotAtom(org.evolvis.tartools.rfc822.Parser.Substring da)
      Overrides:
      pDomainDotAtom in class Path
    • isMailboxListSeparator

      protected boolean isMailboxListSeparator()
      Overrides:
      isMailboxListSeparator in class Path
    • asAddressList

      public Path.AddressList asAddressList()
      Description copied from class: Path
      Parses the address as address-list, such as for the Reply-To, To, Cc, (optionally) Bcc, Resent-To, … headers. RFC6854 (under RFC2026 §3.3(d) Limited Use circumstances) permits using this production for the From and Resent-From headers, normally covered by the Path.asMailboxList() method.
      Overrides:
      asAddressList in class Path
      Returns:
      parser result; remember to call isValid() on it first!
    • of

      protected static <T extends org.evolvis.tartools.rfc822.Parser> T of(Class<T> cls, String input)

      Constructs a parser. Intended to be used by subclasses from static factory methods *only*; see Path.of(String) for an example.

      Type Parameters:
      T - subclass of Parser to construct
      Parameters:
      cls - subclass of Parser to construct
      input - user-provided String to parse
      Returns:
      null if input was null or too large, the new parser subclass instance otherwise
    • jmp

      protected final int jmp(int pos)
      Jumps to a specified input character position, absolute jump.
      Parameters:
      pos - to jump to
      Returns:
      the codepoint at that position
      Throws:
      IndexOutOfBoundsException - if pos is not in or just past the input
    • bra

      protected final int bra(int deltapos)
      Jumps to a specified input character position, relative jump.
      Parameters:
      deltapos - to add to the current position
      Returns:
      the codepoint at that position
      Throws:
      IndexOutOfBoundsException - if pos is not in or just past the input
    • pos

      protected final int pos()
      Returns the current input character position. Useful for saving and restoring (with jmp(int)) and for error messages.
      Returns:
      position
    • s

      protected final String s()
      Returns the input string, for use with substring comparisons. (This is safe because Java™ strings are immutable.)
      Returns:
      String input
    • cur

      protected final int cur()
      Returns the wide character at the current position.
      Returns:
      UCS-4 codepoint, or -1 if end of input is reached
    • peek

      protected final int peek()
      Returns the wide character after the one at the current position.
      Returns:
      UCS-4 codepoint, or -1 if end of input is reached
    • accept

      protected final int accept()
      Advances the current position to the next character.
      Returns:
      codepoint of the next character, or -1 if end of input is reached
      Throws:
      IndexOutOfBoundsException - if end of input was already reached
    • skipPeek

      protected final int skipPeek(LookaheadMatcher matcher)
      Advances the current position using a peeking matcher. Continues as long as the matcher returns true and end of input is not yet reached.
      Parameters:
      matcher - LookaheadMatcher called with cur() and peek() as arguments to determine whether to skip ahead
      Returns:
      codepoint of the first character for which the matcher returned false, or -1 if end of input is reached
      See Also:
    • skip

      protected final int skip(ContextlessMatcher matcher)
      Advances the current position using a regular matcher. Continues as long as the matcher returns true and end of input is not yet reached.
      Parameters:
      matcher - ContextlessMatcher called with just cur() as argument to determine whether to skip ahead
      Returns:
      codepoint of the first character for which the matcher returned false, or -1 if end of input is reached
      See Also: