Package org.evolvis.tartools.rfc822
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:
Path
-
-
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intaccept()Advances the current position to the next character.Path.AddressListasAddressList()Parses the address asaddress-list, such as for theReply-To,To,Cc, (optionally)Bcc,Resent-To, … headers.protected intbra(int deltapos)Jumps to a specified input character position, relative jump.protected intcur()Returns the wide character at the current position.protected booleanisMailboxListSeparator()protected intjmp(int pos)Jumps to a specified input character position, absolute jump.protected static <T extends org.evolvis.tartools.rfc822.Parser>
Tof(Class<T> cls, String input)Constructs a parser.static UXAddressof(String addresses)Creates and initialises a new (forgiving) parser for eMail addresses.protected Path.AddrSpecSIDEpDomainDotAtom(org.evolvis.tartools.rfc822.Parser.Substring da)protected intpeek()Returns the wide character after the one at the current position.protected intpos()Returns the current input character position.protected Strings()Returns the input string, for use with substring comparisons.protected intskip(ContextlessMatcher matcher)Advances the current position using a regular matcher.protected 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 Detail
-
UXAddress
protected UXAddress(String input)
Private constructor. Use the factory methodof(String)instead.- Parameters:
input- string to analyse
-
-
Method Detail
-
of
public static UXAddress of(String addresses)
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:
Path.of(String)
-
pDomainDotAtom
protected Path.AddrSpecSIDE pDomainDotAtom(org.evolvis.tartools.rfc822.Parser.Substring da)
- Overrides:
pDomainDotAtomin classPath
-
isMailboxListSeparator
protected boolean isMailboxListSeparator()
- Overrides:
isMailboxListSeparatorin classPath
-
asAddressList
public Path.AddressList 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
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 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
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
-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
protected final int skipPeek(LookaheadMatcher matcher)
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(ContextlessMatcher)
-
skip
protected final int skip(ContextlessMatcher matcher)
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:
skipPeek(LookaheadMatcher)
-
-