Package org.evolvis.tartools.rfc822
Class UXAddress
java.lang.Object
org.evolvis.tartools.rfc822.Path
org.evolvis.tartools.rfc822.UXAddress
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.evolvis.tartools.rfc822.Path
Path.Address, Path.AddressList, Path.AddrSpec, Path.AddrSpecSIDE, Path.ParserResult, Path.UnfoldedSubstring -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final intaccept()Advances the current position to the next character.Parses the address asaddress-list, such as for theReply-To,To,Cc, (optionally)Bcc,Resent-To, … headers.protected final intbra(int deltapos) Jumps to a specified input character position, relative jump.protected final intcur()Returns the wide character at the current position.protected booleanprotected final intjmp(int pos) Jumps to a specified input character position, absolute jump.protected static <T extends org.evolvis.tartools.rfc822.Parser>
TConstructs a parser.static UXAddressCreates and initialises a new (forgiving) parser for eMail addresses.protected Path.AddrSpecSIDEpDomainDotAtom(org.evolvis.tartools.rfc822.Parser.Substring da) protected final intpeek()Returns the wide character after the one at the current position.protected final intpos()Returns the current input character position.protected final Strings()Returns the input string, for use with substring comparisons.protected final intskip(ContextlessMatcher matcher) Advances the current position using a regular matcher.protected final intskipPeek(LookaheadMatcher matcher) Advances the current position using a peeking matcher.Methods inherited from class org.evolvis.tartools.rfc822.Path
asAddrSpec, asMailboxList, forSender, is, isAtext, isCtext, isDtext, isQtext, pAddress, pAddressList, pAddrSpec, pAngleAddr, pAtom, pCcontent, pCFWS, pComment, pDisplayName, pDomain, pDomainLiteral, pDotAtom, pFWS, pGroup, pLocalPart, pMailbox, pMailboxList, pNameAddr, pPhrase, pQcontent, pQuotedPair, pQuotedString, pWord, unfold, unfold
-
Constructor Details
-
UXAddress
Private constructor. Use the factory methodof(String)instead.- Parameters:
input- string to analyse
-
-
Method Details
-
of
Creates and initialises a new (forgiving) parser for eMail addresses.- Parameters:
addresses- to parse- Returns:
- null if
addresseswas null or very large, the new parser instance otherwise - See Also:
-
pDomainDotAtom
- Overrides:
pDomainDotAtomin classPath
-
isMailboxListSeparator
protected boolean isMailboxListSeparator()- Overrides:
isMailboxListSeparatorin classPath
-
asAddressList
Description copied from class:PathParses the address asaddress-list, such as for theReply-To,To,Cc, (optionally)Bcc,Resent-To, … headers. RFC6854 (under RFC2026 §3.3(d) Limited Use circumstances) permits using this production for theFromandResent-Fromheaders, normally covered by thePath.asMailboxList()method.- Overrides:
asAddressListin classPath- Returns:
- parser result; remember to call isValid() on it first!
-
of
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 constructinput- user-providedStringto 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 (withjmp(int)) and for error messages.- Returns:
- position
-
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
-1if 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
-1if 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
-1if end of input is reached - Throws:
IndexOutOfBoundsException- if end of input was already reached
-
skipPeek
Advances the current position using a peeking matcher. Continues as long as thematcherreturns true and end of input is not yet reached.- Parameters:
matcher-LookaheadMatchercalled withcur()andpeek()as arguments to determine whether to skip ahead- Returns:
- codepoint of the first character for which the matcher returned false,
or
-1if end of input is reached - See Also:
-
skip
Advances the current position using a regular matcher. Continues as long as thematcherreturns true and end of input is not yet reached.- Parameters:
matcher-ContextlessMatchercalled with justcur()as argument to determine whether to skip ahead- Returns:
- codepoint of the first character for which the matcher returned false,
or
-1if end of input is reached - See Also:
-