- java.lang.Object
- 
- jakarta.mail.internet.HeaderTokenizer
 
- 
 public class HeaderTokenizer extends java.lang.ObjectThis class tokenizes RFC822 and MIME headers into the basic symbols specified by RFC822 and MIME.This class handles folded headers (ie headers with embedded CRLF SPACE sequences). The folds are removed in the returned tokens. - Author:
- John Mani, Bill Shannon
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classHeaderTokenizer.TokenThe Token class represents tokens returned by the HeaderTokenizer.
 - 
Constructor SummaryConstructors Constructor Description HeaderTokenizer(java.lang.String header)Constructor.HeaderTokenizer(java.lang.String header, java.lang.String delimiters)Constructor.HeaderTokenizer(java.lang.String header, java.lang.String delimiters, boolean skipComments)Constructor that takes a rfc822 style header.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetRemainder()Return the rest of the Header.HeaderTokenizer.Tokennext()Parses the next token from this String.HeaderTokenizer.Tokennext(char endOfAtom)Parses the next token from this String.HeaderTokenizer.Tokennext(char endOfAtom, boolean keepEscapes)Parses the next token from this String.HeaderTokenizer.Tokenpeek()Peek at the next token, without actually removing the token from the parse stream.
 
- 
- 
- 
Field Detail- 
RFC822public static final java.lang.String RFC822 RFC822 specials- See Also:
- Constant Field Values
 
 - 
MIMEpublic static final java.lang.String MIME MIME specials- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
HeaderTokenizerpublic HeaderTokenizer(java.lang.String header, java.lang.String delimiters, boolean skipComments)Constructor that takes a rfc822 style header.- Parameters:
- skipComments- If true, comments are skipped and not returned as tokens
- header- The rfc822 header to be tokenized
- delimiters- Set of delimiter characters to be used to delimit ATOMS. These are usually- RFC822or- MIME
 
 - 
HeaderTokenizerpublic HeaderTokenizer(java.lang.String header, java.lang.String delimiters)Constructor. Comments are ignored and not returned as tokens- Parameters:
- header- The header that is tokenized
- delimiters- The delimiters to be used
 
 - 
HeaderTokenizerpublic HeaderTokenizer(java.lang.String header) Constructor. The RFC822 defined delimiters - RFC822 - are used to delimit ATOMS. Also comments are skipped and not returned as tokens- Parameters:
- header- the header string
 
 
- 
 - 
Method Detail- 
nextpublic HeaderTokenizer.Token next() throws ParseException Parses the next token from this String.Clients sit in a loop calling next() to parse successive tokens until an EOF Token is returned. - Returns:
- the next Token
- Throws:
- ParseException- if the parse fails
 
 - 
nextpublic HeaderTokenizer.Token next(char endOfAtom) throws ParseException Parses the next token from this String. If endOfAtom is not NUL, the token extends until the endOfAtom character is seen, or to the end of the header. This method is useful when parsing headers that don't obey the MIME specification, e.g., by failing to quote parameter values that contain spaces.- Parameters:
- endOfAtom- if not NUL, character marking end of token
- Returns:
- the next Token
- Throws:
- ParseException- if the parse fails
 
 - 
nextpublic HeaderTokenizer.Token next(char endOfAtom, boolean keepEscapes) throws ParseException Parses the next token from this String. endOfAtom is handled as above. If keepEscapes is true, any backslash escapes are preserved in the returned string. This method is useful when parsing headers that don't obey the MIME specification, e.g., by failing to escape backslashes in the filename parameter.- Parameters:
- endOfAtom- if not NUL, character marking end of token
- keepEscapes- keep all backslashes in returned string?
- Returns:
- the next Token
- Throws:
- ParseException- if the parse fails
 
 - 
peekpublic HeaderTokenizer.Token peek() throws ParseException Peek at the next token, without actually removing the token from the parse stream. Invoking this method multiple times will return successive tokens, untilnext()is called.- Returns:
- the next Token
- Throws:
- ParseException- if the parse fails
 
 - 
getRemainderpublic java.lang.String getRemainder() Return the rest of the Header.- Returns:
- String rest of header. null is returned if we are already at end of header
 
 
- 
 
-