Package org.apache.james.mime4j.stream
Class RawFieldParser
java.lang.Object
org.apache.james.mime4j.stream.RawFieldParser
Low level parser for header field elements. The parsing routines of this class are designed to produce near zero intermediate garbage and make no intermediate copies of input data.
This class is immutable and thread safe.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyContent(ByteSequence buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character, a comment, or any of the given delimiters is encountered.voidcopyQuotedContent(ByteSequence buf, ParserCursor cursor, StringBuilder dst) Transfers content enclosed with quote marks into the destination buffer.voidcopyUnquotedContent(ByteSequence buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character, a comment, a quote, or any of the given delimiters is encountered.static BitSetINIT_BITSET(int... b) parseField(ByteSequence raw) Parses the sequence of bytes intoRawField.parseParameter(ByteSequence buf, ParserCursor cursor) Parses the sequence of bytes containing a field parameter delimited with semicolon intoNameValuePair.parseParameters(ByteSequence buf, ParserCursor cursor) Parses the sequence of bytes containing field parameters delimited with semicolon into a list ofNameValuePairs.parseRawBody(RawField field) Parses the field body containing a value with parameters intoRawBody.parseRawBody(ByteSequence buf, ParserCursor cursor) Parses the sequence of bytes containing a value with parameters intoRawBody.parseToken(ByteSequence buf, ParserCursor cursor, BitSet delimiters) Extracts from the sequence of bytes a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters and comments.parseValue(ByteSequence buf, ParserCursor cursor, BitSet delimiters) Extracts from the sequence of bytes a value which can be enclosed in quote marks and terminated with any of the given delimiters discarding semantically insignificant whitespace characters and comments.voidskipAllWhiteSpace(ByteSequence buf, ParserCursor cursor) Skips semantically insignificant whitespace characters and comments and moves the cursor to the closest semantically significant non-whitespace character.voidskipComment(ByteSequence buf, ParserCursor cursor) Skips semantically insignificant content if the current position is positioned at the beginning of a comment and moves the cursor past the end of the comment.voidskipWhiteSpace(ByteSequence buf, ParserCursor cursor) Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.
-
Field Details
-
DEFAULT
-
-
Constructor Details
-
RawFieldParser
public RawFieldParser()
-
-
Method Details
-
INIT_BITSET
-
parseField
Parses the sequence of bytes intoRawField.- Throws:
MimeException- if the input data does not contain a valid MIME field.
-
parseRawBody
Parses the field body containing a value with parameters intoRawBody.- Parameters:
field- unstructured (raw) field
-
parseRawBody
Parses the sequence of bytes containing a value with parameters intoRawBody.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the buffer
-
parseParameters
Parses the sequence of bytes containing field parameters delimited with semicolon into a list ofNameValuePairs.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the buffer
-
parseParameter
Parses the sequence of bytes containing a field parameter delimited with semicolon intoNameValuePair.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the buffer
-
parseToken
Extracts from the sequence of bytes a token terminated with any of the given delimiters discarding semantically insignificant whitespace characters and comments.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the token is not delimited by any character.
-
parseValue
Extracts from the sequence of bytes a value which can be enclosed in quote marks and terminated with any of the given delimiters discarding semantically insignificant whitespace characters and comments.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the value is not delimited by any character.
-
skipWhiteSpace
Skips semantically insignificant whitespace characters and moves the cursor to the closest non-whitespace character.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the buffer
-
skipComment
Skips semantically insignificant content if the current position is positioned at the beginning of a comment and moves the cursor past the end of the comment. Nested comments and escaped characters are recognized and handled appropriately.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the buffer
-
skipAllWhiteSpace
Skips semantically insignificant whitespace characters and comments and moves the cursor to the closest semantically significant non-whitespace character. Nested comments and escaped characters are recognized and handled appropriately.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the buffer
-
copyContent
public void copyContent(ByteSequence buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character, a comment, or any of the given delimiters is encountered.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the value is delimited by a whitespace or a comment only.dst- destination buffer
-
copyUnquotedContent
public void copyUnquotedContent(ByteSequence buf, ParserCursor cursor, BitSet delimiters, StringBuilder dst) Transfers content into the destination buffer until a whitespace character, a comment, a quote, or any of the given delimiters is encountered.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the bufferdelimiters- set of delimiting characters. Can benullif the value is delimited by a whitespace, a quote or a comment only.dst- destination buffer
-
copyQuotedContent
Transfers content enclosed with quote marks into the destination buffer.- Parameters:
buf- buffer with the sequence of bytes to be parsedcursor- defines the bounds and current position of the bufferdst- destination buffer
-