- java.lang.Object
-
- javax.mail.internet.HeaderTokenizer
-
public class HeaderTokenizer extends Object
This 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 Summary
Nested Classes Modifier and Type Class and Description static class
HeaderTokenizer.Token
The Token class represents tokens returned by the HeaderTokenizer.
-
Field Summary
Fields Modifier and Type Field and Description static String
MIME
MIME specialsstatic String
RFC822
RFC822 specials
-
Constructor Summary
Constructors Constructor and Description HeaderTokenizer(String header)
Constructor.HeaderTokenizer(String header, String delimiters)
Constructor.HeaderTokenizer(String header, String delimiters, boolean skipComments)
Constructor that takes a rfc822 style header.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description String
getRemainder()
Return the rest of the Header.HeaderTokenizer.Token
next()
Parses the next token from this String.HeaderTokenizer.Token
next(char endOfAtom)
Parses the next token from this String.HeaderTokenizer.Token
next(char endOfAtom, boolean keepEscapes)
Parses the next token from this String.HeaderTokenizer.Token
peek()
Peek at the next token, without actually removing the token from the parse stream.
-
-
-
Field Detail
-
RFC822
public static final String RFC822
RFC822 specials- See Also:
- Constant Field Values
-
MIME
public static final String MIME
MIME specials- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HeaderTokenizer
public HeaderTokenizer(String header, String delimiters, boolean skipComments)
Constructor that takes a rfc822 style header.- Parameters:
header
- The rfc822 header to be tokenizeddelimiters
- Set of delimiter characters to be used to delimit ATOMS. These are usuallyRFC822
orMIME
skipComments
- If true, comments are skipped and not returned as tokens
-
HeaderTokenizer
public HeaderTokenizer(String header, String delimiters)
Constructor. Comments are ignored and not returned as tokens- Parameters:
header
- The header that is tokenizeddelimiters
- The delimiters to be used
-
HeaderTokenizer
public HeaderTokenizer(String header)
Constructor. The RFC822 defined delimiters - RFC822 - are used to delimit ATOMS. Also comments are skipped and not returned as tokens
-
-
Method Detail
-
next
public 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
-
next
public 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- Since:
- JavaMail 1.5
-
next
public 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 tokenkeepEscapes
- keep all backslashes in returned string?- Returns:
- the next Token
- Throws:
ParseException
- if the parse fails- Since:
- JavaMail 1.5
-
peek
public 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
-
getRemainder
public String getRemainder()
Return the rest of the Header.- Returns:
- String rest of header. null is returned if we are already at end of header
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/mail/internet/HeaderTokenizer.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.