SunONE Application Server v8.0 PE

javax.mail.internet
Class HeaderTokenizer

java.lang.Object
  extended byjavax.mail.internet.HeaderTokenizer

public class HeaderTokenizer
extends java.lang.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.

Version:
1.9, 02/03/27
Author:
John Mani

Nested Class Summary
static class HeaderTokenizer.Token
          The Token class represents tokens returned by the HeaderTokenizer.
 
Field Summary
static java.lang.String MIME
          MIME specials
static java.lang.String RFC822
          RFC822 specials
 
Constructor Summary
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 Summary
 java.lang.String getRemainder()
          Return the rest of the Header.
 HeaderTokenizer.Token next()
          Parses the next token from this String.
 HeaderTokenizer.Token peek()
          Peek at the next token, without actually removing the token from the parse stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RFC822

public static final java.lang.String RFC822
RFC822 specials

See Also:
Constant Field Values

MIME

public static final java.lang.String MIME
MIME specials

See Also:
Constant Field Values
Constructor Detail

HeaderTokenizer

public HeaderTokenizer(java.lang.String header,
                       java.lang.String delimiters,
                       boolean skipComments)
Constructor that takes a rfc822 style header.

Parameters:
header - The rfc822 header to be tokenized
delimiters - Set of delimiter characters to be used to delimit ATOMS. These are usually RFC822 or MIME
skipComments - If true, comments are skipped and not returned as tokens

HeaderTokenizer

public 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

HeaderTokenizer

public 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

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

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, until next() is called.

Returns:
the next Token
Throws:
ParseException - if the parse fails

getRemainder

public 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

SunONE Application Server v8.0 PE

Submit a bug or feature

Copyright 2003 Sun Microsystems, Inc. All rights reserved.